1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00

27464 Commits

Author SHA1 Message Date
Michael Niedermayer
d66e84695b Bump minor after release/9.0 branch on master
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:47:51 +02:00
Michael Niedermayer
47e9d68e20 Bump minor for release/9.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:43:34 +02:00
Niklas Haas
e5a3c5e409 avformat/http: accept case-insensitive Connection header value
RFC 9110 defines this as case-insensitive, and some servers (e.g. MythTV)
send it as "Close" instead of "close".

See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/23222
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 15:50:43 +00:00
Niklas Haas
bd51105806 avformat/http: infer default s->willclose based on request header
If we send `Connection: close` but don't get any response Connection header
back from the HTTP server, we should still assume the server will close our
connection.

There is a minor bit of ambiguity about what state to assume if the user
overrode the "Connection:" header, but I'm optimistically leaning in
favor of keep-alive as the more likely value for a user to set.

Not updating our internal state tracking as a result of user-provided
headers overriding our own headers is a prior problem with http.c that is
outside the scope of this PR to fix.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 15:50:43 +00:00
Martin Storsjö
1499c4ac6d avformat/tls_openssl: Add a missing <string.h> include
This is needed when building with OpenSSL enabled on macOS after
c32a719cb2.

The tls_openssl.c contains a number of explicit calls to strlen(),
which require including <string.h>.
2026-06-25 15:34:04 +03:00
Marton Balint
18d164a573 avformat/asfdec_f: do not truncate get_value result
Also change the function to return 0 on error, this is a more sensible error
value for aspect ratios anyway.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:54 +02:00
Marton Balint
99aab32380 avformat/asfdec_f: simplify get_tag/get_value usage
get_tag() only behaves differently for the BOOLs of Extended Content
Description Object, so lets adjust the type there instead of passing BOOL width
for all calls. Similar to what asfdec_o does.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:54 +02:00
Marton Balint
dab1ac3e6e avformat/utils: fix ff_dict_set_timestamp() with negative timestamps
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint
c434d0a160 avformat/asfdec_f: set creation time as metadata
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint
2bbf0da31a avformat/asfdec_o: use common function for setting creation time
This also increases precision.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint
83c6534d5a avformat/asfenc: use common function for timestamp conversion
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint
2d2a810294 avformat/wtvdec: use ISO timestamps with timezone and higher precision
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint
2b1cf52dbe avformat/asf: add helper functions to convert between filetime and avtime
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint
ce104d1054 avformat/asfdec_o: fix EOF check in read_header
Since d1ac645636 ff_get_guid() never returns
EOF. This change completely broke the asfdec_o demuxer returning failure on
every file.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Marton Balint
3e4acff3aa avformat/asfdec_o: remove constants already defined in asf.h
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-06-24 23:31:53 +02:00
Kacper Michajłow
dc953a19e6 avformat/hlsenc: initialize avg_bandwidth
Fixes use of uninitialized value and dumping it into AVERAGE-BANDWIDTH
in playlist. Note this will be correctly set when we are at final
segment, otherwise it's optional.

Fixes: fate-hls-seek test on MSAN build

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-24 02:04:02 +00:00
James Almer
579edeabec avformat/movenc: look for remainder samples in packet side data
Sometimes the duration itself reflects the remainder samples by being set to a
value lower than the frame size, but in other cases it's done only through
a discard padding value in side data.
Take the latter into account when calculating durations.

Fixes issue #23532.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-23 20:07:25 -03:00
James Almer
661dd0ffd5 avformat/movenc: use track timescale when making up a tmcd track pts
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-23 20:07:25 -03:00
James Almer
0559f92adc avformat/movenc: don't derive tmcd track durations if they were copied
This behavior only applies to tracks created by the muxer.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-23 20:07:25 -03:00
Kacper Michajłow
50209cd0c0 avformat/hls: advance first_timestamp once per live window slide
Anchor c->first_timestamp to the playlist that established it and only let
that playlist's expiring segments advance it, so it slides exactly once
per window slide.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:28 +02:00
Kacper Michajłow
e27ad5760c avformat/hls: rebase seek discard threshold to each playlist's DTS baseline
After a seek, hls_read_packet drops packets until each playlist reaches
seek_timestamp. That threshold lives on c->first_timestamp's baseline,
i.e. the DTS of whichever stream produced the very first packet. Streams
can have different DTS baselines though. So comparing one stream's
threshold against another stream's DTS is wrong. A stream whose first
keyframe precedes the global baseline gets its segment keyframe dropped
and resumes a segment (or more) late.

Track the first DTS per playlist and rebase the threshold onto each
playlist's own baseline. Since HLS segments are presentation-aligned
across renditions, every stream then resumes at the same presentation
time. seek_timestamp keeps its meaning on the global timeline, only the
per-playlist comparison value is translated.

This fixes playlists that would be unable to play from the start, and
instead skip one or more segments, before data is output.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:28 +02:00
Kacper Michajłow
caa3fa6af0 avformat/hls: fix seeking to before the first timestamp
find_timestamp_in_playlist() already selects the first segment when the
target is below the playlist's first timestamp, but returns 0.
hls_read_seek() treats that as a failure, and all seek operation is
failed.

This breaks seeking to the very start whenever the requested timestamp
is slightly below the first one. Clamp such targets to the first segment
and report success instead.

Fixes: https://github.com/mpv-player/mpv/issues/14840#issuecomment-4703186169
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:28 +02:00
Kacper Michajłow
0616685b1e avformat/hls: reuse the open connection for contiguous byte-range segments
CMAF and other EXT-X-BYTERANGE playlists address consecutive segments as
contiguous byte ranges of a single resource. Each segment was fetched with
a separate bounded request, paying a request/response round-trip per
segment even though the connection was kept alive.

Keep the AVIOContext open across segments of the same resource and seek to
the next segment instead of reopening, for contiguous ranges the seek
targets the current position and issues no request in practice.

Non-contiguous, encrypted and non-seekable cases fall back to the
previous reopen behaviour.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:28 +02:00
Kacper Michajłow
54f0296dfe avformat/hls: deduplicate playlists shared by multiple variants
Master playlists can reference the same media playlist URI from several
rendition group. new_playlist() allocated a separate playlist struct for
each reference, this is unndeded work and we can fold duplicates into
single probe.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-23 20:40:28 +02:00
Niklas Haas
f87323a359 avformat/http: properly fall back on soft seek failure
If the HTTP server still has stale bytes in the TCP receive buffer, but
the underlying conection was already closed, then the http_open_cnx()
call might fail even though we successfully drained the previous request.

In this case, there is no proper fallback to a new connection, leading to
sudden truncation.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 20:33:00 +02:00
Niklas Haas
0d0f9a06ab avformat/http: only re-use old connection if valid
Otherwise, this might leak stale bytes that were already drained by the
HTTP soft-seek attempt.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 20:33:00 +02:00
Niklas Haas
62006041cc avformat/http: don't return EOF unless we actually read all bytes
Otherwise, this masquerades failure due to I/O as legitimate EOFs.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 20:33:00 +02:00
Niklas Haas
557ab6f2ab avformat/http: make short-seek logic more robust
This avoids an underflow if short_seek is negative (which can happen if e.g.
ffurl_get_short_seek() returns AVERROR(ENOSYS)), as well as a possible
underflow if the read position is somehow past `range_end` (e.g. if the HTTP
server malicously lied about the content range but gave us more bytes anyway)

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 20:33:00 +02:00
Niklas Haas
8712114200 avformat/http: properly re-set s->range_end before requests
Otherwise this could leak stale values from a previous response.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 20:33:00 +02:00
Andreas Rheinhardt
762b94e672 libs: Bump major version of all libraries
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Michael Niedermayer
54849fe663 avcodec/avformat: Unavpriv avpriv_packet_list_*()
The avpriv_packet_list_put/get/free() functions and the PacketList type
were implemented in libavcodec and exported via the avpriv_ mechanism
solely so that libavformat (and decklink in libavdevice) could use them;
libavcodec itself has no users of them. Exporting them across the library
boundary has the usual drawbacks for shared builds (export/import overhead
and having to keep them around for ABI stability even once unneeded).

Move the implementation and the PacketList/PacketListEntry types to
libavformat and rename the functions to ff_packet_list_*(). libavformat is
the primary user and compiles the new packet_list.c directly; decklink,
the only libavdevice user, gets a private copy for shared builds via the
SHLIBOBJS scheme already used for reverse.o and ccfifo.o (static builds
resolve the symbols from libavformat).

AVPACKET_IS_EMPTY() and ff_side_data_set_prft() remain in
libavcodec/packet_internal.h as they are libavcodec-internal.
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
c32a719cb2 avutil: Remove FF_API_OPT_INT_LIST
Deprecated on 2024-09-30.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
c85b83f8df avcodec: Remove FF_API_CODEC_PROPS
Deprecated since 2025-01-05.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
0438966d84 avcodec: Remove FF_API_V408_CODECID
Deprecated on 2024-10-12.
The output of the v410enc test changes because padding bits
are now filled with 1s instead of zeroes and because
bits_per_coded_sample changes to 30 (from 32), see
https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22455#issuecomment-46213.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:13:06 +02:00
Andreas Rheinhardt
6d2d1f3f32 avformat/oggenc: Remove deprecated pagesize option
Deprecated in commit 59220d559b.
on 2013-01-08.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt
9549c9ad79 avformat/tls: Remove FF_API_NO_DEFAULT_TLS_VERIFY
The decision to switch to checking peer certificates by default
at the next major version bump was announced on 2025-08-09
in commit 5621eee672.

Thanks to Michael Niedermayer for pointing out that the documentation
needs to be updated, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt
5aba289032 avformat: Remove FF_API_INTERNAL_TIMING
Deprecated since 2024-07-09.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt
c78350af98 avformat/hlsenc: Forward AVFormatContext.flags
Needed for AVFMT_FLAG_BITEXACT.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:05:02 +02:00
Jack Lau
a9e27e2e0c avformat/tls_{openssl,mbedtls}: parse host when external_sock is true
See 28b92b9b2e

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-06-23 22:44:20 +08:00
Jack Lau
e2eee22f16 avformat/tls_openssl: refactor dtls_start() to use common code
Removing the dtls_start() and create a simple dtls_open()
wrapper that just set s->is_dtls and call tls_open() to
use common code.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-06-23 22:44:20 +08:00
Jack Lau
b7db2538f6 avformat/tls_openssl: copy the dtls code into tls_open()
This is first step for moving dtls related code
into tls_open() to make sure they can use common
code in one function.

Next patch should be removing dtls_start() and create
a simple dtls_open() wrapper (set is_dtls and then call
tls_open()) just like GnuTLS.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-06-23 22:44:20 +08:00
Stefan Breunig
de4cfe98b6 avformat/hlsenc: clean up unused keyframe tracking variables 2026-06-23 00:04:42 +00:00
Stefan Breunig
ea3d417d90 avformat/hlsplaylist: fix byte offsets for single_file+iframes_only
fix ticket: 8636

video_keyframe_size and video_keyframe_pos tracked the end of the
previous P/B frame. In the case of I-frame only videos, this would
result in byteoffsets always being 0@0 in the case of fmp4. For
mpegts, the size would be correct but the pos still always be @0.

Since size and pos already correctly track the start of a segment,
we can re-use them even in I-frame only mode.
2026-06-23 00:04:42 +00:00
James Almer
62731e05ab avformat/mov: don't assume a sample to be the last in fragmented input
Both the seek index and the stream duration are constantly being updated as
trun boxes are read.

Fixes mpv issue 18149.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-18 13:46:54 -03:00
Michael Niedermayer
c098b07035 avformat/movenc: initialize all tracks
Fixes: NULL pointer dereference

As a sideeffect this also sets the timescale correctly if an
intermediate matches MOV_TIMESCALE_Q, the previous code stoped
in that case as it could not distinguish it from the overflow detection

Regression since: 51f5f60443

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-18 12:04:39 +00:00
Romain Beauxis
e8cfe912f4 avformat/hls: Also report stream-level metadata update. 2026-06-17 15:39:33 -05:00
Zhao Zhili
5c2f9899df avformat/matroskaenc: fix error code on LCEVC payload allocation failure
The branch returned the ret variable when av_malloc() failed, but ret
is uninitialized at that point unless an earlier branch happened to
set it.
2026-06-17 11:11:18 +00:00
James Almer
491e0d1cfb avformat/matroskaenc: write LCEVC payloads as ITU-T T35 block additional
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 10:20:33 -03:00
James Almer
44d7755f7e avformat/mov: export initial padding
Some muxers, like Matroska, use it to write priming samples.

fate-segment-adts-to-mkv no longer uses the ref file from
fate-segment-adts-to-mkv-header-all as it's demuxed through the hls demuxer
and this commit exposed a bug where initial padding is not being propagated.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:24 -03:00
James Almer
da04251772 avformat/mov: export information about the last actual sample in a stream
This way the generic demux code can calculate how many trimming samples should
be discarded.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-16 09:18:24 -03:00