1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-29 05:57:37 +02:00
Commit Graph

26842 Commits

Author SHA1 Message Date
Vittorio Giovara
119d127d05 lavu/spherical: Add support for Spherical Immersive type 2025-07-31 10:58:36 +02:00
Vittorio Giovara
c275f3bfa1 mov: Export frame packing information from pack box 2025-07-31 10:49:27 +02:00
zhaozhenghang
eade338656 libavformat/mov.c: Fix "statement will never be executed" warning
That occurs when H261, H263, and MPEG4 decoders are disabled.

Signed-off-by: zhaozhenghang <15083277223@163.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-07-31 11:13:04 +08:00
James Almer
4eca8df8b8 avformat/movenc: support writing more than one STSD entry per track
If a packet contains new extradata within a side data entry, save for
specific cases it means the coded stream changed. If ignored, upon
demuxing every packet from then onwards may be undecodable.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-30 16:48:14 -03:00
James Almer
306448756b avformat/movenc: allow storing more than one extradata buffer per track
This is in preparation for a following change

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-30 16:48:14 -03:00
James Almer
eefa6de7d5 avformat/mov: export the correct initial extratada from samples with multiple stsd
The first sample in the stsc box may not refer to the first stsd entry.
This is the case in h264/thezerotheorem-cut.mp4, and as such the
fate-h264_redundant_pps-side_data test is updated accordingly.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-30 16:48:14 -03:00
Kacper Michajłow
daee46ed7e Revert "avformat/tls_openssl: properly get new BIO index"
BIO_get_new_index() is static counter meant to get index for custom bio
type definition. As we can read in the documentation:

> Note that BIO_get_new_index() can only be used 127 times before it
> returns an error.

We cannot call it repeatedly, because it will fail eventually.

To my understanding the index is not needed in our use and we could
safely use BIO_TYPE_NONE. Documentation states:

> type can be set to either BIO_TYPE_NONE or via BIO_get_new_index() if
> a unique type is required for searching (See BIO_find_type(3))

We don't use any search related functions.

This reverts commit 816dad231f.
Fixes: https://github.com/mpv-player/mpv/issues/16589

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-30 02:56:12 +02:00
Michael Niedermayer
ebcdba4c6b avformat/subfile: Initialize end on all cases
Fixes: use of uninitialized variable
Regression since: e29016a9de

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-30 01:18:03 +02:00
Michael Niedermayer
a408b74977 avformat/dhav: Remove end_ prefix from variable names
The end_ prefix is confusing and may have contributed the mixup
fixed in the previous commit

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 19:29:52 +02:00
Michael Niedermayer
33ae6cda71 avformat/dhav: fix reference point mixup
Fixes: reading the duration from before the start of the allocated buffer.

Regression since: 36ec9217e6

Fixes: BIGSLEEP-433513232/test

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 19:29:52 +02:00
Michael Niedermayer
1b12e919cf avformat/mxg: clear AV_INPUT_BUFFER_PADDING_SIZE
Fixes: use of uninitialized memory
Fixes: 427532813/clusterfuzz-testcase-minimized-ffmpeg_dem_MXG_fuzzer-5661938917113856

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:38 +02:00
Michael Niedermayer
1b7a327b3a avformat/vqf: Ensure that comm_chunk is fully read
Fixes: use of uninitialized memory
Fixes: 412125811/clusterfuzz-testcase-minimized-ffmpeg_dem_VQF_fuzzer-6253774274887680

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:37 +02:00
Michael Niedermayer
c6cb3ab7ff avformat/mxfdec: Ensure klv->key is initialized
Fixes: read of uninitialized memory
Fixes: 391916474/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-4935250956845056

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:37 +02:00
Michael Niedermayer
8b16e1ddd9 avformat/mov: make sure file_checksum is fully initialized
Fixes: use of uninitialized memory
Fixes: 394990189/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6431722199908352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:37 +02:00
Michael Niedermayer
fa197924a6 avformat/asfdec_f: Check amount of value read
Fixes: use of uninitialized memory
Fixes: 403675492/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_fuzzer-4754281823797248

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:36 +02:00
Artem Smorodin
0a108a37e1 avformat/hlsenc: limit segments count to search duplicated segments filenames
This linear search has a complexity of O(n). When ffmpeg attempts to parse a playlist containing approximately 100,000 segments, it effectively causes a hang for several minutes.

This patch limits the allowed size for duplicate searches to a reasonable value. Now it takes between 0.5 and a few seconds (tested on different devices) instead of several minutes.

Signed-off-by: Artem Smorodin <artem.smorodin@dacast.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:27:51 +02:00
David McElroy
4b6f6af384 avformat/movenc: fix HEVC fmp4 HLS init segment for Apple playback
HEVC fmp4 HLS video produced by ffmpeg is currently unplayable on Apple
software (Safari, QuickTime, AVFoundation).

This is caused by an empty sdtp atom being erroneously written to the
fmp4 init segment. The `has_disposable` flag can be set for a track
with B-frames, but the init segment contains no actual frames
(track->entry == 0). Writing an sdtp atom in this case is incorrect
and causes Apple's parsers to reject the file.

This patch fixes the issue by ensuring the sdtp atom is only written
if track->entry is non-zero.

A similar patch was proposed in November 2023 by Jay Zhang,
but it was never merged.

Link: https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2023-November/317173.html
Co-authored-by: Jay Zhang <wangyoucao577@gmail.com>
Signed-off-by: David McElroy <david@mcelroy.online>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:27:51 +02:00
Zhao Zhili
631bb6c6e8 avformat/mxfenc: Ensure frame offset in valid range
Fix assert failure.
Fix #11666.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-07-26 21:04:57 +08:00
Kacper Michajłow
e29016a9de avformat/subfile: clip seek offset
Fixes: signed integer overflow: 9223372036854737920 + 1649410 cannot be
represented in type 'int64_t'

Fixes OSS-Fuzz: 410100610

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 22:00:02 +02:00
Kacper Michajłow
d12863a693 avformat/rtmpproto: guard usage of undefined functions with preprocessor
The asumption is that DCE will remove references to those functions.
However some compilers with certain instrumentation enabled doesn't DCE
those at all, resulting in linking failure. Tested with cl.exe -RTCu -RTCs.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:18:17 +02:00
Kacper Michajłow
a9b9636046 avformat/vivo: fix sscanf specifer for double
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
Kacper Michajłow
c6ea6ac39b avformat/os_support: check invalid socket value correctly on Windows
SOCKET defined in winsock2.h is unsigned and invalid value is defined as
INVALID_SOCKET. Check this explicity to avoid compiler warnings.

See: https://learn.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
Kacper Michajłow
d6b72d1d26 avformat/options_table: supress implicit conversion warnings
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:13 +02:00
Kacper Michajłow
29d274afe7 avformat/udp: avoid warning about always false comparison
socklen_t underlying type can be signed or unsigned depending on
platform. This is fine, just cast it to size_t before comparison.

Fixes: warning: result of comparison of unsigned expression < 0 is
       always false [-Wtautological-unsigned-zero-compare]

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-22 19:56:34 +02:00
James Almer
87cc213748 avformat/hevc: don't print parameter_set_id for any NALU
It's not a value stored in the hvcC structure.
Fixes use of uninitialized variable errors under sanitizer when the input extradata is
already hvcC formatted, given we don't parse parameter sets for those.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:18 -03:00
Marvin Scholz
080dc4cf54 avformat/tls_openssl: load default verify locations
When no explicit CAs file is set, load the default locations,
else there is no way for verification to succeed.

This matches the behavior of other TLS backends.
2025-07-22 02:43:54 +02:00
Marvin Scholz
f4befeb767 avformat/tls_openssl: verify setting hostname for SNI 2025-07-22 02:43:54 +02:00
Daniel N Pettersson
e56fd2af1a avformat/tls_openssl: add hostname for verification
When verification is enabled (using -tls_verify 1) now
the hostname will be verified properly too, while before
only other aspects of the certificate were checked.

Co-Authored-By: Marvin Scholz <epirat07@gmail.com>
2025-07-22 02:43:54 +02:00
Michael Niedermayer
8cdb47e47a avformat/concatdec: Clip duration in one more case in get_best_effort_duration()
Fixes: signed integer overflow: 40000 - -9223372036854770000 cannot be represented in type 'long'
Fixes: 427262541/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-4831506940100608

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-21 01:27:23 +02:00
James Almer
85ac589211 avformat/apv: use memset to zero initialize frame_info
Don't rely on implicit zeroing.
Should fix fate failures on msvc targets.

Found-by: Kacper Michajlow <kasper93@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-19 20:01:57 -03:00
James Almer
36b8c200fb avformat/hevc: don't print parameter_set_id for SEI NALUs
The field is unset for those.

Fixes use of uninitialized variable errors under sanitizer.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-18 17:41:41 -03:00
James Almer
e32264a1e1 avformat/mov: don't assume iloc and iinf entries for each item_id will be in the same order
Nothing forbids them to be in any order the muxer desires.

Fixes demuxing heif samples generated by S1II.

Tested-by: Lynne <dev@lynne.ee>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-18 14:57:09 -03:00
Dawid Kozinski
8baa691e5f avformat/mov_muxer: Extended MOV muxer to handle APV video content
- Changes in mov_write_video_tag function to handle APV elementary stream
- Provided structure APVDecoderConfigurationRecord that specifies the decoder configuration information for APV video content

Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-18 14:54:36 -03:00
Eric Joyner
291ec0faf3 avformat/mov: Enable jpeg streams in HEIF MOVContext
Nikon HEIFs from a camera or NX studio include a small jpeg thumbnail in addition to
the expected HEVC thumbnails; allowing jpegs allows all thumbnails to
have an associated stream for Nikon HEIF files.

With this, Nikon HEIFs can finally be decoded without failing and the
thumbnails can be extracted into their own files.

Signed-off-by: Eric Joyner <erj@erj.cc>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-17 21:54:03 -03:00
Eric Joyner
fb163eb28b avformat/mov: Support multiple thumbnails in HEIF
Prevents ffmpeg/ffprobe from erroring out when reading an HEIF that
contains multiple hvcC thumbnails (e.g. from a Nikon Z6III camera).

Before, move_read_iref_thmb() would always override the stored
thmb_item_id in the MOVContext with each new read thumbnail, causing a
stream and item_id mismatch later in mov_parse_heif_items(), resulting
in the "HEIF thumbnail doesn't reference a stream" error message.

To solve this,

- Turn thmb_item_id into an array of IDs because multiple thumbnails can
  exist
- Change check in mov_parse_heif_items() to compare against all stored
  thumbnail IDs to see if any item missing a stream is in the list of
  thumbnail IDs.

Signed-off-by: Eric Joyner <erj@erj.cc>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-17 21:54:03 -03:00
Jack Lau
25e710c61e avformat/whip: force NONBLOCK for rtp
We need to ensure rtp sets NONBLOCK since the dtls
handshake has potentially overriden the sockets mode.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 14:33:47 +02:00
Timo Rothenpieler
e6d2c67cd0 avformat/tls_openssl: avoid unusual inline-if style 2025-07-17 14:06:07 +02:00
Jack Lau
abb274b154 avformat/tls_openssl: make tls and dtls use one close function
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 14:04:32 +02:00
Jack Lau
e6af82c498 avformat/tls_openssl: remove all redundant "TLS: " in log with AVClass
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:35:11 +02:00
Jack Lau
dda91b87e8 avformat/tls_openssl: replace 1 with TLS_ST_OK to be more clear
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:35:07 +02:00
Jack Lau
7bd3bdbd62 avformat/whip: free udp socket after dtls free
the SSL_shutdown in tls_close need call the url_bio_bwrite
so we should keep udp still alive

Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:35:01 +02:00
Timo Rothenpieler
95eae5dd50 avformat/tls_openssl: unset nonblock flag on correct URLContext during dtls handshake
The internal BIO functions do not in fact look at this flag, only the outer
tls_read and tls_write functions do.
2025-07-17 02:20:34 +02:00
Jack Lau
7afe1167e5 avformat/tls_openssl: set tlsext host name after init ssl
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:04:38 +02:00
Timo Rothenpieler
9015d595a1 avformat/flvdec: don't skip backwards or over EOF
Skipping backwards (and even forwards) resets the EOF flag, and can thus
lead to infinite looping if the conditions are just right.

Fixes: Infinite loop
Fixes: 427538726/clusterfuzz-testcase-minimized-ffmpeg_dem_FLV_fuzzer-6582567304495104

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-16 19:05:51 +02:00
Timo Rothenpieler
483e509169 avformat/tls_openssl: automatically generate self-signed certificate when none is provided in listen mode 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
454f161b4b avformat/tls_openssl: make generating fingerprints optional 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
40ce64eae7 avformat/tls_openssl: don't expose deprecated EC_KEY outside of its function 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
5339db2cf4 avformat/tls_openssl: properly free generated/read keys and certificates 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
49badc8689 avformat/tls_openssl: don't enable read_ahead in dtls mode
OpenSSL docs say:
These functions have no impact when used with DTLS.
2025-07-16 18:46:55 +02:00
Timo Rothenpieler
31abcc1505 avformar/tls_openssl: use correct info callback in DTLS mode 2025-07-16 18:46:55 +02:00