aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* avformat/utils: Look at the first 3 frames if timestamps indicate frame ↵Michael Niedermayer2017-11-111-4/+12
| | | | | | | | reorder but decoder delay does not Fixes: Ticket6487 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: preserve AV_PKT_FLAG_DISCARD in parse_packetJohn Stebbins2017-11-111-0/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* aptx: add raw muxer and demuxer for aptXAurelien Jacobs2017-11-101-0/+1
|
* avformat: move priv_pts from AVStream to an internal structJames Almer2017-11-071-3/+3
| | | | | | | It has no reason to be in a public header, even if defined as private. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: deprecate getters and setters for AVFormatContext and AVStream fieldsJames Almer2017-10-291-0/+4
| | | | | | | The fields can be accessed directly, so these are not needed anymore. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* Merge commit '9e4a5eb51b9f3b2bff0ef08e0074b7fe4893075d'James Almer2017-10-281-6/+1
|\ | | | | | | | | | | | | * commit '9e4a5eb51b9f3b2bff0ef08e0074b7fe4893075d': avformat: Free the internal codec context at the end Merged-by: James Almer <jamrial@gmail.com>
| * avformat: Free the internal codec context at the endLuca Barbato2017-04-131-5/+1
| | | | | | | | | | | | Avoid a use after free in avformat_find_stream_info. CC: libav-stable@libav.org
| * utils: Add av_stream_add_side_data()James Almer2016-11-231-10/+27
| | | | | | | | | | | | | | | | Functionally similar to av_packet_add_side_data(). Allows the use of an already allocated buffer as stream side data. Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>