Commit Graph

26945 Commits

Author SHA1 Message Date
Jack Lau
ba3cbc2b4a avformat/whip: fix hard code in SDP BUNDLE
In early code, the BUNDLE always has two stream
id "a=group:BUNDLE 0 1" even though there's only
one stream.

This patch aims to dynamically set BUNDLE value.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 09:18:59 +00:00
Jack Lau
69b6af0e68 avformat/whip: remove redundant NONBLOCK set for dtls
DTLS handshake already force set BLOCK mode.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau
bbd63b5a82 avformat/whip: handle the error of dtls_initialize
Correct the log level to AV_LOG_ERROR when dtls fails

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau
42596578ee avformat/whip: put dtls init code into dtls_initialize
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau
ddf3e56514 avformat/whip: correct the ice time log
The ICE handshake actually finished after recieve
and handle binding request from peer when the peer
is not ice lite mode.

Log the ice status when it really done.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jun Zhao
33dd3485ba lavf/format: skip multiple consecutive ID3v2 tags in probe
Files with multiple consecutive ID3v2 tags were getting low probe
scores (1) because av_probe_input_format3 only skipped the first tag,
leaving subsequent tags to be treated as non-audio data.

Fix by looping to skip all consecutive ID3v2 tags before probing.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-21 02:37:43 +00:00
James Almer
41a2eb735c avformat/iamf_parse: stop trying to parse files that report an unknown layout
Exporting unknown layouts as unspec type is pointless in a format that expects
the user to remix the channels in location specific ways.
This simplifies assumptions and reduces the chances of heap buffer overflows.

Fixes: heap-buffer-overflow
Fixes: clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6363647720095744
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-21 00:02:58 +00:00
Jack Lau
8bd5594a0f avformat/whip: fix potential out of bound read in is_dtls_packet
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau
5bc9e76ec6 avformat/whip: fix parameter order of ELAPSED
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau
5e73027099 avfotmat/whip: remove ssl_error_message since it's no longer in use
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau
d15a9d5961 avformat/whip: fix memleak when avio_alloc_context() fails
The buffer is prepared for avio, so we need to free
the buffer at the end when avio_alloc_context() fails,
otherwise, it will cause memleak.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:34:43 +08:00
Jack Lau
cc8f392136 avformat/whip: add new option ts_buffer_size to deprecate buffer_size
See https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20965#issuecomment-15854

The old option name `buffer_size` maybe confusing because there're some
protocols and muxer using this.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-18 03:42:05 +00:00
Jack Lau
74bc79e475 avformat/tls_gnutls: fix build error on linux
The fd_set need <sys/select.h> on linux, but it's
not included in os_support.h, it's included in os_support.c

So this patch use poll() to replace select() to avoid
this issue and simplify the code.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-18 01:57:56 +00:00
James Almer
5ec31dac94 avformat/mov: fix memory leak on error
Regression since 52b1977353.

Fixes CID 1680454.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 17:52:52 -03:00
James Almer
c1a7c79624 avformat/hcom: check that all extradata bytes were read from the input
Fixes issue #21493.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 17:42:06 -03:00
James Almer
52b1977353 avformat/mov: add overflow checks to item offset values
Fixes issue #21478.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 13:02:49 -03:00
Jun Zhao
6c878f8b82 lavf/movenc: fix missing padding for AV1 extradata
The extradata allocated in mov_write_single_packet() for AV1 was missing
the required AV_INPUT_BUFFER_PADDING_SIZE padding bytes. This could lead
to out-of-bounds reads when the extradata is parsed by bitstream readers.

Replace av_memdup() with av_malloc() + memset() + memcpy() to ensure
proper padding is present and zeroed.

Reproduced with:
./ffmpeg -y -f lavfi -i "testsrc=duration=1:size=320x240:rate=30" -c:v libaom-av1 -cpu-used 8 -crf 50 test-av1.mp4

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-14 23:56:39 +00:00
Michael Niedermayer
23c8123d5b avformat/http: Check white and blacklists on redirects
Noticed while fixing the previous

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 21:56:14 +00:00
Michael Niedermayer
b9227d49ea avformat/http: Check that the protocol of redirects is http or https
Fixes: #YWH-PGM40646-10

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 21:56:14 +00:00
James Almer
cd03e0a001 libavformat/evcdec.c: add a check to ensure evc_frame_merge_bsf is present
While the inclusion of the bsf is forced by a configure check, it's better to not
just have the code here assume filter will never be NULL.

Fixes Coverity issue CID 1680305.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-12 01:43:21 +00:00
Marton Balint
96e8f3b8cc avformat/vorbiscomment: fix writing huge chapter numbers and time offets to vorbiscomment
Previous code truncated chapter numbers more than 999 and and time offsets more
than 99 hours.

The Vorbis comment format only allows 1000 chapters, so cap the number of
written chapters there.

This also fixes the GCC warnings for truncated strings.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-12 00:47:20 +01:00
Marton Balint
b2e077ad69 avformat/vorbiscomment: use null buf to calculate vorbis comment length
Also check possible failures when calculating length, and change return type to
int as bigger return values are no longer possible.
2026-01-12 00:47:20 +01:00
Marton Balint
c80d3b35ae avformat/aviobuf: return error for ffio_close_null_buf() if written bytes exceed INT_MAX
Also check return value where it is used.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-12 00:47:20 +01:00
Jack Lau
b0fe52ba4e avformat/tls_gnutls: add gnutls_pull_timeout() for dtls
See https://gnutls.org/manual/gnutls.html#index-gnutls_005ftransport_005fset_005fpull_005ftimeout_005ffunction

This callback is necessary for enforcing the DTLS mode timeouts when in blocking mode.

Otherwise the dtls pull function won't work.

The gnutls_pull_timeout() implementation refers to gnutls example:
https://gnutls.org/manual/gnutls.html#DTLS-echo-server-with-X_002e509-authentication-1

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-11 04:24:26 +00:00
Jack Lau
6f2d23a009 avformat/tls_gnutls: implement dtls handshake logic
Get and set remote addr when dtls server mode.
(Refer to url_bio_bread in tls_openssl.c)

add tls_handshake function to handle the dtls
or tls handshake

TODO:
add gnutls_pull_timeout function to make dtls
handshake really work.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-10 05:30:50 +00:00
Nicolas Gaullier
af6a1dd0b2 avformat/demux: duplicate side_data in parse_packet()
If an input packet results in several output packets, the side data will be
exported only by the first output packet, and be missing from the rest.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-07 20:25:18 -03:00
James Almer
0cca125a94 avformat/demux: prevent the loss of packet side data when using an parser
Many parsers will request data until they find what will be the start of the
next assembled packet in order to decide where to cut the current one. If this
happens, the loop in demux.c will, in case the demuxer exports already fully
assembled packets as is sometimes the case for MPEG-TS, discard the already
handled first input packet before it tries to move its side data to the output.

The affected FATE tests reflect this change by no longer dropping the side data
from the first input packet, nor exporting every other side data in the wrong
output packet.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-07 20:25:18 -03:00
James Almer
70d84bdd84 avformat/demux: use a stream specific temporary packet for the parser
This will be useful for the next commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-07 20:25:17 -03:00
Gyan Doshi
03541f0026 avformat/hls: show stream IDs
The subdemuxer may be MPEG-TS which sets stream id, and users may
want to see it for stream selection.
2026-01-06 04:05:47 +00:00
wangwenchao10
2892815c45 avformat/pcmdec: Mark raw PCM stream as having no timestamps
Signed-off-by: wangwenchao10 <wangwenchao10@xiaomi.com>
2026-01-05 01:23:17 +00:00
Marton Balint
8579037b6c avformat/file: respect pkt_size even in streaming mode
Also clarify the documentation a bit.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-01 18:20:58 +00:00
Timo Rothenpieler
f6a95c7eb7 avformat/img2dec: reject input images too big to fit into a single packet
Not entirely sure if it should instead use some entirely different
approach here, given that images exceeding 2GB don't seem that crazy
to me, but so far processing such images results in a heap overflow,
since the size addition overflows and a much too small packet is
allocated and its size never checked again when writing into it.

Fixes #YWH-PGM40646-32
2025-12-31 14:37:58 +00:00
caifan3
82144fea48 libavformat/file: apply pkt_size option to read mode
Previously, the pkt_size option only affected write buffering in the file
protocol. This change extends its effect to read mode as well.

On embedded systems with limited RAM, users can now reduce I/O buffer
memory by setting a smaller pkt_size.

Signed-off-by: caifan3 <caifan3@xiaomi.com>
2025-12-30 00:49:13 +00:00
James Almer
129744ac72 avformat/iamf_writer: reindent after the previous change
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:10 -03:00
James Almer
8cd4d4cb0b avformat/iamf_writer: add support for Projection mode ambisonic Audio elements
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:02 -03:00
James Almer
a0fc454871 avformat/iamf_writer: check that stream count is consistent for ambisonic Audio Elements
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer
21ff60d2cf avformat/iamf_writer: fix writting some ambisonics fields in Audio Elements
The fields are defined as 8 bit long unsigned ints. Fortunately, writing most sane values
as leb is equivalent, which is why no tests are affected.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer
e3498c8051 avformat/iamf_parse: set AVIAMFLayer.nb_demixing_matrix
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer
03a981445e avformat/iamf_parse: fix setting denominator in AVIAMFLayer.demixing_matrix
The format of demixing_matrix is Q15 fixed point values.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
Martin Storsjö
78bfcf003b libavformat: Fix the docs for av_mime_codec_str and ff_make_codec_str
The doxygen comments were missed as these functions were updated
during review; they don't take separate pointer/length parameters
but use an AVBPrint struct now instead.

Also clarify that ff_make_codec_str doesn't log if the logctx
parameter is NULL.
2025-12-29 12:05:14 +00:00
James Almer
f8e6f8f0a2 avformat/iamf_parse: check layer channel count and stream count for consistency
A layer could define a loudspeaker_layout that corresponds to a certain channel layout,
but then report an amount of substream_count and coupled_substream_count that might not
match the expected channel count.

Fixes: Invalid write of size 4
Fixes: clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6687125346254848

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-27 15:16:49 +00:00
Michael Niedermayer
9e974b2c45 avformat/hls: fix double space
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 14:14:45 +01:00
Michael Niedermayer
548b28d5b1 avformat/hls: Fix arguments of handle_rendition_args()
Fixes: call to function handle_rendition_args through pointer to incorrect function type 'void (*)(void *, const char *, int, char **, int *)'
Fixes: 464965411/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-4790164406992896

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 12:04:07 +00:00
Michael Niedermayer
d1985442e1 avformat/hls: Check seg size and offset for overflow
Fixes: integer overflow
Fixes: signed integer overflow: 9223372036854775807 + 2039324394 cannot be represented in type 'int64_t' (aka 'long')

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 12:04:07 +00:00
Zhao Zhili
260f5a47a5 avformat/rawvideodec: add stride option to skip line padding
Some tools like v4l2-ctl dump data without skip padding. If the
padding size is not an integer multiple of the number of pixel
bytes, we cannot handle it by using a larger width, e.g.,, for
RGB24 image with 32 bytes padding in each line.
2025-12-23 03:20:34 +00:00
Zhao Zhili
49a15e70be avformat/rawvideodec: use AV_OPT_TYPE_PIXEL_FMT instead of parse from string manually 2025-12-23 03:20:34 +00:00
Romain Beauxis
b43645b2ef libavformat/id3v2.c: return valid string in decode_str for empty strings
with no bom. Fixes: #YWH-PGM40646-12
2025-12-22 13:44:42 +00:00
Andreas Rheinhardt
b934dd1d4b avformat/whip: Fix leak of dtls_fingerprint
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:45:24 +01:00
Andreas Rheinhardt
34bc95ddfc avformat/whip: Check number of audio/video streams generically
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:45:21 +01:00
Andreas Rheinhardt
e252bc0c3d avformat/whip: Remove dead code
This is checked generically after
6070ea29de.
Also set AVOutputFormat.subtitle_codec explicitly in order
not to rely on AV_CODEC_ID_NONE to be zero.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:42:27 +01:00