Commit graph

27398 commits

Author SHA1 Message Date
Niklas Haas
a37c00c4e9 avformat/shared: add missing ret = 0
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Michael Niedermayer
6049b4d7bc avformat/rtspdec: bound Content-Length in the ANNOUNCE handler to SDP_MAX_SIZE
Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-06-13 21:31:18 +00:00
haoyuLiu
dd9083cb89 avformat/http: reject request-line tokens not terminated by whitespace
Fixes out of array access

Found-by: Cloud-LHY (@Clouditera-lhy) / VulnForge Security Research Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 16:47:05 +00:00
James Almer
b817e19259 avformat/dump: support printing Dolby Vision stream group information
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-12 15:10:12 +00:00
Michael Niedermayer
2cc7b87bdb avformat/mov: reject out of range ispe dimensions, avoid overflow summing HEIF tile dimensions
ispe width/height are read as uint32 but stored in int HEIFItem fields;
values above INT_MAX became negative, and read_image_grid() summing such
widths into coded_width overflowed int:
libavformat/mov.c:10404:33: runtime error: signed integer overflow: -2147483647 + -2147483647 cannot be represented in type 'int'

Also accumulate the grid tile dimensions and running offsets in 64bit
and validate the totals, as up to 256 tile columns of individually
valid widths can still overflow int.

Found-by: 51511
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 02:00:36 +00:00
Michael Niedermayer
c82196b299 avformat/hlsenc: reject out-of-range EXT-X-PROGRAM-DATE-TIME
Parse the timestamp with av_small_strptime() instead of sscanf(): it
range-checks each field (year 0-9999, month, day, hour, minute, second)
and limits the number of digits consumed, so an oversized field can no
longer overflow during parsing. The mktime() result is additionally
checked for EOVERFLOW.

Fixes: integer overflow

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 01:57:06 +00:00
David Korczynski
50e65074f5 avformat/dhav: Fix second integer overflow in get_duration()
Fixes: ada-2-poc.dhav

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.
2026-06-12 00:46:32 +00:00
James Almer
e4c631731e avformat/mov: allow outputting potentially truncated APV packets
The size field could be wrong while the actual payload is valid.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-11 21:09:24 +00:00
Romain Beauxis
f35a082ecc libavformat/{riffenc, adpcmenc}.c: export correct bitrate 2026-06-11 14:06:20 +00:00
Romain Beauxis
80b2dcc991 libavformat/riffdec.c: correct invalid bit_rate when possible. 2026-06-11 14:06:20 +00:00
Romain Beauxis
e02b4e5d62 libavformat/tests/seek.c: add optional stream id CLI param. 2026-06-11 14:06:20 +00:00
James Almer
cf0244aa38 avformat/movenc: avoid negative cts offsets when using an edit list with CMAF output
Fixes issue #23417.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-10 18:14:42 +00:00
Romain Beauxis
c19949ae0f avformat/isom_tags: Add support for detecting apple_apac
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-06-10 11:59:35 +00:00
Jun Zhao
c75701a62f lavf/mov: read multi-valued metadata tags
When a metadata tag (e.g. ©ART) contains multiple values, either as
multiple 'data' child atoms within one tag or as multiple sibling tag
atoms with the same key, only the first value was read.

Fix by joining multiple values with semicolons using AV_DICT_APPEND,
consistent with Ogg Vorbis Comment handling in oggparsevorbis.c, and
reusing the existing 'goto retry' loop that covr already uses.
Also add the missing atom.size -= str_size to correctly track remaining
bytes in the tag atom, matching the covr path.

Limitation: on remux the joined string is written back as a single
value, same lossy behavior as Ogg Vorbis. Lossless round-trip would
require AV_DICT_MULTIKEY support throughout the metadata pipeline.

Fix #22367
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-08 02:18:32 +00:00
Michael Niedermayer
0a8d961388 avformat/matroskadec: avoid signed overflow in DASH cue time differences
Fixes: 493466409/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6150181551931392
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-07 02:56:44 +00:00
Michael Niedermayer
b99c6fc8c3 avformat/dashdec: Fail with any inner stream count being 0
Fixes: ada-3-poc.mpd

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-06-06 17:29:17 +00:00
Michael Niedermayer
0ea090e09f avformat/gxfenc: Check timecode and propagate error
Fixes: ./ffmpeg   -f lavfi -i testsrc=duration=0.1:size=720x480:rate=30   -c:v mpeg2video -frames:v 1   -metadata timecode="999999999:00:00:00"   -f gxf output.gxf

Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-05 01:14:02 +00:00
Michael Niedermayer
fe2dabbbf4 avformat/iamf_parse: bound substream count by remaining OBU size
also check for nb_substreams == 0

Fixes: 472641765/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6390897173659648
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-05 01:11:58 +00:00
Michael Niedermayer
c7e0bac050 avformat/matroskadec: bound TRACKENTRY parsing by max_streams
After the fix the reproducer finishes in 43 ms instead of OOM-ing at the
2 GB limit. Legitimate .mkv/.webm fate samples still parse cleanly.

Fixes: 471604245/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6662979358883840
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-05 01:11:11 +00:00
Andreas Rheinhardt
e076b602c0 avformat/tls_{gnutls,mbedtls,openssl}: Add config_components.h
Forgotten in fb5dd6ec60,
effectively disabling the #if CONFIG_UDP_PROTOCOL block;
it triggered a -Wundef warning as well as an unused-variable
warning in tls_openssl.c.
Also use the TLSShared* in tls_openssl to avoid an unused
variable warning if the UDP protocol is disabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-05 00:43:20 +02:00
Andreas Rheinhardt
5b9d8901a9 avformat/shared: use av_fallthrough to mark fallthroughs
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-04 19:43:15 +02:00
Kacper Michajłow
ca1b3c79a4 avformat: don't use deprecated .lcevc field
It's the same as `.layered_video` now.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-04 17:03:05 +00:00
Niklas Haas
afce637550 avformat/shared: add option to verify cache file contents
This will effectively disable the cache but allows the cache layer to verify
cached files against the original input file. Useful only for debugging
the shared cache protocol itself, as file corruption can already be caught by
the CRC check.
2026-06-04 17:48:12 +02:00
Niklas Haas
ca748964fe avformat/shared: implement 16-bit CRC check
Decided to split this off from the previous commit in case we
ever want to revert it, since it does double the overhead of the spacemap
as well as adding extra overhead to both the read and write path.

Bump the cache version to 2 to reflect the changed disk format.
2026-06-04 17:48:12 +02:00
Niklas Haas
56de70a2e6 avformat: add shared concurrent block cache protocol
This adds a new protocol shared:URI which is distinct from the existing
`cache:` in that it is explicity designed to be thread-safe and cross-process,
enabling multiple ffmpeg processes (or multiple ffmpeg decoders within the same
process) to share a single cache file, for e.g. a remote HTTP stream. As such,
it uses a radically different internal design.

To facilitate zero-knowledge cross-process interoperability, the cache file
itself is just a memory-mapped representation of the underlying file data,
which has the side benefit that the resulting cache file will contain a
working copy of the streamed file (assuming the stream was read to
completion).

To keep track of which regions are cached and which are not, we use a
secondary file that contains a minimal header along with a static bytemap of
blocks within the file. This secondary file is also used to store metadata
such as the filesize, if known, as well as marking "failed" blocks.

Both files can grow dynamically in order to accommodate larger/growing files,
and can be atomically updated (through the use of shared space maps). I have
extensively checked the space map initalization and update code for race
conditions, and I believe the current design to be solid.

That said, it is the user's responsibility to some extent to ensure that the
same URI is not used for different streams, as we rely on the URI to uniquely
identify the cache files. That said, we use a cryptographic hash with
sufficient collision resistance to protect against possible abuse. The lack of
any implicit default on `-cache_dir` also means that `shared:` can't be enabled
via URL injection to possibly access random files on the disk (or intentionally
leak content from other streams with similar URIs, even if the cryptograhic
hash function is broken).
2026-06-04 17:48:12 +02:00
Niklas Haas
cd3f335207 avformat/file: return ENOSYS for filesize query on files with follow=1
If the input is expected to grow, we shouldn't make any assumptions about
the file size. This matches e.g. the behavior of streamed protocols like
chunked HTTP, which similarly return ENOSYS for streams of unknown size.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-04 17:48:12 +02:00
Niklas Haas
7cb93fb200 avformat/http: return ENOSYS instead of UINT64_MAX for unknown filesize
This matches the behavior of e.g. the pipe: protocol, which returns ENOSYS
on account of ffurl_seek() not being implemented.

The previous behavior of returning s->filesize directly is almost surely a
bug, as s->filesize is UINT64_MAX when never initialized.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-04 17:48:12 +02:00
Michael Niedermayer
92804c9e25 avformat/rtmppkt: Check recursion depth
Based on flvdec.c

Fixes: out of array access

Found-by: Xueqing
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-03 23:36:13 +00:00
Tim Walker
34ebcabcf1 avformat/aiffenc: write CHAN chunk after COMM
COMM is where the channel count is indicated
Channel count can be useful when parsing the CHAN chunk
2026-06-03 14:32:19 +00:00
Omkhar Arasaratnam
711cdae64f avformat/mov: cap HEIF ICC profile copies via c*max_streams to bound CPU and memory
Found-by: Claude (Anthropic). Human-verified and reported by
Omkhar Arasaratnam <omkhar@linkedin.com>.
Signed-off-by: Omkhar Arasaratnam <omkhar@linkedin.com>
2026-06-02 20:55:14 +00:00
Romain Beauxis
80375ca773 avformat/mpegts: update stream metadata from timed_id3 packets
Set AVSTREAM_EVENT_FLAG_METADATA_UPDATED so applications can detect
mid-stream metadata changes without inspecting packet side data.
2026-06-01 21:53:36 -05:00
Michael Niedermayer
43f712d917 avformat/iff: check av_get_packet() result in ANIM branch
Fixes: 494958338/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-6265824670449664
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-01 22:56:47 +00:00
James Almer
95fe0658d7 avformat/mov: don't abort on unsupported or invalid chnl boxes
They are optional and just define a channel layout, which may also be defined
by the underlying codec.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-01 09:53:54 -03:00
James Almer
fd1c8fa0e6 avformat/mov_chan: keep the layout untouched on chan/chnl box failure
Needed to keep the process going if some issue was found while parsing these boxes.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-01 09:53:54 -03:00
James Almer
cd92ef77c9 avformat/mov: add support for version 1 of chnl box
Fixes ticket #11183.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-01 09:53:54 -03:00
James Almer
f778a7e241 avformat: deprecate AVStreamGroupLCEVC
It's been replaced with AVStreamGroupLayeredVideo, which is functionally the
same while generic enough to be shared with other kinds of layered video
implementations.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow
b31fdbfde0 avformat/matroskadec: create Dolby Vision stream group
Matroska has no explicit cross-track Dolby Vision reference, so the
pairing is recovered from the dvcC/dvvC config records. Find a single
HEVC track whose record declares a profile 7 enhancement layer
(el_present_flag=1) and a single sibling HEVC BL candidate. If either
side is ambiguous, leave the streams ungrouped.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow
29bc8ec8d1 avformat/mpegts: create Dolby Vision stream group
See: https://professionalsupport.dolby.com/s/article/How-to-signal-Dolby-Vision-in-MPEG-2-TS

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow
8d89d7c25a avformat/mov: create Dolby Vision stream group
See: https://professionalsupport.dolby.com/s/article/How-to-signal-Dolby-Vision-in-ISOBMFF-format-AKA-mp4-container

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow
0a2e0b28d0 avformat/mov: add support for vdep based tref
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow
d7c7ee4e2e avformat: add AV_STREAM_GROUP_PARAMS_DOLBY_VISION
This uses existing AVStreamGroupLayeredVideo.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
Kacper Michajłow
1e3883df9f avformat: rename AVStreamGroupLCEVC to AVStreamGroupLayeredVideo
It will be reused for other similar groups.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 03:43:29 +00:00
James Almer
de647bfbbc avformat/mpeg: lower PES stream score compared to mp3/ac3
The heuristics run to detect PES streams are much laxer than mp3/ac3 ones,
which check for valid headers, so it should not have a higher score than the
latter.

Fixes misdetection of some mp3 files with big id3v2 tags at the beginning.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-31 00:39:51 +00:00
James Almer
fd9e4fa081 avformat/dump: remove unused variable
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-30 16:02:26 -03:00
Romain Beauxis
6ef1a9579f avformat/matroskaenc: write hvcE BlockAdditionMapping for Dolby Vision EL
When AV_PKT_DATA_HEVC_CONF is present on an HEVC track, write
an hvcE BlockAdditionMapping alongside the existing dvcC/dvvC one,
carrying the raw HEVCDecoderConfigurationRecord for the enhancement layer.
2026-05-30 17:37:28 +00:00
Romain Beauxis
523b9faa94 avformat/matroskadec: parse hvcE block addition mapping as AV_PKT_DATA_HEVC_CONF
Handle MATROSKA_BLOCK_ADD_ID_TYPE_HVCE in mkv_parse_block_addition_mappings
and store the raw HEVCDecoderConfigurationRecord as
AV_PKT_DATA_HEVC_CONF on the stream's coded side data, mirroring
the existing dvcC/dvvC handling.
2026-05-30 17:37:28 +00:00
Romain Beauxis
e2cfc80f32 avformat/matroska: add hvcE block addition mapping type
Add MATROSKA_BLOCK_ADD_ID_TYPE_HVCE (0x68766345) for the Dolby Vision
enhancement-layer HEVC configuration, alongside the existing dvcC/dvvC
entries.
2026-05-30 17:37:28 +00:00
Romain Beauxis
199e49d9b6 avformat/movenc: write hvcE box for Dolby Vision enhancement layer
When AV_PKT_DATA_HEVC_CONF is present on a MODE_MP4 HEVC
track, write it as an hvcE box alongside hvcC and dvcC. Like dvcC,
writing requires -strict unofficial.
2026-05-30 17:37:28 +00:00
Romain Beauxis
2c74d197ee avformat/mov: parse hvcE box as AV_PKT_DATA_HEVC_CONF side data
The hvcE box carries the HEVCDecoderConfigurationRecord for the Dolby
Vision enhancement layer in ISOM-based containers. Store its raw
contents as AV_PKT_DATA_HEVC_CONF on the stream's coded side data,
mirroring the existing dvcC/dvvC handling.
2026-05-30 17:37:28 +00:00
Michael Niedermayer
aaac0989e6 avformat/mxfdec: Remove unneeded check
size is 16bit only

Found-by: Tomas Härdin
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-29 18:23:06 +00:00