Commit graph

26414 commits

Author SHA1 Message Date
James Almer
b6c2498a59 avformat/takdec.c: return proper error codes for avio_read() failures
Suggested-by: Nicolas George <george@nsup.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-21 14:08:23 -03:00
Thierry Foucu
1d244c641b libavformat/takdec.c: Fix msan error
Make sure we are reading 16 bytes for the MD5

Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-21 14:08:23 -03:00
softworkz
02d7384ed5 avformat/dump: Print stream start offsets for input streams
Seeing the offset of video and audio streams to each other is often
a useful metric in diagnosing and understanding issues with playback
or transcoding.
This commit adds those offsets to the stream info print.

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-04-19 17:05:30 +02:00
softworkz
fcc50c41ce avformat/hls demuxer: Add WebVTT subtitle support
This add support for WebVTT subtitles in HLS streams.
Just like for separate audio streams, it supports all available
WebVTT streams in all renditions.
No new options are added, it just works and provides subtitles streams
like any other demuxer.
The code prevents downloading subtitle segments which are farther
in the future than the main segments, to avoid loading hundreds
of subtitle segments in advance.

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-04-19 17:02:24 +02:00
Michael Niedermayer
058d49b168
Revert "lavf/id3v2dec: support multiple values and TIPL frames"
see: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that decode_str() did advance

but in short, first our API since 16years says we dont have multiple values per key
(which it supports since 9 years only)

and it causes some problems for ffprobe apparently.
I do believe the original patch is the correct direction but it requires
more changes. So revert this until other things are in place and until
we have a consensus.

This reverts commit 80b77e8e8d.
2025-04-16 13:09:05 +02:00
Jack Lau via ffmpeg-devel
cf7dfddee4
avformat/rtpdec_mpeg4: add need_parsing for rtsp AAC
fix ticket #11531

the rtsp aac did not marked keyframe which cannot easy copy to output.
because f265f9c9d0 commit change the AAC props to match xHE-AAC.
in some formats like MOV, need_parsing is set, so AAC can be still parsed be keyframe
but rtsp did not, so this patch add it

Signed-off-by: Jack Lau <jacklau1222@qq.com>
Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-16 13:09:04 +02:00
Michael Niedermayer
1946b7875c
avformat/id3v2: Print the unknown encoding
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-16 13:09:03 +02:00
Arthur Grillo
2fedb29780
avformat/fifo: Check for keyframe video type before stop dropping
The current behavior when using restart_with_keyframe is that it will
recover if it also encounters any audio packet, as they are flagged as a
keyframe.

The expectation is that packets are dropped until the next _video_
keyframe.

To fix that, check if exists a video stream, if it exists check the
packet stream codec type, only letting it recover when it is a video
one. If there is no video stream, resume to the original behavior, not
checking the codec type.

Fixes ticket: #11467

Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-16 13:09:02 +02:00
Felicia Lim
2229b74127 avformat/movenc: fix setting elst/stss for IAMF with Opus 2025-04-14 17:25:39 -03:00
Felicia Lim
d36883f119 avformat/iamf_writer: fix setting skip_samples and discard_padding for OPUS 2025-04-14 17:25:34 -03:00
Andreas Rheinhardt
66310f8a22 avformat/asf_tags: Deduplicate tags
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-13 22:49:21 +02:00
rcombs
80b77e8e8d
lavf/id3v2dec: support multiple values and TIPL frames
Fixes https://trac.ffmpeg.org/ticket/6949

Ordinary text frames in ID3v2 are allowed to have multiple
(null-separated) values. This technically isn't allowed in TXXX,
but it's used in practice by Picard, and supporting it is harmless.

TIPL/IPL (Involved People List) and TMCL (Musician Credits List) work
similarly to TXXX, but alternate key-value-key-value.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-07 01:02:42 +02:00
rcombs
172e7ca668
lavf/metadata: support duplicate keys in ff_metadata_conv
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-07 01:02:41 +02:00
Chris Hodges
68b105341c avformat: Fix AV1 RTP wrong log condition
Fixed warning about OBU count being wrong, which can only be
determined when the number of OBUs in the header is non-zero,
not the other way round.

Signed-off-by: Chris Hodges <chris.hodges@axis.com>
2025-04-03 16:08:41 +02:00
Andreas Rheinhardt
35c091f4b7 avformat/rtpenc: Check dimensions during init
Also fixes a -Wdeclaration-after-statement warning.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-31 08:04:05 +02:00
Koushik Dutta
2657e1679e
avformat/rtpenc: Add flag AVFMT_NODIMENSIONS.
Not all rtp formats require the video dimensions to be available
up front. H264 and HEVC will send them as stream parameters.
The flag is restrictive and prevents RTP repacketization
without parsing the codec information out of the stream.

This change checks to see if the codec parameters are available
on the rtp formats that need it.

Signed-off-by: Koushik Dutta <koushd@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-29 22:49:57 +01:00
James Almer
b338d1b35b libs: bump major version for all libraries
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:44:34 -03:00
Andreas Rheinhardt
c389d9ac78 avutil/dict: Unavpriv avpriv_dict_set_timestamp()
And move it to lavf, its only user.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:08 -03:00
James Almer
ef8bf6ca24 avformat/version_major: postpone some deprecations until the next bump
They are either too recent, or are not trivial to remove.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
James Almer
b2564b0ab8 avformat: remove deprecated FF_API_GET_DUR_ESTIMATE_METHOD
Deprecated since 2024-03-06.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
James Almer
ec8e796b42 avformat: remove deprecated FF_API_AVSTREAM_SIDE_DATA
Deprecated since 2023-10-06.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
James Almer
c153238275 avformat: remove deprecated FF_API_ALLOW_FLUSH
Deprecated since 2023-10-02.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
James Almer
3fd10e0cf3 avformat: remove deprecated FF_API_LAVF_SHORTEST
Deprecated since 2023-09-18.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
James Almer
7d07723db5 avcodec: remove deprecated FF_API_TICKS_PER_FRAME
Deprecated since 2023-05-15.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
Michael Niedermayer
5bf6d9c3e3
avformat/nut: Add GBR(A)PF16/32LE/BE
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-28 15:23:28 +01:00
James Almer
08e334e462 avformat/movenccenc: add support for CENC AV1 encryption
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-25 20:59:18 -03:00
Zhao Zhili
1731eba20d avformat/mov: generalize sgpd_sync index lookup
The function has a nal_unit_type parameter but unused before.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-24 14:53:41 +08:00
Andreas Rheinhardt
c94143350f avutil/libm: Only include intfloat.h when needed
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-22 03:35:28 +01:00
Jack Lau
1502551dd3 avformat/hlsenc: fix CODECS Attribute hard code in hevc EXT-X-STREAM-INF
fix ticket: 10786

parse the SPS from extradata and
get profile_compatibility, tier, constraints which was been hard code before.
HEVC CODECS Attribute reference to: ISO/IEC14496-15

Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2025-03-19 19:20:50 +08:00
softworkz
e0aedeb72e
avformat/webvttdec: Add webvtt extension and MIME type
The webvtt extension is sometimes used in HLS playlists.

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-14 02:03:59 +01:00
Andreas Rheinhardt
a6c58450da all: Fix doxy comments wrongly designated as trailing ///<
The ///< or /**< form of doxygen comments are only to be used
when the documentation follows the member and the comment
block starts on the same line as the member. This commit
fixes wrong uses of them; in particular, this fixes the comment
for mb_height in H.264 SPS's structure which was wrongly added
to mb_width.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-12 17:00:24 +01:00
Zhao Zhili
0f7d77fc42 avformat/flvdec: Use appropriate error code
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:07:20 +08:00
Zhao Zhili
fa5a100ed2 avformat/flvdec: Fix error handling of parse_video_color_info
Some error should not be ignored.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:07:09 +08:00
Zhao Zhili
291fdc96ab avformat/flvdec: Use float for FLVMasteringMeta
The precision should be enough for primaries and luminance.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:04:00 +08:00
Zhao Zhili
888f5ea72b avformat/flvdec: Use appropriate types in FLVMetaVideoColor
This also reduce memory usage.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:03:56 +08:00
Zhao Zhili
f0cf122cf4 avformat/flvdec: Remove one level of indentation
Also remove the condition of AMF_DATA_TYPE_BOOL when parse color
info. There is no AMF_DATA_TYPE_BOOL type in color info.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:03:38 +08:00
Zhao Zhili
4f53ecf114 avformat/flvdec: Put FLVMetaVideoColor inside FLVContext directly
1. Rename metaVideoColor to meta_color_info
2. Allocated FLVMetaVideoColor together with FLVContext
3. Improve the use of meta_color_info_flag. Do a sequence of strcmp
only if meta_color_info_flag is FLV_COLOR_INFO_FLAG_PARSING.
4. Check return value of amf_parse_object().

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:03:15 +08:00
Zhao Zhili
f34294897f avformat/flvdec: Fix use sizeof(AVMasteringDisplayMetadata)
sizeof AVMasteringDisplayMetadata isn't part of ABI.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: James Almer <jamrial@gmail.com>
2025-03-12 16:02:12 +08:00
Andreas Rheinhardt
ede2b391cc avcodec/put_bits: Add and use put_bits63()
When using a 64bit PutBitContext (i.e. on x64), put_bits_no_assert()
can naturally write up to 63 bits. So one can avoid treating the
cases <32bits, 32 bits and <63 bits differently.

As it turns out, no user actually wants to write 64 bit at once
(maybe except testprograms).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-11 04:37:21 +01:00
Andreas Rheinhardt
b98beb3704 all: Use put_bytes_output() instead of put_bits_ptr - pb->buf
Avoids accessing internals of PutBitContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-10 04:51:57 +01:00
Andreas Rheinhardt
56cfbe3c9f avformat/mpegenc, mpegts. mxfenc: Mark (de)muxers declarations as internal
Otherwise compilers might emit code that presumes there to be
a GOT which can't be fixed by the linker.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-05 00:24:54 +01:00
Andreas Rheinhardt
9e2773034b avformat/rtp_av1: Add necessary headers
Also use a void* instead of an AVFormatContext as logctx in parse_leb.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-04 15:34:38 +01:00
Zhao Zhili
2d7966aee1 avformat/isom_tags: Add tag for AVS3
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-04 17:01:58 +08:00
Zhao Zhili
a053516e64 avformat/movenc: Add AVS3 support
'avs3' is registered at mp4ra.org. The Avs3ConfigurationBox 'av3c'
inside 'avs3' hasn't been registered yet, but is specified by the
AVS3 spec.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-04 17:01:58 +08:00
Viraaj Raulgaonkar
081c865867
avformat/riffdec: change declaration of ff_get_wav_header()
Change the type of logctx from void* to AVFormatContext*. This is in
preparation for the next commit.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-04 02:07:01 +01:00
James Almer
25c439296b avformat/mov: fix overflow in corrected_dts calculation
Fixes: Integer-overflow
Fixes: 400093647/clusterfuzz-testcase-minimized-media_metadata_parser_fuzzer-4794341562187776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-03 18:10:10 -03:00
softworkz
ace9f03a6c
avformat/hls: Partially revert "reduce default max reload to 3"
(setting to 100 as a reasonable compromise)

The change has caused regressions for many users and consumers.
Playlist reloads only happen when a playlist doesn't indicate that it
has ended (via #EXT-X-ENDLIST), which means that the addition of future
segments is still expected.
It is well possible that an HLS server is temporarily unable to serve
further segments but resumes after some time, either indicating a
discontinuity or even by fully catching up.
With a segment length of 3s, a max_reload value of 1000 corresponds to
a duration of 50 minutes which appears to be a reasonable default.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-01 02:47:20 +01:00
Chris Hodges
330c8f8b93 avformat: add AV1 RTP depacketizer and packetizer
Add RTP packetizer and depacketizer according to (most)
of the official AV1 RTP specification. This enables
streaming via RTSP between ffmpeg and ffmpeg and has
also been tested to work with AV1 RTSP streams via
GStreamer.

It also adds the required SDP attributes for AV1.

AV1 RTP encoding is marked as experimental due to
draft specification status, debug amount reduced
and other changes suggested by Tristan.

Added optional code for searching the sequence
header to determine the first packet for broken
AV1 encoders / parsers.

Stops depacketizing on corruption until next keyframe,
no longer prematurely issues packet on decoding if
temporal unit was not complete yet.

Change-Id: I90f5c5b9d577908a0d713606706b5654fde5f910
Signed-off-by: Chris Hodges <chrishod@axis.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2025-02-26 12:32:22 -05:00
Peter Zebühr
e24920375c Make mime-type award a bonus probe score
This changes the default behaviour of ffmpeg where content-type headers
on an input gives an absolut probe score (of 75) to instead give a bonus
score (of 30). This gives the probe a better chance to arrive at the
correct format by (hopefully) giving a large enough bonus to push edge
cases in the right direction (MPEG-PS vs MP3, I am looking at you) while
also not adversly punishing clearer cases (raw ADTS marked as
"audio/mpeg" for example).

This patch was regression tested against 20 million recent podcast
submissions (after content-type propagation was added to
original-storage), and 50k Juno vodcasts submissions (dito). No adverse
effects observed (but the bonus may still need tweaking if other edge
cases are detected in production).
2025-02-26 14:52:34 +01:00
Ulrik Mikaelsson
5a526fdad0 avformat/mp3dec: Subtract known padding from duration
When an Info-tag is present, marking initial and trailing samples as
padding, those samples should not be included in the calculation of track
duration.

This solves a surprising user experience where converting a WAV->MP3->WAV,
ffprobe will show the duration of the mp3 as slightly longer than both the
input and the output.

As a result, the estimated duration and imprecise seek-results of some
FATE-tests have been updated.
2025-02-26 14:52:34 +01:00