summaryrefslogtreecommitdiff
path: root/libavformat/movenc.c
Commit message (Collapse)AuthorAge
* avformat/av1: Avoid allocation + copying when filtering OBUsAndreas Rheinhardt2020-01-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | Certain types of OBUs are stripped away before muxing into Matroska and ISOBMFF; there are two functions to do this: One that outputs by directly writing in an AVIOContext and one that returns a freshly allocated buffer with the units not stripped away copied into it. The latter option is bad for performance, especially when the input does already not contain any of the units intended to be stripped away (this covers typical remuxing scenarios). Therefore this commit changes this by avoiding allocating and copying when possible; it is possible if the OBUs to be retained are consecutively in the input buffer (without an OBU to be discarded between them). In this case, the caller receives the offset as well as the length of the part of the buffer that contains the units to be kept. This also avoids copying when e.g. the only unit to be discarded is a temporal delimiter at the front. For a 22.7mb/s file with average framesize 113 kB this improved the time for the calls to ff_av1_filter_obus_buf() when writing Matroska from 313319 decicycles to 2368 decicycles; for another file with 1.5mb/s (average framesize 7.3 kB) it improved from 34539 decicycles to 1922 decicyles. For these files the only units that needed to be stripped away were temporal unit delimiters at the front. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: Check for reformatting errors when writing hint tracksAndreas Rheinhardt2020-01-26
| | | | | | | | If this is not done, the avio_write() calls will cause segfaults immediately afterwards on error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: allow ISMV timescale to be user-setGyan Doshi2020-01-25
| | | | | | | | As per the PIFF standard, the timescale of 10000000 is recommended but not mandatory, so don't override the user-set value. A warning is shown for non-recommended values.
* avformat/movenc, segafilmenc: Remove unnecessary avio_tell()Andreas Rheinhardt2020-01-17
| | | | | | | | | | | | | | When the faststart option for the mov/mp4 muxer is used, the current position (i.e. the size of the already written data pre-shifting) was evaluated twice: First in an initialization and then again later, overwriting the first value without having ever touched it. So remove the initialization. Also, the clone of this code in the Sega FILM muxer behaves the same and has been treated the same. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Revert "avformat/utils: make ff_ntp_time() accept a timestamp as input argument"James Almer2020-01-16
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: add a flag to enable CMAF compatabilityJames Almer2020-01-15
| | | | | | | Sets some required constrains and reports compatability with the relevant compatible brand. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: use AVProducerReferenceTime side data to write the prft atomJames Almer2020-01-15
| | | | | | | If not available, set flags to 24 (bits 4 and 5), to signal the wallclock value is read at the time of writing the atom. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: make ff_ntp_time() accept a timestamp as input argumentJames Almer2020-01-15
| | | | | | Will be needed by the next patch. Signed-off-by: James Almer <jamrial@gmail.com>
* movenc: Write durations based on pts into mvhd/mdhd/tkhd/elstMartin Storsjö2020-01-10
| | | | | | | | | | | | | Keep all the existing data fields as they are (there's lots and lots of nontrivial calculation and heuristics based on them in their current form), but derive the duration as the difference between the pts of the first packet to the maximum pts+duration (not necessarily the last packet); use this duration in any box where the actual presentation duration is supposed to be. Fixes: 8420 Signed-off-by: Martin Storsjö <martin@martin.st>
* avformat: convert some avio_flush() calls to ↵Marton Balint2020-01-07
| | | | | | | | | | | | | | | | | avio_write_marker(AVIO_DATA_MARKER_FLUSH_POINT) Converting explicit avio_flush() calls helps us to buffer more data and avoid flushing the IO context too often which causes reduced IO throughput for non-streamed file output. The user can control FLUSH_POINT flushing behaviour using the -flush_packets option, the default typically means to flush unless a non-streamed file output is used, so this change should have no adverse effect on streaming even if it is assumed that after an avio_flush() the output buffer is clean so small seekbacks within the output buffer will work even when the IO context is not seekable. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: remove avio_flush() calls from the end of write_header functionsMarton Balint2020-01-07
| | | | | | | | | | | | | | To make it consistent with other muxers. The user can still control the generic flushing behaviour after write_header (same way as after packets) using the -flush_packets option, the default typically means to flush unless a non-streamed file output is used. Therefore this change should have no adverse effect on streaming, even if it is assumed that the first packet has a clean buffer, so small seekbacks within the output buffer work even when the IO context is not seekable. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/movenc: use iso6 major brand when signed CTS offsets are used in ↵James Almer2019-12-21
| | | | | | trun boxes Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: ensure we don't write the major brand as a compatible brand ↵James Almer2019-12-21
| | | | | | more than once Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: write the major brand also as the first compatible brandJames Almer2019-12-21
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/movenc: cosmeticsYuki Tsuchiya2019-12-12
| | | | | Signed-off-by: Yuki Tsuchiya <Yuki.Tsuchiya@sony.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/isom: support for demuxing and remuxing of MPEG-H 3D Audio in MP4Yuki Tsuchiya2019-12-12
| | | | | | | | | Implemented according to the specification at https://www.iso.org/standard/69561.html The 'mhm1' sample entry is registered with MP4RA, which is defined as MHAS encapsulated single stream MPEG-H 3D Audio. 'MHAS' stands for MPEG-H audio stream, which contains encoded audio data and corresponds metadata for decoding. This patch enables extracting the MHAS bitstream from MP4 and remuxing into MP4. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: Avoid allocation for small dynamic buffersAndreas Rheinhardt2019-11-28
| | | | | | | | By using avio_get_dyn_buf() + ffio_free_dyn_buf() instead of avio_close_dyn_buf() + av_free() one can avoid an allocation + copy for small dynamic buffers. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* aformat/movenc: add missing padding to output track extradataJames Almer2019-09-26
| | | | | | | Fixes ticket #8183. Tested-by: Thierry Foucu <tfoucu@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: Fix undefined shiftAndreas Rheinhardt2019-09-26
| | | | | | Fixes the movenc FATE-test. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: don't hardcode the colr box sizeJames Almer2019-09-19
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: add muxing support for Dolby TrueHD streamsJames Almer2019-08-24
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: use unspecified language by defaultMarton Balint2019-07-12
| | | | | | English was used before. Signed-off-by: Marton Balint <cus@passwd.hu>
* lavf/movenc: Pass correct pointer to av_log().Carl Eugen Hoyos2019-04-09
|
* lavf/movenc: fix tmcd writing for non-MP4/MOV modesGyan Doshi2019-04-03
| | | | | | | write_tmcd allows tmcd track to be created with any mode but in mov_write_header, index for first tmcd track is only set for modes MP4 or MOV, causing a crash if tmcd creation is attempted with other modes.
* avformat/movenc: Fix skip_trailer when global_sidx is enabledKarthick J2019-04-02
|
* avformat/movenc: free eac3 private data only when closing the streamJames Almer2019-03-31
| | | | | | | | | This makes sure the data is available when writing the moov atom during the second pass triggered by the faststart movflag. Fixes ticket #7780 Signed-off-by: James Almer <jamrial@gmail.com>
* libavformat/movenc: mov: added subtitle codec tags to codec tag listPaweł Wegner2019-03-18
| | | | | | | | This fixes avformat_query_codec incorrectly returning 0 for mov container and mov_text subtitles. Signed-off-by: Paweł Wegner <pawel.wegner95@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: Add more error checking when writing sample entries.Nikolas Bowe2019-02-07
| | | | | | | | | | Fixes a problem where a sample entry which cannot be written correctly appears to succeed, but produces an invalid file. For example, this command: ffmpeg -f lavfi -i sine=frequency=1000:duration=5 -codec:a ac3 -movflags +empty_moov -frag_duration 5000000 /tmp/foo.mp4 produced a file with the ac-3 sample entry, but no AC3SpecificBox (dac3) child, which is invalid according to ETSI TS 102 366. Reviewed-by: Baptiste Coudurier <baptiste.coudurier@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/movenc: Mention video_track_timescale as option to fix the timescale.Carl Eugen Hoyos2019-01-24
| | | | | Smarter improvements for this error message were suggested in the past but this is certainly an improvement.
* avformat/movenc: treat ALAC same as FLAC and write correct infoPaul B Mahol2018-12-14
| | | | Fixes #7291.
* avformat/movenc: Added an option to disable SIDX atomkjeyapal@akamai.com2018-12-11
|
* avformat/movenc: get number of written bytes from bitstream writerPaul B Mahol2018-11-22
| | | | Update fate test.
* avformat/movenc: fix size calculation in mov_write_eac3_tag()Paul B Mahol2018-11-22
| | | | Otherwise it would assert when flushing bits.
* avformat/movenc: Remove unneeded variable from mov_find_codec_tag()Michael Niedermayer2018-10-07
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/movenc: remove experimental checks for AV1 streamsJames Almer2018-09-09
| | | | | | The spec has been finalized. Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/movenc: Fail when codec tag is invalid for formatJohn Stebbins2018-09-08
| | | | | | Fixes ticket #6897 Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/movenc: Add GoPro metadata to permitted mp4 "codecs"John Stebbins2018-09-08
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: implicitly enable negative CTS offsets for ismvJan Ekström2018-08-24
| | | | | | | | | | | ISMV lacks any sort of edit list support, as well as tfxd is effectively the PTS of the fragment for most intents and purposes. Thus, if b-frames are requested without negative CTS offsets you end up with N frames' worth of delay (tfxd PTS plus the CTS offset of the first sample). Negative CTS offsets enable the first sample to have CTS=DTS, and thus a/v desync due to b-frame reorder delay is avoided.
* avformat/movenc: support Opus packets with more than 60ms of audio when ↵James Almer2018-08-24
| | | | | | | | | | writing the Sample Group Description Since libopus 1.2, packets of sizes 80ms, 100ms and 120ms are allowed. Fixes assertion failures when trying to mux such streams. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: update ff_isom_write_av1c() to the latest revision of the specJames Almer2018-08-17
| | | | | | | | | | This will get ISOBMFF and Matroska up to date with the revised AV1 Codec Configuration Box spec. For now keep propagating raw OBUs as extradata until all libavcodec modules are adapted to handle AV1CodecConfigurationRecord formatted extradata. Tested-by: Thomas Daede <bztdlinux@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: add support for AV1 streamsJames Almer2018-07-20
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: add reason for minf->hdlr in MOV onlyGyan Doshi2018-07-14
|
* avformat/movenc: Write version 2 of audio atom if channels is not knownMichael Niedermayer2018-07-09
| | | | | | | | | | | The version 1 needs the channel count and would divide by 0 Fixes: division by 0 Fixes: fpe_movenc.c_1108_1.ogg Fixes: fpe_movenc.c_1108_2.ogg Fixes: fpe_movenc.c_1108_3.wav Found-by: #CHEN HONGXU# <HCHEN017@e.ntu.edu.sg> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/movenc: Check input sample countMichael Niedermayer2018-07-08
| | | | | | | | | | | | | | Fixes: division by 0 Fixes: fpe_movenc.c_199_1.wav Fixes: fpe_movenc.c_199_2.wav Fixes: fpe_movenc.c_199_3.wav Fixes: fpe_movenc.c_199_4.wav Fixes: fpe_movenc.c_199_5.wav Fixes: fpe_movenc.c_199_6.wav Fixes: fpe_movenc.c_199_7.wav Found-by: #CHEN HONGXU# <HCHEN017@e.ntu.edu.sg> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/movenc: Use mov->fc consistently for av_log()Michael Niedermayer2018-06-28
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/movenc: Do not pass AVCodecParameters in avpriv_request_sampleMichael Niedermayer2018-06-28
| | | | | | | | Fixes: out of array read Fixes: ffmpeg_crash_8.avi Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan Caciulescu with AFLSmart Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/movenc: Check that frame_types other than ↵Michael Niedermayer2018-06-28
| | | | | | | | | | EAC3_FRAME_TYPE_INDEPENDENT have a supported substream id Fixes: out of array access Fixes: ffmpeg_bof_1.avi Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan Caciulescu with AFLSmart Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/movenc: allow hdlr name field to be emptyGyan Doshi2018-06-21
| | | | | | Both QTFF and the ISOBMFF standards allow it. Fixes #7262
* avformat/movenc: read track title from correct keyGyan Doshi2018-06-19
| | | | | | | | | | da9cc22d5bd allowed the MOV muxer to relay a custom stream handler name, whether populated from the input stream or user-set. However, the entry key didn't match the key set by the MOV demuxer, so it wasn't effective. Fixed. Due to the change, four FATE refs have to be updated. Verified that the target payload of the tests hasn't changed in terms of CRC.
* avformat/movenc: fix recognization of cover image streamsTimo Teräs2018-06-13
| | | | | | | | | | For chapter images, the mov demux produces streams with disposition set to attached_pic+timed_thumbnails. This patch fixes to properly recognize streams that should be encoded as cover image (ones with only and only attached_pic disposition set). Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>