aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
Commit message (Collapse)AuthorAgeFilesLines
...
* avformat/utils: fix stream ordering for program ID stream specifiersMarton Balint2019-05-241-5/+11
| | | | | | Fixes a regression introduced in dbfd042983eed8586d4048795c00af820f5b6b1f. Signed-off-by: Marton Balint <cus@passwd.hu>
* Revert "lavf/utils: Allow url credentials to contain a slash."Marton Balint2019-05-181-4/+1
| | | | | | | | | | | | | | | | This reverts commit dd06f022b07438d650c82255dff16908ba04244a. Fixes ticket #7871 and reopens ticket #7816. The introduced regression caused URL's with @ in them to be parsed incorrectly which is a bigger issue then not being able to specify the slash character as a password. I think there are better ways to fix the original issue, like being able to specify HTTP username and password as a protocol option, or adding a protocol option to percent-decode the URL first. Signed-off-by: Marton Balint <cus@passwd.hu>
* libavformat: improve logs with cur_dtsAndreas Hakon2019-04-191-2/+2
| | | | | | | | | | | This patch improves the logs when the message "cur_dts is invalid" appears. If helps to identify which stream generates the trouble, and the status of the stream. A lot of users suffers with the message, and the origin varies. The improved message can help to discover the cause. Signed-off-by: Andreas Hakon <andreas.hakon@protonmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/utils: Allow url credentials to contain a slash.Carl Eugen Hoyos2019-04-191-1/+4
| | | | Fixes ticket #7816.
* lavf: Constify AVInputFormat pointer.Carl Eugen Hoyos2019-03-201-3/+3
|
* avformat/utils: fix indentationMarton Balint2019-03-011-118/+118
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: be even more strict about stream specifiersMarton Balint2019-03-011-11/+15
| | | | | | | | | After this change we always parse the full specifier even if we know the result in the middle of the parsing. Sligtly slower, but this is needed to consistently reject incorrect specifiers in both matching and non-matching cases. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: be more strict about stream specifiersMarton Balint2019-03-011-31/+51
| | | | | | | | | | | | This reworks the code to be more strict about accepting stream specifiers. From now on we strictly enforce the syntax in the documentation up until the decisive part of the stream specifier. Therefore matching stream specifiers always need to be correct, non matching specifiers only need to be correct until the decisive part. Also recursion is changed to a simple loop. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: parse some stream specifiers recursivelyMarton Balint2019-02-131-118/+55
| | | | | | | | This removes lots of code duplication and also allows more complex specifiers, for example you can use p:204:a:m:language:eng to select the English language audio stream from program 204. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: add support for reading ID3 tags at start of wavPaul B Mahol2018-12-131-1/+1
| | | | Fixes #4140.
* avformat/utils: Never store negative values in last_IP_durationMichael Niedermayer2018-10-181-2/+3
| | | | | | | | Fixes: integer overflow compute_pkt_fields() Fixes: compute_pkt_usan Reported-by: Thomas Guilbert <tguilbert@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Fix integer overflow in discontinuity checkMichael Niedermayer2018-10-181-1/+1
| | | | | | | | Fixes: signed integer overflow: 7738135736989908991 - -7954308516317364223 cannot be represented in type 'long' Fixes: find_stream_info_usan Reported-by: Thomas Guilbert <tguilbert@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Fix potential integer overflow in extract_extradata()Michael Niedermayer2018-10-071-1/+3
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Do not use "i" as a context pointer, "i" is normally the ↵Michael Niedermayer2018-10-071-21/+21
| | | | | | | | | integer counter in loops This avoids surprising developers. Its bad to surprise developers with such unexpected things. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Do not ignore failure in extract_extradata_init()Michael Niedermayer2018-10-071-6/+2
| | | | | | We check for the documented explanation of the "Ignore code" in extract_extradata_check() already Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: move mkdir_p to utilsSteven Liu2018-09-251-0/+34
| | | | | | | Because it will be used by avformat/segment.c or other module which need to automatically create sub-directories operation. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/utils: set AV_PKT_FLAG_KEY for data packetsBaptiste Coudurier2018-09-241-1/+1
|
* avformat/utils: Don't calculate duration using AV_NOPTS_VALUE for start_time.Dale Curtis2018-09-091-1/+1
| | | | | | Found by ClusterFuzz, https://crbug.com/879852 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: avoid undefined integer overflow behavior in ↵Fredrik Hubinette2018-08-221-1/+1
| | | | | | update_stream_timings() Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: correct fdebug loglevelGyan Doshi2018-08-141-2/+2
| | | | | fftools/cmdutils sets loglevel for fdebug to DEBUG but all fdebug output except for two were emitted at TRACE.
* avformat/utils: function to get the formatted ntp timeVishwanath Dixit2018-05-291-0/+22
| | | | | | | This utility function creates 64-bit NTP time format as per the RFC 5905. A simple explaination of 64-bit NTP time format is here http://www.beaglesoft.com/Manual/page53.htm
* avformat: add fields to AVProgram/AVStream for PMT change trackingAman Gupta2018-05-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | These fields will allow the mpegts demuxer to expose details about the PMT/program which created the AVProgram and its AVStreams. In mpegts, a PMT which advertises streams has a version number which can be incremented at any time. When the version changes, the pids which correspond to each of it's streams can also change. Since ffmpeg creates a new AVStream per pid by default, an API user needs the ability to (a) detect when the PMT changed, and (b) tell which AVStream were added to replace earlier streams. This has been a long-standing issue with ffmpeg's handling of mpegts streams with PMT changes, and I found two related patches in the wild that attempt to solve the same problem: The first is in MythTV's ffmpeg fork, where they added a void (*streams_changed)(void*); to AVFormatContext and call it from their fork of the mpegts demuxer whenever the PMT changes. The second was proposed by XBMC in https://ffmpeg.org/pipermail/ffmpeg-devel/2012-December/135036.html, where they created a new AVMEDIA_TYPE_DATA stream with id=0 and attempted to send packets to it whenever the PMT changed. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avformat: add skip_estimate_duration_from_ptsAman Gupta2018-05-171-0/+6
| | | | | | | | | | | | | | | | | | | For seekable mpegts streams, duration is calculated from pts by seeking to the end of the file for a pts and subtracting the initial pts to compute a duration. This can be expensive in terms of added latency during probe, especially when streaming over a network. This new option lets you skip the duration calculation, which is useful when you don't care about the value and want to save some overhead. This patch is particularly useful when dealing with live mpegts streams. Normally such streams are not seekable, so durations are not calculated. However in my case I am dealing with a seekable live mpegts stream (networked access to a .ts file which is still being appended to). Signed-off-by: Aman Gupta <aman@tmm1.net>
* avformat/utils: refactor upstream_stream_timingsAman Gupta2018-04-201-11/+10
| | | | | Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: ignore outlier durations on subtitle/data streams as wellAman Gupta2018-04-201-2/+12
| | | | | | | | | Similar to 4c9c4fe8b21, but for durations. This fixes #7151, where the report duration and bitrate on a mpegts stream is wildly off due to the dvb_teletext stream's timings. Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: use the existing packet reference when parsing complete framesJames Almer2018-04-131-3/+20
| | | | | | | | | | | | If the parser returns full frames, then the output pointer retured by av_parser_parse2() is guaranteed to point to data contained in the input packet's buffer. Create a new reference to said buffer in that case, to avoid unnecessary data copy when queueing the packet later in the function. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Check cur_dts in update_initial_timestamps() moreMichael Niedermayer2018-04-131-0/+1
| | | | | | | | | Fixes: runtime error: signed integer overflow: 18133149658382192 - -9223090561878065151 cannot be represented in type 'long long' Fixes: crbug 831552 Reported-by: Matt Wolenetz <wolenetz@google.com> Reviewed-by: Matt Wolenetz <wolenetz@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Fix integer overflow in end time calculation in ↵Michael Niedermayer2018-04-131-1/+1
| | | | | | | | | | update_stream_timings() Fixes: crbug 829153 Reported-by: Matt Wolenetz <wolenetz@google.com> Reviewed-by: Matt Wolenetz <wolenetz@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Stream specifier enhancement 2.Bela Bodecs2018-04-131-0/+28
| | | | | | | | | | | | | | | | | In some cases, mainly working with multiprogram mpeg-ts containers as input, it would be handy to select sub stream of a specific program by their metadata. This patch makes it possible to narrow the stream selection among streams of the specified program by stream metadata. Examples: p:601:m:language:hun will select all sub streams of program with id 601 where sub streams have metadata key named 'language' with value 'hun'. p:602:m:guide will select all sub streams of program with id 602 where sub streams have metadata key named 'guide'. Signed-off-by: Bela Bodecs <bodecsb@vivanet.hu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Stream specifier enhancementBela Bodecs2018-04-121-5/+60
| | | | | | | | | | | | | | | | | | | | Currently when specifying the program id you can only decide to select all stream of the specified program (e.g. p:103 will select all streams of program 103) or narrow the selection to a specific stream sub index (e.g. p:145:1 will select 2nd stream of program 145.) But you can not specify like all audio streams of program 145 or 3rd video stream of program 311. In some case, mainly working with multiprogram mpeg-ts containers as input, this feature would be handy. This patch makes it possible to narrow the stream selection among streams of the specified program by stream type and optionally its index. Handled types: a, v, s, d. Examples: p:601:a will select all audio streams of program 601, p:603:a:1 will select 2nd audio streams of program 603, p:604:v:0 will select first video stream of program 604. Signed-off-by: Bela Bodecs <bodecsb@vivanet.hu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: optimize ff_packet_list_free()James Almer2018-04-041-3/+6
| | | | | | Don't constantly overwrite the list's head pointer. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: make AVPacketList helper functions sharedJames Almer2018-04-041-24/+33
| | | | | | Based on a patch by Luca Barbato. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: use av_packet_make_refcounted to ensure packets are ref countedJames Almer2018-04-021-7/+3
| | | | | | Simplifies code, while also fixing a potential leak of side data in pkt. Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/utils.c: Don't compute start_time from DISCARD packets for video.Sasi Inguva2018-03-241-1/+3
| | | | | Signed-off-by: Sasi Inguva <isasi@isasi.mtv.corp.google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Fix integer overflow of fps_first/last_dtsMichael Niedermayer2018-03-071-1/+1
| | | | | | | Fixes: runtime error: signed integer overflow: 7738135736989908991 - -7898362169240453118 cannot be represented in type 'long' Fixes: Chromium bug 796778 Reported-by: Matt Wolenetz <wolenetz@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: simplify ff_alloc_extradata()James Almer2018-03-061-15/+11
| | | | | | | Cosmetic refactor Reviewed-by: 74a2fa708af88d225ed708af758f236f869b1a57 Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: free existing extradata before trying to allocate a new oneJames Almer2018-03-061-0/+1
| | | | | | | | This prevents leaks in the rare cases the function is called when extradata already exists. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: don't overwrite the return value of read_packet()James Almer2018-02-261-3/+3
| | | | | | | This only affected demuxers that didn't return reference counted packets. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* Add muxer/demuxer for raw codec2 and .c2 filesTomas Härdin2018-02-241-0/+1
|
* avformat: deprecate AVFormatContext filename fieldMarton Balint2018-01-281-0/+8
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: migrate to AVFormatContext->urlMarton Balint2018-01-281-1/+1
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: add url field to AVFormatContextMarton Balint2018-01-281-0/+14
| | | | | | | | | This will replace the 1024 character limited filename field. Compatiblity for output contexts are provided by copying filename field to URL if URL is unset and by providing an internal function for muxers to set both url and filename at once. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: add option to parse/store ID3 PRIV tags in metadata.Richard Shaffer2018-01-241-0/+2
| | | | | | | | | | | | | | Enables getting access to ID3 PRIV tags from the command-line or metadata API when demuxing. The PRIV owner is stored as the metadata key prepended with "id3v2_priv.", and the data is stored as the metadata value. As PRIV tags may contain arbitrary data, non-printable characters, including NULL bytes, are escaped as \xXX. Similarly, any metadata tags that begin with "id3v2_priv." are inserted as ID3 PRIV tags into the output (assuming the format supports ID3). \xXX sequences in the value are un-escaped to their byte value. Signed-off-by: wm4 <nfxjfg@googlemail.com>
* avformat: make avformat_network_init() explicitly optionalwm42018-01-161-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was sort of optional before - if you didn't call it, networking was initialized on demand, and an ugly warning was logged. Also, the doxygen comments threatened that it would be made strictly required one day. Make it explicitly optional. I would prefer to deprecate it fully, but there might still be legitimate reasons to use this. But the average user won't need it. This is needed only for two reasons: to initialize TLS libraries like OpenSSL and GnuTLS, and winsock. OpenSSL and GnuTLS were already silently initialized on demand if the global network init function was not called. They also have various thread-safety acrobatics, which make concurrent initialization within libavformat safe. In addition, the libraries are moving towards making their global init functions safe, which removes all need for central global init. In particular, GnuTLS 3.5.16 and OpenSSL 1.1.0g have been found to have safe init functions. In all cases, they use internal reference counters to avoid that the global uninit functions interfere with concurrent uses of the library by other API users who called global init. winsock should be thread-safe as well, and maintains an internal reference counter as well. Since we still support ancient TLS libraries, which do not have this fixed, and since it's unknown whether winsock and GnuTLS reinitialization is costly in any way, don't deprecate the libavformat functions yet.
* avformat: deprecate another ffserver API leftoverwm42018-01-161-0/+12
|
* avformat/hlsenc, utils: Moved is_http_proto from hlsenc to utils for re-useKarthick Jeyapal2017-12-291-0/+5
| | | | | Reviewed-by: Aman Gupta <aman@tmm1.net> Reviewed-by: Steven Liu <lq@onvideo.cn>
* lavc, lavf: move avformat static mutex from avcodec to avformatwm42017-12-261-0/+13
| | | | | | | | It's completely absurd that libavcodec would care about libavformat locking, but it was there because the lock manager was in libavcodec. This is more stright forward. Changes ABI, but we don't require ABI compatibility currently.
* avformat/utils: fix mixed declarations and codeJames Almer2017-11-241-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Prevent undefined shift with wrap_bits > 64.Dale Curtis2017-11-241-2/+3
| | | | | | | | | 2LL << (wrap_bits=64 - 1) does not fit in int64_t; change the code to use a uint64_t (2ULL) and add an av_assert2() to ensure wrap_bits <= 64. Signed-off-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: remove usage of AVCodecContext accessorsJames Almer2017-11-151-5/+9
| | | | Signed-off-by: James Almer <jamrial@gmail.com>