Commit Graph

88 Commits

Author SHA1 Message Date
Nicolas Gaullier ed9363052f avformat/demux: add duration_probesize AVOption
Yet another probesize used to get the durations when
estimate_timings_from_pts is required. It is aimed at users interested
in better durations probing for itself, or because using
avformat_find_stream_info indirectly and requiring exact values: for
concatdec for example, especially if streamcopying above it.
The current code is a performance trade-off that can fail to get video
stream durations in a scenario with high bitrates and buffering for
files ending cleanly (as opposed to live captures): the physical gap
between the last video packet and the last audio packet is very high in
such a case.

Default behaviour is unchanged: 250k up to 250k << 6 (step by step).
Setting this new option has two effects:
- override the maximum probesize (currently 250k << 6)
- reduce the number of steps to 1 instead of 6, this is to avoid
detecting the audio "too early" and failing to reach a video packet.
Even if a single audio stream duration is found but not the other
audio/video stream durations, there will be a retry, so at the end the
full user-overriden probesize will be used as expected by the user.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2024-04-02 19:53:40 +02:00
Anton Khirnov 1e7d2007c3 all: use designated initializers for AVOption.unit
Makes it robust against adding fields before it, which will be useful in
following commits.

Majority of the patch generated by the following Coccinelle script:

@@
typedef AVOption;
identifier arr_name;
initializer list il;
initializer list[8] il1;
expression tail;
@@
AVOption arr_name[] = { il, { il1,
- tail
+ .unit = tail
}, ...  };

with some manual changes, as the script:
* has trouble with options defined inside macros
* sometimes does not handle options under an #else branch
* sometimes swallows whitespace
2024-02-14 14:53:41 +01:00
Anton Khirnov 85e075587d lavf: deprecate AVFMT_FLAG_SHORTEST
It was added in cb114ed464 with the comment
"This will allow fixing several bugs with the -shortest option".

Since
* there is no explanation of what these bugs are
* libavformat is not the place to work around ffmpeg CLI bugs
* there is no indication that this feature is actually in use
deprecate it without replacement.
2023-09-18 17:10:59 +02:00
Andreas Rheinhardt f6d14b1297 avformat/avformat: Add AVFMT_AVOID_NEG_TS_DISABLED
And also don't use explicit constants in the movenc test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-21 16:47:38 +01:00
Andreas Rheinhardt e8876bdcf3 avformat: Remove deprecated AVFMT_FLAG_MP4A_LATM flag, latm option
Deprecated in 67747c89ad.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:09 -03:00
Andreas Rheinhardt a3439de874 avformat: Remove remnants of side data merging
Deprecated in d682ae70b4,
ineffective since ca4df37f06.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:09 -03:00
Paul B Mahol d64cbd4fda remove CHAR_MIN/CHAR_MAX usage
It is not needed at all.
2020-03-17 22:46:36 +01:00
Michael Niedermayer 7d475c53c8 avformat/options_table: err_detect compliant and aggressive should also enable the weaker checks
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-31 18:43:50 +01:00
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