Commit Graph

27296 Commits

Author SHA1 Message Date
James Almer ef3ff9a73d avformat/iamf_writer: reject unset frame size
The specification states that nb_samples in codec config must not be zero.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:23 -03:00
James Almer c0bdc3b62a avformat/avformat: add an AVOutputFormat capability flag to signal fixed frame size is needed.
And set it on the IAMF muxer.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:22 -03:00
James Almer 7c5df8d34d avformat/matroskaenc: use frame_size to write audio DefaultDuration
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-16 13:55:22 -03:00
David Korczynski 08d7646abf avformat/assenc: Add the missing parentheses
Fixes: ada-1-poc.mkv

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects, and I am from Ada Logics helping validate the found issues and report to maintainers.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-16 16:53:51 +00:00
Kacper Michajłow 200cbaeb5a avformat/hlsenc: use correct close function for custom io
This is open by s->io_open().

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 18:03:26 +02:00
Kacper Michajłow 06ef9a74ea avformat/hlsenc: respect io_open set in AVFormatContext
io_open_default() will call internal impl if needed, don't call it
directly.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 17:18:51 +02:00
Kacper Michajłow 4cf687b3b1 avformat/dashenc: respect io_open set in AVFormatContext
io_open_default() will call internal impl if needed, don't call it
directly.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 17:18:51 +02:00
Kacper Michajłow fbc4003642 avformat/dashdec: respect io_open set in AVFormatContext
io_open_default() will call internal impl if needed, don't call it
directly.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 17:18:51 +02:00
Kacper Michajłow dc74fe70b2 avformat/demux: use correct close function for custom io
You may look and think `AVFMT_FLAG_CUSTOM_IO` check is enough, but this
is not what it seems. This flag means that user provided custom
AVIOContext, before creating AVFormatContext and it should not be
closed. However nested sub-demuxers may still open an temporary io, and
those have to be closed and use correct io_close2 function.

You can see 0dcac9c3f0 and
ef01061225 where this flag is cleared for
nested opens to avoid leaking those.

lavf micro version bumped so API users can know if it is safe to use
custom io.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 11:09:56 +00:00
Stuart Eichert 2aad4fb2e3 Typo: Remove space in 'centiseconds', 'microseconds', and 'nanoseconds'.
According to Chapter 3, Paragraph 2 of the "SI Brochure - 9th ed./version 3.02":

> Prefix symbols are printed in upright typeface, as are unit symbols,
> regardless of the typeface used in the surrounding text and are
> attached to unit symbols without a space between the prefix symbol
> and the unit symbol.

https://www.bipm.org/documents/20126/41483022/SI-Brochure-9-EN.pdf
2026-05-15 18:19:40 -07:00
Link Mauve b5fc215e2d avformat/mods: Return EOF for packets starting at the index offset
Assuming there is no padding between the last packet and the index, this
prevents the index from being parsed as a normal packet, with non-
sensical data.
2026-05-15 19:30:52 +00:00
Link Mauve c4b7a51d35 avformat/mods: Parse the index entries
This lets us seek in the video properly, based on the table at the end
of the files, and has been tested with Suikoden Tierkreis videos.

While at it I’ve also set the duration of the stream, this makes the
progress bar work correctly in mpv.
2026-05-15 19:30:52 +00:00
Andreas Rheinhardt b2867481d9 avformat/avformat: Add AVFMT_EXPERIMENTAL to allowed flags
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-14 22:58:04 +02:00
Marton Balint 43bbd6dbf9 avformat/utils: avoid void pointer arithmetic
Fixes compliation on MSVC.

Regression since cb708d8703.

Based on code by James Almer.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-05-14 20:52:45 +02:00
Ben Kepner a327bc0561 avformat/hlsenc: fix segment duration with mixed stream time bases
When audio and video streams have different time bases (e.g. video at
1/90000 and audio at 1/48000), vs->start_pts was stored as a raw PTS
from whichever stream's packet arrived first. The segment split
comparison then subtracted this value from the current packet's PTS
without accounting for the time base difference, producing incorrect
elapsed time calculations.

This caused segments to be split at wrong points — either too
frequently (on every keyframe) or not at all, depending on the
relative magnitudes of the time bases.

Fix by normalizing vs->start_pts to AV_TIME_BASE_Q at the point of
assignment and converting pkt->pts to the same base before comparison.
This ensures the segment split decision is always unit-consistent
regardless of which stream's packet is being evaluated.

The bug is most easily triggered by HLS muxing with video passthrough
and audio transcode, where the video retains its container time base
while the audio encoder outputs in its native time base.

Signed-off-by: Ben Kepner <u6bkep@gmail.com>
2026-05-13 23:04:46 +00:00
Marton Balint 566ad7869e avformat/hlsenc: remove unused function parameter
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-05-13 22:41:23 +02:00
Marton Balint f20ea3fb22 avformat/hlsenc: dynamically allocate segment uris along with the segment struct
As suggested by Andreas Rheinhardt.

Supersedes: #22536.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-05-13 22:41:23 +02:00
Marton Balint cb708d8703 avformat/utils: add ff_bprint_finalize_as_fam to put bprint strings to flexible array members
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-05-13 22:41:23 +02:00
Kirill Gavrilov 553321d59e libavcodec/hdrdec: accept "#?RGBE" header in addition to "#?RADIANCE"
Some Radiance HDR image files in the wild have "#?RGBE" header,
which other image readers accept.

Also updated hdr_probe() in libavformat/img2dec.
2026-05-13 19:35:33 +00:00
Andreas Rheinhardt c29d1b9df5 avformat/id3v2: Fix indentation
Forgotten after e9c372362c.

Reviewed-by: Romain Beauxis <toots@rastageeks.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-12 16:12:54 +02:00
Andreas Rheinhardt 356e427d5c avformat/id3v2: Use proper logcontext
Otherwise one could not associate log messages with inputs.

Reviewed-by: Romain Beauxis <toots@rastageeks.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-12 16:12:51 +02:00
Andreas Rheinhardt e626b02a01 avformat/id3v2: Avoid temporary buffer
Reviewed-by: Romain Beauxis <toots@rastageeks.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-12 16:11:56 +02:00
Marvin Scholz 18761f9fb5 avformat/rtpdec_av1: fix buffer overflow due to variable confusion
The pktpos denotes the position in the output packet buffer, while
buf_ptr is the position in the input buffer. As this payload is ignored,
nothing is written to the output packet so increasing the pktpos does
not make sense here, instead the buf_ptr has to be increased to advance
the input buffer to the correct position after this OBU.

This incorrect increment here could result in pktpos exceeding the whole
size of the output packet and the later call to memcpy to write to that
buffer would start its write way past the end of the packet buffer.

Fix #22812

Reported-By: fre3dm4n
2026-05-12 16:02:51 +02:00
Vignesh Venkat 2c1af16872 avformat/matroskaenc: Use correct buffer for smpte2094_app5
In the call to mkv_write_blockadditional, use the correct
buffer for smpte2094_app5.

Commit 38df985fba updated the
buffer usage to prevent incorrect buffer reuse, but left this line
unchanged inadvertently.

Signed-off-by: Vignesh Venkat <vigneshv@google.com>
2026-05-11 14:44:25 -07:00
Nariman-Sayed 837cf8e38f avformat/tls_mbedtls: fix DTLS handshake failure when receiving non-DTLS packets
Some WebRTC servers such as Pion send STUN packets concurrently during
the DTLS handshake. Unlike OpenSSL and GnuTLS which filter non-DTLS
packets internally, mbedtls passes all received UDP packets directly to
its DTLS state machine, causing the handshake to fail.

Fix this by using ff_is_dtls_packet() in mbedtls_recv to discard
non-DTLS packets such as STUN by returning WANT_READ, as specified
by RFC 5764 Section 5.1.2.

Signed-off-by: Nariman-Sayed <narimansayed28@gmail.com>
2026-05-11 12:36:58 +00:00
Nariman-Sayed 094f72748d avformat/tls: move DTLS packet detection into ff_is_dtls_packet()
Move the DTLS packet detection logic from whip.c into a shared
ff_is_dtls_packet() function in tls.c, with its declaration and
related macros in tls.h. Update whip.c to use the new shared function.

Signed-off-by: Nariman-Sayed <narimansayed28@gmail.com>
2026-05-11 12:36:58 +00:00
Kacper Michajłow 17bc88e67f avformat/hls: disable http_persistent/http_multiple with custom io_open
Both rely on the AVIOContext being backed by the builtin URLContext.
When the API user overrides io_open, the keepalive path asserts on the
missing URLContext and the http_multiple auto-detect probe fails on
every read. http_multiple=1 still works even with custom IO.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-11 09:00:31 +00:00
Dale Curtis 5bbc00c05d [Wave] Fix issues with unaligned metadata chunks.
Fixes corruption issues with the sample in this PR.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
2026-05-10 01:18:09 +00:00
Michael Niedermayer 188461be10 avformat/mpegts: Dont assume fc->priv_data is a MpegTSContext
Fixes: out of array access
Fixes: 508365271/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-6219535958212608

Regression since: b9cb948ec1

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-09 18:35:08 +00:00
James Almer 2948acd528 avformat/nal: take into account removed zero bytes when calculating buffer size in nal_parse_units()
Fixes issue #23010

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-09 11:28:46 -03:00
jiangjie 2f4ad2497e avformat/movenc: fix dynamic buffer leaks on error paths
In mov_write_iacb_tag(), the dynamic buffer dyn_bc was leaked when
ff_iamf_write_descriptors() failed.

In mov_write_track_udta_tag(), the dynamic buffer pb_buf was leaked
when mov_write_track_kinds() failed, as the error path returned
directly instead of going through cleanup.

Fix both by ensuring ffio_free_dyn_buf() is called on all error paths.
2026-05-09 19:27:17 +08:00
Zhao Zhili 180a10647d avformat/tee: clean up local resources on program copy failure
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-05-09 10:46:35 +00:00
Vignesh Venkat 8518599cd1 avformat/matroskaenc: Write additional mappings for webm
The elements written in mkv_write_blockadditionmapping
(MaxBlockAdditionID, BlockAddIDType and BlockAddIDValue) are all
allowed in WebM as well. Move them out of the "if (!IS_WEBM)"
block.

Matroska spec:
https://www.matroska.org/technical/elements.html#MaxBlockAdditionID
(See column with title "W" which shows WebM availability).

WebM spec:
https://www.webmproject.org/docs/container/#MaxBlockAdditionID

Signed-off-by: Vignesh Venkat <vigneshv@google.com>
2026-05-08 13:33:31 -07:00
Andreas Rheinhardt 6a59c847b5 configure: Redo enabling cbs in lavf
Right now, the cbs_type_table (the table of all CodedBitstreamTypes
supported by CBS) is empty unless cbs_apv and cbs_av1 is enabled.
The latter are only enabled in configure if they are needed in lavc.
This means that the mov muxers (the only users of cbs-in-lavf)
don't work as they should depending upon the availability of
e.g. the av1_metadata BSF. The table being empty is also illegal C
and according to PR #23038 MSVC warns about this (as does GCC
with -pedantic) and it may even lead to an internal compiler error.

This could be fixed by simply adding a mov_muxer->cbs_av1,cbs_apv
dependency in configure, yet this would have the downside that
it would force cbs_av1 and cbs_apv to be built for lavc, too,
even though it may not be needed there. So add new configure
variables cbs_{apv,av1}_lavf and cbs_lavf to track this correctly.

Reported-by: xiaozhuai <798047000@qq.com>
Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: xiaozhuai <798047000@qq.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-08 09:34:52 +02:00
Romain Beauxis 85cc813412 libavformat/tests/id3v2: add test program for raw ID3v2 frame debugging
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-05-07 09:46:37 -05:00
Romain Beauxis 910d796430 libavformat/id3v2: wire FF_FDEBUG_ID3V2 frame debugging
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-05-07 09:46:17 -05:00
Dale Curtis 256d93413f avformat/mov: Fix negative index given to can_seek_to_key_sample()
The potentially negative return value of av_index_search_timestamp()
wasn't being handled before passing it to can_seek_to_key_sample().

Found by Wongi Lee (@_qwerty_po) of Theori with Xint Code,
Jungwoo Lee (@physicube).

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
2026-05-05 21:26:38 +00:00
Gyan Doshi 7fc335cb27 avformat/tee: relay programs to child muxers 2026-05-05 12:54:40 +05:30
Gyan Doshi 1b82e58a3a avformat/segment: relay programs to child muxers 2026-05-05 12:54:40 +05:30
Gyan Doshi 0005b36eb7 avformat/hlsenc: relay programs to child muxers 2026-05-05 12:54:40 +05:30
Gyan Doshi 5c557dd5d5 avformat: add av_program_copy()
Helper to transfer programs from one muxing context to another.
2026-05-05 12:54:36 +05:30
Gyan Doshi 7623379a77 avformat: add av_program_add_stream_index2()
av_program_add_stream_index() added in 526efa1053
may fail to carry out its purpose but the lack of
a return value stops callers from catching any error.

Fixed in new function.
2026-05-05 12:51:54 +05:30
huanghuihui0904 b40d91cad9 avformat: avoid potential tmp_opts leak in ffurl_connect()
When options is NULL, ffurl_connect() creates a temporary dictionary
(tmp_opts). If the protocol_blacklist av_dict_set() fails after the
whitelist entry was inserted, the function returns without freeing
this dictionary.

Ensure tmp_opts is freed on this error path.

Signed-off-by: Huihui_Huang <hhhuang@smu.edu.sg>

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-03 20:32:16 +00:00
Alexander Slobodeniuk 1e9dd2b7e9 avformat/mpegts: handle AC-4 descriptor in DVB extension
as defined in ETSI EN 300 468 (Table 109).

This allows ffprobe to recognize that .ts
file has an ac4 stream.

Checked on the files downloaded from
https://ott.dolby.com/OnDelKits/AC-4/Download_v15.html
2026-05-03 20:10:26 +00:00
Alexander Slobodeniuk dd020e1025 avformat/mpegts: simplify ac3/eac3 descriptor handling
those lines are literally the same, so removing the
code duplication
2026-05-03 20:10:26 +00:00
Alexander Slobodeniuk cda069b092 avformat/mpegts: don't check impossible branches
Quit dvb extension handling when the descriptor
have been processed
2026-05-03 20:10:26 +00:00
Jesper Ek d5a913f99f avformat/gxf: return proper errors when reading header/packet
Returning -1 resulted in an "operation not permitted" error which
was incorrect. This changes the error to a correct "invalid data".
2026-05-03 20:03:00 +00:00
James Almer 3393dc3020 avformat/dashdec: propagate parsing requirement from the underlying demuxer
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-03 17:00:17 +00:00
James Almer e76bfba1cf avformat/mov: request parsing for LCEVC streams
Given that no standalone decoder will be present, use a parser to get stream
information that's not reported by the container.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-03 17:00:17 +00:00
Andreas Rheinhardt 21c2d38537 avformat/rmdec: Fix shadowing
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:46 +02:00