summaryrefslogtreecommitdiff
path: root/libavformat
Commit message (Collapse)AuthorAge
* libavformat/mov: fix multiple trun per trafJohn Stebbins2020-04-11
| | | | | | | | | dts would start over at the beginning of each trun when they should be computed contiguously for each trun in a traf Fixes ticket 8070 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* mov: fix seek to next root atom in fragmented mp4John Stebbins2020-04-11
| | | | | | | | | If some but not all moof's are referenced in an sidx, whole fragments were being skipped. Fixes tickets 7377, 7389, and 8502 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/oggparsevorbis: Use case-insensitive key compare for vorbis pictureMattias Wadman2020-04-11
| | | | | | | Regression since 8d3630c5402fdda2889fe4f74f7dcdd50ebca654 where keys were changed to not be touppered but the picture block strcmp was not changed to be case-insensitive. Fixes ticket #8608.
* libavformat/mov: restore use of mfra time as dtsJohn Stebbins2020-04-11
| | | | | | This was inadvertantly removed in 4a9d32baca Reviewed-by: Gyan Doshi <ffmpeg@gyani.pro>
* avcodec: add MV30 decoderPaul B Mahol2020-04-10
|
* avformat/hlsenc: return media_url directly if failed to get seperatorLimin Wang2020-04-10
| | | | | Fix ticket: 8606 Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/matroskaenc: Remove unnecessary headersAndreas Rheinhardt2020-04-10
| | | | | | | | | | | | subtitles.h has been included in order to use ff_subtitles_next_line() to help parsing srt subtitles which at that time had their timing as part of the payload and not as part of the AVPacket fields. When this changed (in 55180b32) it has been forgotten to remove this header. libavcodec/internal.h meanwhile has been added in bb47aa5850c and has never been used at all. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mpeg: Don't use unintialized valueAndreas Rheinhardt2020-04-09
| | | | | | | | vobsub_read_packet() didn't check whether an array of AVPackets was valid and therefore used uninitialized values. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/segment: always use interleaved writes for formats with custom ↵Marton Balint2020-04-08
| | | | | | interleaving Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/hlsenc: use av_asprintf()Limin Wang2020-04-08
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: Factor out deleting files from deleting segmentsAndreas Rheinhardt2020-04-08
| | | | | | Removes code duplication. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat: add subtitle support in master playlist m3u8Limin Wang2020-04-08
| | | | | | | | | | | | | | | | | | | | | | | | | Test with the following command for the webvtt subtitle: $ ./ffmpeg -y -i input_with_subtitle.mkv \ -b:v:0 5250k -c:v h264 -pix_fmt yuv420p -profile:v main -level 4.1 \ -b:a:0 256k \ -c:s webvtt -c:a mp2 -ar 48000 -ac 2 -map 0:v -map 0:a:0 -map 0:s:0 \ -f hls -var_stream_map "v:0,a:0,s:0,sgroup:subtitle" \ -master_pl_name master.m3u8 -t 300 -hls_time 10 -hls_init_time 4 -hls_list_size \ 10 -master_pl_publish_rate 10 -hls_flags \ delete_segments+discont_start+split_by_time ./tmp/video.m3u8 Check the master m3u8: $ cat tmp/master.m3u8 #EXTM3U #EXT-X-VERSION:3 #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subtitle",NAME="subtitle_0",DEFAULT=YES,URI="video_vtt.m3u8" #EXT-X-STREAM-INF:BANDWIDTH=6056600,RESOLUTION=1280x720,CODECS="avc1.4d4829,mp4a.40.33",SUBTITLES="subtitle" video.m3u8 Check the result by convert to mkv: $ ./ffmpeg -strict experimental -i ./tmp/master.m3u8 -c:v copy -c:a mp2 -c:s srt ./test.mkv Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsplaylist: simplify code for checking whether the string is emptyLimin Wang2020-04-08
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: remove the first slash of the relative path line in the ↵Limin Wang2020-04-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | master m3u8 file Please testing with the following command: ./ffmpeg -y -i input.mkv \ -b:v:0 5250k -c:v h264 -pix_fmt yuv420p -profile:v main -level 4.1 \ -b:a:0 256k \ -c:a mp2 -ar 48000 -ac 2 -map 0:v -map 0:a:0\ -f hls -var_stream_map "v:0,a:0" \ -master_pl_name master.m3u8 -t 300 -hls_time 10 -hls_init_time 4 -hls_list_size \ 10 -master_pl_publish_rate 10 -hls_flags \ delete_segments+discont_start+split_by_time ./tmp/video.m3u8 then cat ./tmp/master.m3u8 before: #EXTM3U #EXT-X-VERSION:3 #EXT-X-STREAM-INF:BANDWIDTH=6056600,RESOLUTION=1280x720,CODECS="avc1.4d4829,mp4a.40.33" /video.m3u8 $ ./ffmpeg -i ./tmp/master.m3u8 -c:v copy -c:a mp2 ./test.mkv [hls @ 0x7f82f9000000] Skip ('#EXT-X-VERSION:3') [hls @ 0x7f82f9000000] Opening '/video.m3u8' for reading [hls @ 0x7f82f9000000] parse_playlist error No such file or directory [/video.m3u8] ./tmp/master.m3u8: No such file or directory after: #EXTM3U #EXT-X-VERSION:3 #EXT-X-STREAM-INF:BANDWIDTH=6056600,RESOLUTION=1280x720,CODECS="avc1.4d4829,mp4a.40.33" video.m3u8 Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: Use AVBPrint to avoid allocations of stringsAndreas Rheinhardt2020-04-08
| | | | | | when deleting old segments. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: Fix memleak when deleting old segmentsAndreas Rheinhardt2020-04-08
| | | | | | | | | | | if the directory name of the segments contains "%v". This memleak is caused by masking the pointer that will eventually be freed by a variable of the same name in a smaller scope. Therefore the pointer that gets freed is always NULL when it is freed and the allocated data leaks. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: CosmeticsAndreas Rheinhardt2020-04-08
| | | | | | | | | | This is mainly about improving legibility of the code and getting rid of overlong lines by using variables for st->codecpar instead of accessing the codecparameters via st->codecpar->. Also, some code has been moved to better fitting places. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Remove unused structureAndreas Rheinhardt2020-04-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Only store what is needed laterAndreas Rheinhardt2020-04-08
| | | | | | | | This commit removes data that is only used during smacker_read_header() from the demuxer's context and replaces the data that is used by local variables. The other data is completely dropped. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Create audio streams immediatelyAndreas Rheinhardt2020-04-08
| | | | | | | | | | | | | | | | | | | The Smacker demuxer currently parses several fields that indicate how many audio streams a file contains. This data is parsed and stored into arrays in the demuxer's context and although the data is used only to initialize the audio streams, it is kept for the whole lifetime of the demuxer. This has been changed: The data is used directly to create the audio streams and no longer kept at all. This also simplifies error handling in case adding a new stream fails: Several arrays which until now have been allocated between parsing the data determining how many audio streams to create and actually creating them would need to be freed in this case. Now the streams are created first, so freeing is no longer an issue. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Read extradata directly into extradataAndreas Rheinhardt2020-04-08
| | | | | | | | | | | | | | | | | | | | | The Smacker demuxer reads four consecutive 32bit values from the file header into its demux context (as four uint32_t), converting it to native endianness in the process and then writing these four values later (after extradata has been allocated) to extradata as four 32bit values (converting to little endian in the process). This commit changes this: The stream and the extradata are allocated earlier, so that the data destined for extradata can be read directly into extradata. Furthermore, given that these values are not needed for demuxing itself they are now no longer kept as part of the demuxing context. Finally, a check regarding the number of frames has been moved up, too, in order to exit early before unnecessarily allocating the stream and the extradata. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/ilbc: Add missing #if for muxerMichael Niedermayer2020-04-07
| | | | | | | | Fixes: building without muxers Fixes: 21594 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/webmdashenc: Use AVCodecDescriptors for codec namesAndreas Rheinhardt2020-04-07
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/webmdashenc: Check codec typesAndreas Rheinhardt2020-04-07
| | | | | | | | | | | | | The WebM DASH Manifest muxer only supports VP8, VP9, Vorbis and Opus, but there was no check for this. The codec type is used to get a pointer to a string containing the codec name or NULL if it is not one of those four codecs. Said pointer has then been used without further checks as string for the %s conversion specifier in an avio_printf()) call which is undefined behaviour. This commit adds a check for the supported codec types. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* mov: Support fake moov boxes disguised as hoovVittorio Giovara2020-04-07
| | | | | | | | | | | | | | Some broken apps generate files that have a fake box named 'hoov' instead of a proper 'moov' one. This is speculation but it seems like this box contains data to be modified later (eg as file grows in size, data gets re-written) and its name is supposed to be changed to 'moov' once it can be used as a 'moov', but for some reason this step is skipped. Since this is not the first time this happens ('moov' boxes can be found in 'free' ones) extend the existing hacks to search for the moov in such boxes and skip the moov_retry since it needs to be found right away. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* lavf/chromaprint: Silence compilation warningsCarl Eugen Hoyos2020-04-05
| | | | | | | Fixes the following warnings: libavformat/chromaprint.c:117:42: warning: passing argument 2 of ‘chromaprint_feed’ from incompatible pointer type libavformat/chromaprint.c:132:52: warning: passing argument 2 of ‘chromaprint_get_raw_fingerprint’ from incompatible pointer type libavformat/chromaprint.c:143:71: warning: passing argument 4 of ‘chromaprint_encode_fingerprint’ from incompatible pointer type
* avformat/avidec: Fix memleak with embedded GAB2 subtitlesAndreas Rheinhardt2020-04-05
| | | | | | | | | | | | | The code for GAB2 subtitles predates refcounting AVPackets. So in order to transfer the ownership of a packet's data pkt->data was simply stored and the packet zeroed; in the end (i.e. in the read_close-function) this data was then simply freed with av_freep(). This of course leads to a leak of an AVBufferRef and an AVBuffer. It has been fixed by keeping and eventually unreferencing the packet's buf instead. Additionally, the packet is now reset via av_packet_unref(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/avidec: Fix memleak when allocating DVDemuxContext failsAndreas Rheinhardt2020-04-05
| | | | | | | | | An AVIStream (intended to be used as private data for an AVStream) would leak in this scenario. Also return a more fitting error code instead of AVERROR_INVALIDDATA. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/avidec: Fix memleak when DV demuxer is disabledAndreas Rheinhardt2020-04-05
| | | | | | | | | | | | | | If one uses a build without dv demuxer, an AVIStream struct that is destined to be used as private data for an AVStream by the avi demuxer would leak, because it has been moved from the AVStream (that is going to be freed) and only stored in a local variable (in order to be used for another AVStream), but if the dv demuxer is disabled, the earlier code returned immediately instead. Also return a better error code in this scenario (instead of AVERROR_INVALIDDATA). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/avidec: Don't reimplement ff_free_stream()Andreas Rheinhardt2020-04-05
| | | | | | | | | | Using ff_free_stream() makes the code more readable, more future-proof (the old code freed AVCodecContexts and AVCodecParameters and its substructures manually, so that there is a chance that there would be a memleak for some time if new substructures were added) and reduces code size. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* Revert "avformat/rtp: Pass sources and block filter addresses via sdp file ↵Carl Eugen Hoyos2020-04-05
| | | | | | | | | | for rtp" This reverts commit b71685865fe761925feedda3cd0b288224d9a509. The commit lead to the use of an uninitialized variable. Other issues were listed by Andreas Rheinhardt: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259150.html
* avformat/avisynth: fix deprecation warningStephen Hutchinson2020-04-05
|
* avformat/avisynth: switch to AviSynth+ on LinuxStephen Hutchinson2020-04-05
| | | | | | | | | | AviSynth+ now supports non-Windows OSes, making AvxSynth obsolete. Since we no longer support AviSynth 2.5 (which is essentially what AvxSynth is), remove AvxSynth support and replace it with AviSynth+. As a result, the USING_AVISYNTH defines can be switched back to generic _WIN32.
* lavf, lavfi: Remove uses of sizeof(char).Carl Eugen Hoyos2020-04-04
| | | | The C standard requires sizeof(char) == 1.
* avformat/mpegts: use buffer pools for allocating PES payloadsMarton Balint2020-04-04
| | | | | | | | | | | | | | | | | | | | | This brings a performance improvement when demuxing files, most of the improvement comes from buffer pooling unbound packets. time ffprobe -i samples/ffmpeg-bugs/trac/ticket6132/Samsung_HDR_-_Chasing_the_Light.ts -show_packets >/dev/null 2>&1 Before: real 0m1.967s user 0m1.471s sys 0m0.493s After: real 0m1.497s user 0m1.364s sys 0m0.129s Based on a patch of James Almer. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mov: Discard last STSC if its emptyMichael Niedermayer2020-04-04
| | | | Fixes: Ticket8508
* avformat/matroska: clean the structure formattingSteve Lhomme2020-04-03
| | | | | | Always use a comma at the end, order elements by value. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dss: Remove unnecessary allocationAndreas Rheinhardt2020-04-03
| | | | | | | | | Put a buffer with a known fixed size into the demuxer's context instead of allocating it separately. This also allows to remove the demuxer's read_close()-function. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/ilbc: Don't reimplement ff_raw_write_packetAndreas Rheinhardt2020-04-03
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/matroskaenc: Improve BlockAdditionsAndreas Rheinhardt2020-04-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | 8ffcc826 added support for muxing BlockAdditions with BlockAddID equal to one. The restriction to BlockAddID == 1 probably resulted from a limitation to what was needed; yet over time this led to three occurences of "(side_data_size && additional_id == 1)". This commit changes this by setting side_data_size to 0 if additional_id != 1. It also stops hardcoding 1 for the value of BlockAddID to write; but it still upholds the requirement that it is 1. See below. Despite BlockAddId actually having a default value of 1, it is still written, because until very recently (namely dbc50f8a) our demuxer used a wrong default value of 0. Furthermore, use put_ebml_binary() to write the BlockAdditional element. (The Matroska specifications have evolved and now the BlockAddID 1 is reserved for the codec (as described in the codec's codec mapping), BlockMore elements with BlockAddID > 1 are now of a more codec-independent nature and require a BlockAdditionalMapping in the track's TrackEntry. Given that this muxer does not support writing said BlockAdditionalMapping yet (actually, none have been defined yet), we have to uphold the requirement that BlockAddID == 1.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/matroskaenc: Improve checks for updating TagsAndreas Rheinhardt2020-04-03
| | | | | | | | | | When updating the Tags at the end, the Matroska muxer would twice check for whether (!mkv->is_live) is true, despite this code being only executed if it is. Furthermore, a loop iterates over all the streams even when there is no Tags element to update at all, because the check for whether there are Tags is only performed later. This commit fixes this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/matroskaenc: Remove unnecessary avio_tell(), avio_seek()Andreas Rheinhardt2020-04-03
| | | | | | | | | | | | | | | | | | | | avio_close_dyn_buf() has a bug: When the write pointer does not point to the end of the written data when calling it (i.e. when one has performed a seek back to update already written data), it would not add padding to the end of the buffer, but to the current position, overwriting other data; furthermore the reported size would be wrong (off by the amount of data it has overwritten with padding). In order not to run into this when updating already written elements or elements for which size has only been reserved, the Matroska muxer would first record the current position of the dynamic buffer, then seek to the desired position, perform the update and seek back to the earlier position. But now that end_ebml_master_crc32() does not make use of avio_close_dyn_buf() any more, this is no longer necessary. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/matroskaenc: Stop reallocating of Cluster bufferAndreas Rheinhardt2020-04-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Matroska muxer uses a dynamic buffer to buffer the content of Clusters before eventually writing them. Up until now, each time a Cluster was written, the dynamic buffer was closed, i.e. freed; now it is only reset, saving allocations of the AVIOContext itself, its opaque as well as most of the reallocations of the buffer. This is advantageous performance-wise, in particular on systems where reallocations are slow (namely Windows). The following table shows the decicyles for writing a frame on Linux (Ubuntu 19.10) and Windows (7) on an x64 Haswell (to /dev/null on Linux, to stdout which is discarded on Windows (the default values of the size and duration of clusters for seekable output have been explicitly set in this case); in all tests, writing CRC-32 values has been disabled in all tests; calls to the muxer's write_packet function in write_packet() in libavformat/mux.c have been timed; each of the following tests has been repeated 50 times): | Windows before | Windows after | Linux before | Linux after _________________________________________________________________ A | 979437 | 192304 | 259500 | 183320 B | 715936 | 155648 | 152786 | 130879 C | 265115 | 56034 | 78496 | 53243 D | 386224 | 80307 | 128894 | 75354 E | 21732 | 10695 | 11320 | 9801 (A is a 10.2 mb/s file with a GOP length of 2s, amounting to an average Cluster size of about 2.5 MiB; the average Cluster size of B is 1.1 MiB; for C it is 2.35 MiB, for D it is 0.46 MiB; for E - a file with just a single audio track of 158kb/s resulting in a Cluster size of about 100 kB, the relative gains were the smallest, probably because of the small Cluster size.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* libavformat/amr.c: Check return value from avio_read()John Rummell2020-04-03
| | | | | | | | If the buffer doesn't contain enough bytes when reading a stream, fail rather than continuing on with initialized data. Caught by Chromium fuzzeras (crbug.com/1065731). Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/hnm: Only keep and parse what is needed laterAndreas Rheinhardt2020-04-02
| | | | | | | | | | | | | | | | The hnm demuxer's context struct contained lots of fields that are write-only variables or that are not used outside of parsing the header and that can therefore be replaced by local variables of hnm_read_header(). This commit removes all of these from the context; the second type has been replaced by local variables. An AVPacket (that was initialized when reading the header and for which dead code to unreference it existed in hnm_read_close()) is among the removed things. Removing it allowed to remove hnm_read_close() altogether and also removes another instance of usage of sizeof(AVPacket). Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/matroskaenc: Don't implicitly mark WebVTT in WebM as EnglishAndreas Rheinhardt2020-04-02
| | | | | | | | | | | | | | | | | | | | Writing the language of WebVTT in WebM proceeded differently than the language of all other tracks: In case no language was given, it does not write anything instead of "und" (for undefined). Because the default value of the Language element in WebM (that inherited it from Matroska) is "eng" (for English), any such track will actually be flagged as English. Doing it this way goes back to commit 509642b4 (the commit adding support for WebVTT) and no reason for this has been given in the commit message or in the discussion about this patch on the mailing list; the best I can think of is this: the WebM wiki contains "The srclang attribute is stored as the Language sub-element." Someone unfamiliar with default values in Matroska/WebM could interpret this as meaning that no Language element should be written if the language is unknown. And this is wrong and this commit changes it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/matroskaenc: Reindent after previous commitAndreas Rheinhardt2020-04-02
| | | | | | Also remove { } after an if if there is only one statement inside { }. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/matroskaenc: Combine checks for audioAndreas Rheinhardt2020-04-02
| | | | | | | | | mkv_write_track() currently has three places where it checks for whether the current codec type is audio: One in a switch and two outside of it. These checks can be combined by moving the code after the other two checks inside the audio-related part of the switch. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/matroskaenc: Simplify writing Void elementsAndreas Rheinhardt2020-04-02
| | | | | | | | | | | | | | | | | | | Reserving space in Matroska works by writing a Void element. And until now this worked as follows: The current position was recorded and the EBML ID as well as the length field written; then the new position was recorded to know how much more to write. Afterwards the actual writing has been performed via ffio_fill(). But it is unnecessary to explicitly use the positions (obtained via avio_tell()) to find out how much still needs to be written, because the length of the ID and the length field are known. So rewrite the function to no longer use them. Also, given that ffio_fill() uses an int parameter and given that no current caller (and no sane future caller) will want to reserve several GB of space, make the size parameter of put_ebml_void() itself an int. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/matroskaenc: Avoid seek when writing Cues at the frontAndreas Rheinhardt2020-04-02
| | | | | | | | | | When the Cues are written in front of the Cluster, the muxer would seek to the beginning (to where the Cues ought to be written) and write the Cues; afterwards it would seek back to the end of the file only to seek to the beginning once again to update several elements there. This commit removes the seek to the end. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>