1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00
Commit Graph

26842 Commits

Author SHA1 Message Date
Michael Niedermayer
b518c027a0 avformat/http: Fix off by 1 error
Fixes: out of array access
Fixes: zeropath/off-by-one-one-byte

Found-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 02:26:36 +01:00
Zhao Zhili
632958d2bf avformat/mov: log unknown tag via av_fourcc2str
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-05 23:45:31 +08:00
Zhao Zhili
07581d6736 avformat/mov: check prji box version and flags
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-05 23:45:31 +08:00
Zhao Zhili
0734d1c55a avformat/mov: relax check on proj box size
Pico VR adds a '\0' after projection_type (a real C string than
a fourcc). It's not strictly correct, but doesn't affect parsing.

[prji: Projection Information Box]
    position = 149574743
    size = 17
    version = 0
    flags = 0x000000
    projection_type = rect

Co-Authored-by: Keven Ma
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-05 23:45:31 +08:00
Martin Storsjö
8313dc1120 movenc: Make hybrid_fragmented retain the fragmented form headers
This makes the final file truly hybrid: Externally the file
is a regular, non-fragmented file, but internally, the fragmented
form also exists un-overwritten.

To make any use of that, first, the fragments need to be muxed in
a position independent form, i.e. with empty_moov+default_base_moof
(or the dash or cmaf meta-flags).

Making use of the fragmented form when the file is finalized is
not entirely obvious though. One can dump the contents of the
single mdat box, and get the fragmented form. (This is a neat
trick, but not something that anybody really is expected to
want to do.)

The main expected use case is accessing fragments in the form of
byte range segments, for e.g. HLS.

Previously, the start of the file would look like this:

- ftyp
- free
- moov
 - (moov contents)

After finalizing the file, it would look like this:

- ftyp
- free
- mdat (previously moov)
 - (moov contents)

In this form, the size and type of the original moov box were
overwritten, and the original moov contents is just leftover
as unused data in the mdat box.

To avoid this issue, the start of the file now looks like this:

- ftyp
- free
- free
 - ftyp
- moov
 - (moov contents)

The second, hidden ftyp box inside mdat, would normally never be
seen.

After finalizing, the difference is that the mdat box now is
extended to cover the ftyp and the whole moov including its header
(and all the following fragments).

I.e., the start of the file looks like this:

- ftyp
- free
- mdat
 - ftyp
 - moov
  - (moov contents)

This allows accessing the "ftyp+moov" pair sequentially as such,
with a byte range - this range is untouched when finalizing,
producing the same ftyp+moov pair both while writing, when the
file is fragmented, and after finalizing, when the file is
transformed to non-fragmented externally.

Note; the sequential two "free+free" boxes may look slightly
silly; it could be tempting to make the second one an mdat
from the get-go. However, some players of fragmented mp4 (in
particular, Apple's HLS player) bail out if the initialization
segment contains an mdat box - therefore, use a free box.

It could also be possible to use just one single free box with
8 bytes of padding at the start - but that would require more
changes to the finalization logic.

For a segmenting user of the muxer, the only unclarity is how
to determine the right byte range for the internal ftyp+moov
pair. Currently, this requires parsing the muxer output and skip
past anything up to the start of the non-empty free box.
2025-11-04 10:23:31 +00:00
Michael Niedermayer
5b98cea4bf avformat/sctp: Check size in sctp_write()
Fixes: out of array access
No testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-01 23:22:32 +01:00
Michael Niedermayer
83e0298de2 avformat/rtmpproto: consider command line argument lengths
Fixes: out of array access
Fixes: zeropath/rtmp-2025-10

Found-by: Joshua Rogers <joshua@joshua.hu>
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-01 19:54:07 +01:00
Michael Niedermayer
a64e037429 avformat/rtmpproto_ Check tcurl and flashver length
Fixes: out of array accesses

Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-01 19:53:46 +01:00
lholliger
e59d964a3c libavformat/mov: add support for name udta
In the QTFF documentation for udta/"user data atoms", "name" is a
valid entry for "name of object" however it is currently skipped
leading to some missing metadata when copying for some files. This
isn't classified the same as "(C)nam" which is "Title of content"
so they aren't necessarily the same.
2025-10-31 14:28:23 +00:00
Desmond Liu
4348bde2d2 libavformat/udp: Fix call to recvfrom(2)
Last parameter to recvfrom() is not initialized, causing
recvfrom() to randomly return EINVAL. Issue was introduced in
af04a27893.
2025-10-30 17:22:12 -07:00
Michael Niedermayer
d03483bd26 avformat/rtpenc_h264_hevc: Check space for nal_length_size in ff_rtp_send_h264_hevc()
Fixes: memcpy with negative size
Fixes: momo_trip-poc/input

Reported-by: Momoko Shiraishi <shiraishi@os.is.s.u-tokyo.ac.jp>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-30 01:24:23 +01:00
Baptiste Coudurier
1025beeef1 lavf/id3v2: allow empty strings without bom, fixes #20597 2025-10-28 10:59:25 -07:00
James Almer
c7a2b31f84 avformat/demux: pass new extradata to the parser
The parser API doesn't work with packets, only raw data, so in order for it to
be made aware of new extradata propagated through packet side data we need to
pass it in some other form, namely, replacing the main extradata and ensuring
it will be parsed by restarting the parser.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-28 10:10:22 -03:00
Chris Hodges
d12791ef7f libavformat: fix rtpdec_av1 regarding OBU size
Fix the AV1 RTP depacketizer for instances where the OBU elements
did not have their OBU size fields removed according to the
recommendation (SHOULD) of the AV1 RTP specification.

Roger Hardiman courteously reported that the depacketizer doesn't
work correctly for fragmented OBU elements with their OBU size
fields still present and will incorrectly state that the
continuation of such a fragment was unexpected, because the
frag_obu_size field was used as a state and only incremented
when the size field needed to be updated on OBU size field
restoration. This patch solves the slip.

Change-Id: I95af8cc89862e8ecf79aabcf029dd95a20dfd7ad
2025-10-27 22:11:58 +00:00
James Almer
e10473f13e avformat/matroskadec: relax the check for cropped dimensions
There seem to be samples with no Video element on video tracks in the wild,
which even if not spec compliant, can be demuxed fine after lavf probes the
stream with a decoder/parser.
Relax the check to allow tracks with no dimensions to work, and also add a
check for strict spec compliance to maintain the current behavior if desired.

Fixes issue #20649.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-27 15:54:22 -03:00
Anthony Bajoua
68152978b5 libavformat/movenc: Output ftyp atom with hybrid_fragmented+delay_moov 2025-10-27 09:06:06 +00:00
averne
23df9d4172 avcodec/prores: add parser
Introduce a basic parser for ProRes frame headers.
This avoid having to decode an entire frame to
extract codec information.
2025-10-25 19:56:44 +00:00
Anders Rein
f5f72b4f8a Fix incorrect extraction of Origin
The code that attempted to extract origin (4B.02) was put in the wrong
metadata handler and was also read as the wrong integer type. According
ST 377-1 Origin is of type "Position" (Int64) in the Timeline Track, not
a 8 bit unsigned integer in the Sequence.
2025-10-25 19:22:48 +00:00
Kacper Michajłow
a2b47ccfbf avcodec/{png,mov}enc: use EOTF gamma approximation for gAMA chunk
This is how images encoded with specific transfer function should be
viewed. Image viewers that doesn't support named trc metadata, will
fallback to simple gAMA value and both of those cases should produce the
same image apperance for the viewer.

Fixes: https://github.com/mpv-player/mpv/issues/13438

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-24 22:24:54 +00:00
Baptiste Coudurier
7f7335ec43 lavf/mxfenc: fix muxing for DNxHD/DNxHR 444 2025-10-24 00:16:21 +00:00
Baptiste Coudurier
548bdee8db lavf/mxfenc: factorize cdci descriptor functions 2025-10-24 00:16:21 +00:00
Baptiste Coudurier
48c6b8a907 lavf/mxfenc: fix return value to int64_t 2025-10-24 00:16:21 +00:00
Baptiste Coudurier
1cd3f61ad8 lavf/mxfenc: correctly add jpeg2000 subdescriptor reference in cdci, factorize 2025-10-24 00:16:21 +00:00
Baptiste Coudurier
cfcd996575 lavf/mxfenc: remove cdci pixel format specific values from stream context 2025-10-24 00:16:21 +00:00
Baptiste Coudurier
06b04da4dc lavf/mxfenc: require pixel format to be set for video streams 2025-10-24 00:16:21 +00:00
Baptiste Coudurier
0b0cb7cd6c lavf/movenc: improve AVdh atom generation for DNxHD/DNxHR 2025-10-24 00:16:21 +00:00
Jack Lau
cb5e201f5c avformat/whip: cleanup the redundant variable
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-23 10:58:45 +00:00
Jack Lau
0e8cff52bc avformat/whip: add DTLS active role support
Add dtls_active flag to specify the dtls role.

Properly set the send key and recv key depends on DTLS role:

As DTLS server, the recv key is client master key plus salt,
the send key is server master key plus salt.
As DTLS client, the recv key is server master key plus salt,
the send key is client master key plus salt.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-23 10:58:45 +00:00
Martin Storsjö
e442128944 movenc: Make sure to flush the delayed moov atom for hybrid fragmented
If using the delay_moov flag in combination with hybrid_fragment
(which is a potentially problematic combination otherwise - the
ftyp box does end up hidden in the end), then we need to flush
twice to get both the moov box and the first fragment, if the
file is finished before the first fragment is completed.
2025-10-21 08:38:32 +00:00
Martin Storsjö
27f5561885 movenc: Fix sample clustering for hybrid_fragmented+delay_moov
If samples were available when the moov was written, chunking
for those samples has been done already, which has to be reset
here.

This is the case when not using empty_moov, when the moov box
describes the first fragment - this case was accounted for already.
But if using the delay_moov flag, then those samples also were
available when writing the moov, so chunking for them has already
been done in this case as well.

Therefore, always reset chunking here (it should be harmless to
always do it), and update the comment to clarify the cases
involved here.
2025-10-21 08:38:32 +00:00
Martin Storsjö
36896af64a movenc: Make the hybrid_fragmented mode more robust
Write the moov tag at the end first, before overwriting the mdat size
at the start of the file.

In case writing the final moov box fails (e.g. due to being out
of disk), we haven't broken the initial moov box yet.

Thus if writing stops between these steps, we could end up with
a file with two moov boxes - which arguably is more feasible to
recover from, than from a file with no moov boxes at all.
2025-10-16 18:58:54 +00:00
Zhao Zhili
cd4b01707d Revert "avformat/movenc: sidx earliest_presentation_time is applied after editlist"
This reverts commit 301141b576.

cluster[0].dts, pts and frag_info[0].time are already in presentation
timeline, so they shouldn't be shift by start_pts.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-16 11:22:37 +08:00
Zhao Zhili
0de3b1f358 avformat/mov: don't shift sidx_pts
sidx_pts is already in presentation time, so it shouldn't be shift
by sc->time_offset again.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-16 11:22:37 +08:00
James Almer
2e1d702cfc avformat/dump: fix log level passed to av_log when printing stream group side data
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-15 17:49:11 -03:00
Zhao Zhili
6b961f5963 avformat/mov: fix missing video size when some decoders are disabled
Fix #20667

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-14 20:05:55 +08:00
Jack Lau
b43f8dec18 avformat/whip: add macros to replace magic number
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:32:03 +00:00
Jack Lau
bc6164eb6f avformat/whip: remove WHIP_STATE_DTLS_CONNECTING
This value is only useful when dtls handshake is NONBLOCK mode,
dtls handshake just need to call ffurl_handshake once since it
force block mode.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:32:03 +00:00
Jack Lau
76b13ca0a6 avformat/whip: check the peer whether is ice lite
See RFC 5245 Section 4.3
If an agent is a lite implementation, it MUST include an "a=ice-lite"
session-level attribute in its SDP.  If an agent is a full
implementation, it MUST NOT include this attribute.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:32:03 +00:00
Jack Lau
ec0a04de0d avformat/whip: remind user increase -buffer_size
The udp buffer size might be too small to easily
be full temporarily and return WSAEWOULDBLOCK.
The udp code will handle the windows error code
and convert it to AVERROR(EAGAIN).

This issue just can be reproduced on windows.

If sleep a interval and retry to send pkt when hit
EAGAIN, it will increase latency, and appropriate
interval is hard to define.

So this patch just remind user increase the buffer
size via -buffer_size to avoid this issue.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:55:18 +00:00
Jack Lau
b3793d9941 avformat/whip: pass through buffer_size option to udp
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:55:18 +00:00
Jack Lau
469aad3897 avformat/whip: add ICE consent freshness support
Refer to RFC 9725 4.2,
"Once a session is set up, consent freshness as per
[RFC7675] SHALL be used to detect non-graceful
disconnection by full ICE implementations and DTLS
teardown for session termination by either side"

Refer to RFC 7675,
send STUN Binding request every 5s,
expire consent after 30s without response,
terminate session when the consent expired.

TODO:
Random consent check interval (4-6s) will be
added later.

Co-authored-by: Sergio Garcia Murillo <sergio.garcia.murillo@gmail.com>
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:29:25 +00:00
Jack Lau
aba84db96f avformat/whip: add WHIP_US_PER_MS macro to replace 1000
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:29:25 +00:00
Zhao Zhili
9034ca30ef avformat/flacdec: fix self assign warning 2025-10-09 03:41:29 +00:00
James Almer
660983b7f3 avformat/mccenc: use Lavf version string instead of FFmpeg
The muxed subtitle is created by libavformat, and as such that's what should be
reported. This is in line with the string we write for every other muxer.
After this change, the muxer will no longer be recompiled every time a commit
is made.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-06 11:51:50 -03:00
James Almer
9b709532d5 avformat/demux: don't overwrite container level color information if set
If the information is coded at the container level, then that's what should be
exported. The user will still have access to values coded at the bitstream
level by firing a decoder.

Fixes issue #20121

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 13:22:17 -03:00
Marton Balint
f1d5114103 avformat/tls_openssl: do not cleanup tls after a successful dtls_start()
Regression since 8e11e2cdb8.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-02 18:41:47 +02:00
Zhao Zhili
1a02412170 avformat/movenc_ttml: fix memleaks
Memory leaks can happen on normal case when break from while loop
early, and it can happen on error path with goto cleanup.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-01 22:31:03 +08:00
Romain Beauxis
cb4052beae libavformat/oggparseopus.c: Parse comments from secondary chained streams header packet. 2025-10-01 14:20:55 +00:00
Romain Beauxis
45d7d5d3e2 libavformat/oggparseflac.c: Parse ogg/flac comments in new ogg packets, add them to ogg stream
new_metadata.
2025-10-01 14:20:55 +00:00
Romain Beauxis
7dbf7d2a45 libavformat/oggdec.c: Use AV_PKT_DATA_STRINGS_METADATA to pass metadata updates. 2025-10-01 14:20:55 +00:00