Commit Graph

1637 Commits

Author SHA1 Message Date
Kacper Michajłow bdbeecbc11 demux_lavf: select non-empty edition by default
Some files, that are stripped from programs without edition program
table expose all old programs, that are not usable. Try to select the
one that actually has tracks.

Fixes: https://github.com/mpv-player/mpv/issues/18053#issuecomment-4607524402
2026-06-03 18:56:23 +02:00
Kacper Michajłow 18d38d4f3e demux: don't mark mid-stream cache ranges as BOF
queue->is_bof is set optimistically after a seek to start, assuming
demuxing began at the start of the file. That is wrong for streams
opened mid-content, which can happen in unfinished event HLS playlists,
which starts at live-edge, but the seekable range in the past is still
valid.

For full support this also require change in lavf [1] to fix the overall
duration of the stream and seeking.

[1] https://code.ffmpeg.org/FFmpeg/FFmpeg/commit/6d98a9a2e8757d6eb616501ade06877389a31597

Fixes: #11990
2026-06-02 08:35:31 +02:00
Kacper Michajłow f239c2dd76 demux_lavf: migrate to AVStreamGroupLayeredVideo 2026-06-01 12:28:16 +02:00
llyyr d521821573 demux_cue: fix audio file lookup inside subdirectory
The FILE field in a CUE sheet may contain a relative path with
subdirectories. It's not clear if this usecase is intended to be
supported, as none of the usual CD/DVD ripping tool generates this type
of FILE field in the CUE sheet. The specification is old and abandoned,
so this will likely never be clarified and it doesn't cost much to
support it so might as well...
2026-05-20 23:22:18 +02:00
Guido Cella 3d111fbf1e demux_libarchive: apply --directory-filter-types to files in archives
Fixes #17931.
2026-05-20 23:15:44 +02:00
Kacper Michajłow b14d8f5ee1 demux_lavf: route nested HTTP opens through the curl backend
Hook AVFormatContext.io_open so HLS/DASH segment fetches and other
nested FFmpeg I/O go through stream_http when libcurl is available.
This lets segments inherit the connection reuse, HTTP/2 multiplexing,
mid-stream resume and conditional compression of the top-level stream.

Falls back to FFmpeg's default I/O for non-HTTP URLs and when the curl
backend is not built in.
2026-05-16 18:20:42 +02:00
Guido Cella aa57714b63 video: merge the tiles of grid heif and avif images
Fixes #13585.
Fixes #14982.
Fixes #16486.
2026-05-13 14:55:48 +02:00
Kacper Michajłow 8c76342a52 demux: select all tracks represented by the stream group 2026-05-13 14:02:10 +02:00
Kacper Michajłow 1095d85b51 demux/stheader: add sh_stream_group representing stream group 2026-05-13 14:02:10 +02:00
Kacper Michajłow e0eb42c303 demux: add --demuxer-hysteresis-bytes
Fixes: https://github.com/mpv-player/mpv/discussions/17888#discussioncomment-16852506
2026-05-08 17:27:13 +02:00
Kacper Michajłow 09900a0ff0 demux/packet_pool: incrementally free old packets on pop
Until now the pool only released its packets on shutdown or when the
cache size was reduced at runtime, so it kept growing across a session.
The amount of packets would be indirectly bound by demuxer cache size,
else the packets are reused. Still over long playback or switching
files, this may give impression of elevated memory usage, or even memory
leak. This was particularly visible with cache-on-disk, where users
reasonably expect RAM usage to stay low.

Pop now keeps the first POOL_HOT_RESERVE packets at the head of the
freelist for fast reuse, and frees up to POOL_GC_BATCH packets from
beyond that on each call. Bulk pushes (e.g. cache reset on file end)
remain no-work policy. The pool drains across subsequent allocations
rather than stalling on a single huge free. Self-balancing without any
size tracking.

This drains the pool in steady state. Note that on file switch we
effectively reuse only ~N / POOL_GC_BATCH packets from the old cache,
because each pop reuses just one packet while freeing up to
POOL_GC_BATCH. That's fine, both free and alloc calls are throttled to
the same per-pop rate, so allocator pressure stays bounded even though
not all packets get reused.
2026-05-08 14:43:36 +02:00
Kacper Michajłow cdbe01c3db demux_lavf: add support for stream groups
Currently none of them are fully supported, but at least mark dependent
tracks as such.
2026-05-01 11:44:26 +02:00
Kacper Michajłow f5857d3b87 demux_lavf: support multiple program mappings per stream
Each stream can belong to multiple programs, we have to support that.
Previously track could belong only to single program.
2026-05-01 11:41:31 +02:00
Kacper Michajłow b4a7ea306e demux_{lavf,timeline}: add --flatten-editions
Lavf exposes programs/renditions as a flat track list tagged with
program_id. We respect this metadata and group tracks into their
respective programs, as tracks from different programs may be completely
unrelated to each other.

This commits adds an option to flatten the editions and ignore the
grouping.

Fixes: https://github.com/mpv-player/mpv/issues/17836#issuecomment-4345930205
2026-05-01 10:42:00 +02:00
Kacper Michajłow 8aef2c9162 demux_lavf: map comment to stream title
Lavf HLS demmuxer put rendition names into `comment`, this is basically
a title in our usage.
2026-05-01 06:09:27 +02:00
Kacper Michajłow ec03ef7e97 demux_lavf: remove track flags duplication from title
Those flags are already exposed, and users can format it as they wont.
Don't produce some dummy titles.
2026-05-01 06:09:27 +02:00
Kacper Michajłow 2f58ee36ce demux/packet: refactor demux_packet_add_blockadditional
Make it more extensible for future additions.
2026-05-01 00:38:04 +02:00
Kacper Michajłow 696190d25b demux/packet: add support for LCEVC ITU-T35 payloads 2026-05-01 00:38:04 +02:00
Kacper Michajłow 5ebe9581d5 demux_{lavf,timeline}: consider audio only HLS when selecting edition
Fixes: #17836
2026-04-29 19:23:42 +02:00
Kacper Michajłow 91b6d8fdd1 demux: enrich edition titles with codec/resolution/bitrate info
Extract the codec descriptor out of mp_format_track_metadata into a
shared demux_append_codec_desc() helper, and use it from a new
demux_compose_edition_title() composer that both demux_timeline.c and
demux_lavf.c call when building editions. Codec block is only added
when the program has exactly one stream of that kind, and fields
already present in the prefix (e.g. WxH from yt-dlp's format label)
are skipped to avoid duplication.
2026-04-29 03:45:05 +02:00
alydev d40a29190d demux_playlist: add support for 'strm' playlist
The .strm format consists of a URI or local path as the sole contents
of a text file, this is parsed by software like Emby or Jellyfin to
treat remote streams or paths as if they are in the local filesystem.
This commit adds .strm to mpv's internal list of playlist file formats,
and points it to the handler for .m3u files as they should be
compatible. .strm doesn't need all the features of .m3u/.m3u8, but the
features do not cause issues with the relatively barebones playlist
format of .strm.
2026-04-22 03:23:50 +02:00
Kacper Michajłow 1be21a3186 demux_timeline: prefer editions with default video track
When the EDL marks a video track with flags=default, select the edition
whose video stream carries that flag.
2026-04-20 03:04:25 +02:00
llyyr ac852ab9df demux/packet: fix version check for SMPTE 2094-50 metadata
This enum was added in lavc 62.30.100 in https://github.com/ffmpeg/ffmpeg/commit/7faa6ee2aa01
The doc/APIchanges version listed in that commit is incorrect, it's
actually lavc 62 not lavc 60.

Fixes build failure with ffmpeg between
https://github.com/ffmpeg/ffmpeg/commit/6ba6db4f195c and https://github.com/ffmpeg/ffmpeg/commit/7faa6ee2aa01

Fixes: 76df24f40c ("demux/packet: add support for SMPTE 2094-50 metadata")
2026-04-19 16:11:38 +02:00
Kacper Michajłow 76df24f40c demux/packet: add support for SMPTE 2094-50 metadata 2026-04-18 05:38:40 +02:00
Guido Cella f4dcd295cf demux_edl: support global_tags with delay_open
The delay_open mechanism used by
--script-opt=ytdl_hook-all_formats=yes breaks setting metadata with
global_tags because tl->track_layout is NULL. See adcf51dccd cbb8f534b0
8ea7aa5471.

Fix this by applying tags to the EDL timeline in this case.

Tags must still be applied to tl->track_layout when available for them
to work with local EDL files.
2026-04-17 19:24:47 +02:00
Kacper Michajłow cc9610b850 demux_timeline: add support for programs 2026-04-17 18:30:43 +02:00
Kacper Michajłow 6c165fe46e demux_lavf: add support for programs
This adds proper support for MPEG-TS programs and HLS variants. Now
program selection is exposed as editions and tracks are grouped under
such edition. If there are external tracks added, they are available in
all editions.
2026-04-17 18:30:43 +02:00
nanahi 3d568495fc misc/bstr: move str_in_list to this file
Rename it to bstr_in_list0 and implement it in bstr_find_in_list0.
2026-04-17 04:09:23 +02:00
nanahi da2739f44f various: don't check if endptr is null for strto[udll]
These functions always set endptr to non-null so there is no need to
check.
2026-04-17 04:09:23 +02:00
NRK e2180e581e demux_playlist: only autocreate on regular file
trying to autocreate playlist when the file is a fifo breaks
playback. the bug report is a special case of `/dev/fd/*` but
even for named fifos, opening and closing them can cause the
other end to stop writing.

Closes: https://github.com/mpv-player/mpv/issues/17682
2026-04-06 18:50:28 +02:00
nanahi e45f86225f demux_playlist: don't get config group again when checking shuffle
The shuffle option is already available as p->mp_opts->shuffle since
44a3a3293f.
There is no reason to get the config group again and free it.
2026-03-30 00:07:45 +00:00
Kacper Michajłow 9339a68dfb demux_lavf: mark packets with keyframe for wrapped avframes too 2026-03-23 13:29:59 +01:00
Rudi Heitbaum 8ace278cbe various: fix Wdiscarded-qualifiers warnings
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
2026-03-15 14:49:00 +01:00
nanahi 3eb8f9a1de demux_lavf: get codec info from AVCodecParameters
This allows displaying codec info for all tracks without selecting the
track.
2026-02-24 19:36:33 +01:00
nanahi 4e2f3ce4b9 command: add track-list/N/demux-duration property 2026-02-24 19:36:33 +01:00
nanahi e6bd564723 demux_lavf: also make demux-bitrate available for video
Make it available as a property and on stats page 5.
2026-02-24 19:36:33 +01:00
Simon Bruder 534b2d2ea6 {demux,player}: expose original and commentary track flags
Those flags were added to the Matroska specification together with the
already implemented hearing-impaired and visual-impaired flags.

They allow specifying whether a track is a commentary track or in the
original language without relying on the free-form track name, which
makes consistent tagging and parsing by machines easier.

Ref: https://github.com/ietf-wg-cellar/matroska-specification/pull/447
Ref: https://www.rfc-editor.org/rfc/rfc9559#name-original-flag
Ref: https://www.rfc-editor.org/rfc/rfc9559#name-commentary-flag
2026-02-20 20:31:04 +01:00
llyyr a7523a4afd demux_mf: satisfy gcc ubsan so it doesn't produce bogus warnings
Since we call bstr0 on the string anyway, might as well use it for
printing which implicitly includes a null check that gcc can see so it
doesn't produce the warning as seen in the next commit anymore
2026-02-14 00:43:52 +01:00
Kacper Michajłow 54da0ba070 demux/packet_pool: unref packet early if we can do it without penalty 2026-01-28 18:40:19 +01:00
Kacper Michajłow a1ea4f3aec demux/packet_pool: always return default packet state from pop
This is not functional change, as pop() is only used in packet_create()
which already cleared the packet, but it's better to make it explcit.
2026-01-28 18:40:19 +01:00
Kacper Michajłow 3b17ab5d3b demux/packet: add demux_packet_unref helper 2026-01-28 18:40:19 +01:00
Guido Cella bbcd68f8ed demux_playlist: expand tilde placeholders in playlist files
This allows playing something like an m3u containing ~/foo.mp4 or
~~/foo.mp4.

URLs like memory://#EXTM3U\n~/foo.mp4 also work.
2026-01-12 15:10:37 +00:00
Guido Cella fc86b96a8a various: don't normalize playlist filenames again
Since the previous commit normalized playlist filenames when they are
stored, the code normalizing them can be simplified back to how it was
before implementing normalization.
2026-01-12 15:10:37 +00:00
Guido Cella 2871471f31 demux_playlist: add base paths when adding playlist entries
Currently entries in playlist files like m3u are first added to the
playlist, and then if they were relative paths the playlist file's
dirname is prepended to them.

Change it to directly add entries with the correct path. This will be
needed to normalize playlist entries as soon as they are added, else
normalization would prepend the working directory to entries with
relative paths.

demux_cue, demux_edl and demux_mkv_timeline don't need to be modified to
work with the next commit.
2026-01-12 15:10:37 +00:00
Hubert Głuchowski 2ed355f51f demux/demux_sbr: re-emit packet after seek 2025-12-23 07:01:29 +01:00
Hubert Głuchowski 2b78ac44a9 demux/demux_sbr: allow configuring probe size 2025-12-23 07:01:29 +01:00
Hubert Głuchowski bb97882c9a sub: add subrandr renderer support
subrandr is a subtitle rendering library which aims to render
SRV3 (YouTube) subtitles and WebVTT subtitles accurately.

Currently in mpv WebVTT subs are rendered via ffmpeg conversion to ASS
which throws away a lot of the style and completely disregards
the WebVTT non-region-cue positioning algorithm. Furthermore if
one wants to render some more complex SRV3 subtitles one has to
resort to external converters since it's not even supported by ffmpeg.

However subrandr is able to render SRV3 subtitles natively with support
for the most commonly used features. It can render ruby text without
relying on font metrics during conversion which is obviously fragile,
and it can perform correct scaling using the exact calculations used by
YouTube instead of making up ASS approximations. Similarly it follows
the WebVTT spec for the features of WebVTT that it supports (mostly).

It's not perfect of course and there's still many things it doesn't do
or does wrong but those are things that can be incrementally improved
outside of mpv.
2025-12-23 07:01:29 +01:00
sfan5 584b368972 demux_playlist: clarify reason for HLS detection
see 0b1c3e8de2
2025-11-30 17:21:28 +01:00
sfan5 2ad27be8be demux_lavf: remove 'bin' format from blacklist
A probing function was implemented in ffmpeg 4.0:
<https://github.com/FFmpeg/FFmpeg/commit/8f6a71f7f13d21614f5140e672976e96dca04af8>
2025-11-30 17:21:28 +01:00
Kacper Michajłow 52525dceb8 demux: clear packet pool when upper memory limit is lowered
This clears packets from the pool, that would never be reused under new
settings. Note that depending on demuxer state this clears only unused
packets, in some cases demuxer may still hold more packets than the new
limit. Fox example demuxer doesn't forcefully clear forward cache when
reducing the size.

Also keep packet pool, even if current file is not cached, this is
useful for all sorts of things and may be useful for next file.

This act only on user options values, regardless of internal demuxer
caching state, which can vary depending on track type or source.
2025-11-20 20:35:00 +01:00