Commit Graph

80 Commits

Author SHA1 Message Date
Andriy Gelman 5e3229df4c avformat: Add max_probe_packets option
Allows user to set maximum number of buffered packets when
probing a codec. It was a hard-coded parameter before this commit.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-03 11:52:32 +01:00
Gyan Doshi 67747c89ad avformat: deprecate unused MP4A_LATM flag
A generic lavf flag for AAC LATM packetization for the RTP muxer was
added in ef409645f0 and then made inert 20 days later in 0832122880
when a private muxer option was added and the generic flag no longer
read.
2018-06-13 10:24:33 +05:30
Aman Gupta 2734f8d63a avformat: add skip_estimate_duration_from_pts
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>
2018-05-17 11:33:01 -07:00
Jun Zhao c6c20249e7 avformat/options_table: Change the seek2any location in opt table.
Change the seek2any location in avformat_options to make code more
readable.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-04-02 23:27:51 +02:00
James Almer d6d605eb05 avformat/mux: stop delaying writing the header
Every bitstream filter behaves as intended now, so there's no need to
wait for the first packet of every stream.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-12-06 15:43:59 -03:00
James Almer ca2b779423 avformat: remove use of deprecated AVFMT_FLAG_KEEP_SIDE_DATA flag
It has no effect whatsoever since the major bump.
Replace the flag's documentation to reflect this as well.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-10-29 00:09:52 -03:00
Marton Balint eeeb595c7f avformat: make flush_packets a tri-state and set it to -1 (auto) by default
If flushing is not disabled, then mux.c will signal the end of the packets with
an AVIO_DATA_MARKER_FLUSH_POINT, and aviobuf will be able to decide to flush or
not based on the preferred minimum packet size set by the used protocol.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Marton Balint <cus@passwd.hu>
2017-06-24 18:51:29 +02:00
wm4 d682ae70b4 avcodec, avformat: deprecate anything related to side data merging
This patch deprecates anything that has to do with merging/splitting
side data. Automatic side data merging (and splitting), as well as all
API symbols involved in it, are removed completely.

Two FF_API_ defines are dedicated to deprecating API symbols related to
this: FF_API_MERGE_SD_API removes av_packet_split/merge_side_data in
libavcodec, and FF_API_LAVF_KEEPSIDE_FLAG deprecates
AVFMT_FLAG_KEEP_SIDE_DATA in libavformat.

Since it was claimed that changing the default from merging side data to
not doing it is an ABI change, there are two additional FF_API_ defines,
which stop using the side data merging/splitting by default (and remove
any code in avformat/avcodec doing this): FF_API_MERGE_SD in libavcodec,
and FF_API_LAVF_MERGE_SD in libavformat.

It is very much intended that FF_API_MERGE_SD and FF_API_LAVF_MERGE_SD
are quickly defined to 0 in the next ABI bump, while the API symbols are
retained for a longer time for the sake of compatibility.
AVFMT_FLAG_KEEP_SIDE_DATA will (very much intentionally) do nothing for
most of the time it will still be defined. Keep in mind that no code
exists that actually tries to unset this flag for any reason, nor does
such code need to exist. Code setting this flag explicitly will work as
before. Thus it's ok for AVFMT_FLAG_KEEP_SIDE_DATA to do nothing once
side data merging has been removed from libavformat.

In order to avoid that anyone in the future does this incorrectly, here
is a small guide how to update the internal code on bumps:

- next ABI bump (probably soon):
  - define FF_API_LAVF_MERGE_SD to 0, and remove all code covered by it
  - define FF_API_MERGE_SD to 0, and remove all code covered by it
- next API bump (typically two years in the future or so):
  - define FF_API_LAVF_KEEPSIDE_FLAG to 0, and remove all code covered
    by it
  - define FF_API_MERGE_SD_API to 0, and remove all code covered by it

This forces anyone who actually wants packet side data to temporarily
use deprecated API to get it all. If you ask me, this is batshit fucked
up crazy, but it's how we roll. Making AVFMT_FLAG_KEEP_SIDE_DATA to be
set by default was rejected as an ABI change, so I'm going all the way
to get rid of this once and for all.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-21 06:13:45 +01:00
Michael Niedermayer 30581c51e7 avformat/options_table: Set the default maximum number of streams to 1000
Fixes CVE-2016-9561, Note the security relevance of this is disputed as
running out of memory can happen with valid files

Suggested-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-13 15:55:42 +01:00
Michael Niedermayer 1296f84495 avformat: Add max_streams option
This allows user apps to stop OOM due to excessive number of streams

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-08 18:25:30 +01:00
Rodger Combs 1f6d7eb470
lavf: add a flag to enable/disable automatic bitstream filtering
This is mostly useful for muxers that wrap other muxers, such as dashenc
and segment. The actual duplicated bitstream filtering is largely harmless,
but delaying the header can cause problems when the muxer intended the header
to be written to a separate file.
2016-09-12 21:50:32 -05:00
Michael Niedermayer cb114ed464 avformat/mux: implement AVFMT_FLAG_SHORTEST
This will allow fixing several bugs with the -shortest option

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-11 23:17:31 +02:00
Michael Niedermayer 11db7eee9b avformat/options_table: Add missing identifier for very strict compliance
Fixes Ticket5443

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-02 22:16:40 +02:00
Derek Buitenhuis 93629735d7 avformat: Add a protocol blacklisting API
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-03-04 16:13:42 +00:00
Moritz Barsnick 6eaad752c1 lavf/options_table: mark use_wallclock_as_timestamps as boolean
It is only used in a boolean context. Also clarify its documentation.

Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-18 15:24:31 +01:00
Michael Niedermayer 1dba8371d9 avformat: add protocol_whitelist
Note to maintainers: update tools

Note to maintainers: set a default whitelist for your protocol
If that makes no sense then consider to set "none" and thus require the user to specify a white-list
for sub-protocols to be opened

Note, testing and checking for missing changes is needed

Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-02 03:39:34 +01:00
Clément Bœsch 43ecec0f03 avformat: use AV_OPT_TYPE_BOOL in a bunch of places 2015-12-04 15:43:33 +01:00
James Almer 655b6dcb34 lavc/lavf: remove incompatible abi checks for the new 64bit fields
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-09-17 11:36:16 -03:00
Carl Eugen Hoyos b290972b8f lavf: Switch probesize and max_analyze_duration to 64bit.
Both are only accessible through AVOptions.
2015-09-15 18:02:51 +02:00
Carl Eugen Hoyos 670d8ecfae lavf: Remove probesize32 and max_analyze_duration32 on version bump.
Add FF_API_PROBESIZE_32 to allow removing 32bit probesize and 32bit
max_analyze_duration after the next libavformat version bump.
2015-09-01 09:19:49 +02:00
wm4 748d4816d9 avformat: add AVFMT_FLAG_FASTSEEK, use it for mp3
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-22 22:27:05 +02:00
Michael Niedermayer 66e49ff3b9 Merge commit '1384df641994bf3d6cb51084290aa94752737bae'
* commit '1384df641994bf3d6cb51084290aa94752737bae':
  lavf: Add an option for avoiding negative timestamps

Conflicts:
	libavformat/avformat.h
	libavformat/mux.c
	libavformat/options_table.h
	libavformat/version.h

See: 3ba0dab76a
See: a89c012531
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-07 23:09:30 +01:00
Michael Niedermayer 1384df6419 lavf: Add an option for avoiding negative timestamps
This is the same logic as is invoked on AVFMT_TS_NEGATIVE,
but which can be enabled manually, or can be enabled
in muxers which only need it in certain conditions.

Also allow using the same mechanism to force streams to start
at 0.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-07 12:11:35 +02:00
Michael Niedermayer 057ea2a982 avformat: Add format_whitelist
This allows restricting demuxers to a list of needed ones for improved security
Note, some demuxers themselfs open other demuxers, these are only restricted if
AVOptions are forwarded to them. Please check that your code does that.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-19 04:37:30 +02:00
Michael Niedermayer f0a6874de8 avformat: Allow choosing the dump format field separator.
The default is to maintain the previous ", " for now.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-09 00:56:58 +02:00
Michael Niedermayer c02ea58c5f avformat/options_table: add FF_COMPLIANCE_UNOFFICIAL
Fixes ticket 3959

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-05 21:43:17 +02:00
Michael Niedermayer 215db2935b Merge commit 'b263f8ffe7599d9cd27ec477a12700da8eb2790d'
* commit 'b263f8ffe7599d9cd27ec477a12700da8eb2790d':
  lavf: add AVFormatContext.max_ts_probe

Conflicts:
	doc/APIchanges
	libavformat/avformat.h
	libavformat/utils.c
	libavformat/version.h

lavf-fate/mp3 changes as the estimated input bitrate changes and that is
copied to the output

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-25 13:25:09 +02:00
Anton Khirnov b263f8ffe7 lavf: add AVFormatContext.max_ts_probe
It allows to configure how long will avformat_find_stream_info() wait
to get the first timestamp.
2014-08-25 05:17:54 +00:00
Carl Eugen Hoyos ff9a154157 Add int64_t probesize2 instead of int probesize to AVFormatContext.
Allows to set a probesize >2G.
Tested-by: Oliver Fromme
2014-07-30 11:09:25 +02:00
Michael Niedermayer e6aba1be4c avformat/options_table: Fix flush_packet flag flags
Found-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-28 21:24:15 +02:00
Carl Eugen Hoyos 5482780a3b Allow values >31bit for -analyzeduration. 2014-06-10 14:28:34 +02:00
Carl Eugen Hoyos d58bcc1921 Allow >2G for skip_initial_bytes. 2014-06-06 09:16:53 +02:00
Michael Niedermayer d858ee717b Merge commit '6d212599aa684f30511fb08ca30fe2378405304e'
* commit '6d212599aa684f30511fb08ca30fe2378405304e':
  avformat: Provide a standard compliance flag

Conflicts:
	doc/APIchanges
	libavformat/avformat.h
	libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-29 00:20:48 +02:00
Luca Barbato 6d212599aa avformat: Provide a standard compliance flag
Provide f_strict for avconv usage.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-05-28 22:04:56 +02:00
Michael Niedermayer 52887aa409 avformat: move default for max_analyze_duration into utils.c
this way we can do better tha a single fixed constant value

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-26 22:33:01 +02:00
Michael Niedermayer c37d179295 avformat: add format_probesize to allow tuning the maximum amount of bytes to identify the filetype
Currently probesize is cliped at 1mb before being used for format detection.
Alternatively this cliping could be removed but this would then tie various
things like stream analysis to the file detection.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-25 23:54:34 +02:00
Michael Niedermayer eacf7d650d Merge commit '0c1959b056f6ccaa2eee2c824352ba93c8e36d52'
* commit '0c1959b056f6ccaa2eee2c824352ba93c8e36d52':
  lavf: add AVFMT_FLAG_BITEXACT.

Conflicts:
	doc/APIchanges
	libavformat/avformat.h
	libavformat/flacenc.c
	libavformat/movenc.c
	libavformat/oggenc.c
	libavformat/options_table.h
	libavformat/version.h
	tests/fate/video.mak

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-15 19:16:57 +02:00
Anton Khirnov 0c1959b056 lavf: add AVFMT_FLAG_BITEXACT.
Use it instead of checking CODEC_FLAG_BITEXACT in the first stream's
codec context.

Using codec options inside lavf is fragile and can easily break when the
muxing codec context is not the encoding context.
2014-05-15 07:42:07 +02:00
Michael Niedermayer e94b08f002 avformat: add AV_EF_IGNORE_ERR
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-04 13:24:40 +02:00
Fred Rothganger 3f3229cd10 avformat: extracting NTP timestamp from RTCP
For muxing, it accepts
both 0 and AV_NOPTS_VALUE. For demuxing, it will present
AV_NOPTS_VALUE when start_time_realtime is unknown.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 13:33:14 +01:00
Michael Niedermayer a908de7f49 avformat/options_table: add named constants for avoid_negative_ts
Idea-by: ubitux
Reviewed-by: Timothy Gu <timothygu99@gmail.com>
Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-24 19:46:11 +01:00
Michael Niedermayer a89c012531 avformat/mux: support shifting timestamps so they start at 0
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-22 22:39:49 +01:00
Michael Niedermayer 3adb5f8d8b Merge commit 'd9ae1031f5edbd25c8526b4cb51aba66d3bee931'
* commit 'd9ae1031f5edbd25c8526b4cb51aba66d3bee931':
  lavf: improve handling of sparse streams when muxing

Conflicts:
	doc/APIchanges
	libavformat/avformat.h
	libavformat/mux.c
	libavformat/options_table.h
	libavformat/version.h

See: 37ed5df5c5
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-05 03:19:22 +01:00
Luca Barbato d9ae1031f5 lavf: improve handling of sparse streams when muxing
Currently ff_interleave_packet_per_dts() waits until it gets a frame for
each stream before outputting packets in interleaved order.

Sparse streams (i.e. streams with much fewer packets than the other
streams, like subtitles or audio with DTX) tend to add up latency and in
specific cases end up allocating a large amount of memory.

Emit the top packet from the packet_buffer if it has a time delta
larger than a specified threshold.

Original report of the issue and initial proposed solution by
mus.svz@gmail.com.

Bug-id: 31
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2014-02-04 22:01:42 +01:00
Stefano Sabatini 5871ee5072 lavf: add output_ts_offset option to AVFormatContext
This option can be generally useful to set an output offset, needed when
setting an absolute index in the output.
2014-02-02 13:16:17 +01:00
James Darnley 86bee7984e AVFormatContext: add metadata_header_padding field
This field is used to store the number of bytes that should be written
as padding to a metadata header of a file.  For example:
 - The FLAC format's METADATA_BLOCK_PADDING [1]
 - The ID3v2 tag format's padding           [2]

[1] http://xiph.org/flac/format.html#metadata_block_padding
[2] http://id3.org/id3v2.3.0#ID3v2_overview

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-24 22:33:21 +01:00
Michael Niedermayer 2ef1e62c8d correct the AVOption documentation for AV_EF_CAREFUL
The flag was and is intended to be a sane default and thus does not enable
time consuming checks. This also matches how the flag is used in decoders and
demuxers.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-27 20:03:08 +01:00
Michael Niedermayer 7703d19c40 lavf/options_table: improve option help text
Contains text suggested by carl

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-17 19:47:58 +02:00
Michael Niedermayer 96e6447d62 Merge commit '596e5d4783ca951258a7c580951fd161f1785ec1'
* commit '596e5d4783ca951258a7c580951fd161f1785ec1':
  lavf: Add a flag to enable/disable per-packet flushing

Conflicts:
	libavformat/avformat.h
	libavformat/mux.c
	libavformat/version.h

This adds a 2nd API to set per packet flushing
If the user application indicates through either a non default then this non default takes
precedence over the other still default value

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-17 12:01:35 +02:00
Luca Barbato 596e5d4783 lavf: Add a flag to enable/disable per-packet flushing
This is enabled by default and can be disabled with
"-fflags -flush_packets".

Inspired by a patch from Nicolas George <nicolas.george@normalesup.org>.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-09-16 22:11:08 +03:00