Commit Graph
694 Commits
Author SHA1 Message Date
Kacper Michajłow c6833a9307 stream_curl: add libcurl-based stream backend
Introduces stream_http, an internal libcurl-driven backend for http://
and https:// URLs. Runs all transfers on a dedicated curl multi thread
with a producer-side ring buffer, and exposes HTTP/2 multiplexing,
QUIC/HTTP/3 (when libcurl supports it), HSTS and TCP keep-alive.

Should generally be more stable and faster than FFmpeg HTTP/1.1 impl,
additionally connections are kept-alive between files open, so if you
open playlist of network files and navigate through them, it will re-use
the same connection.

Build is gated on the new 'libcurl' meson option (auto). When disabled
or unavailable, mpv silently falls back to FFmpeg's HTTP implementation.
2026-05-16 18:20:42 +02:00
Kacper Michajłow cdd3f1197f stream: split shared network options into their own sub-options
Will be useful for future commits
2026-05-16 18:20:42 +02:00
nanahi 0ec3015339 player/external_files: remove handling related to update sub exts
This is only used to update the list for player internal sub ext matching.
Since this handling now lives in the dnd client, it can be removed from
core, which also eliminates a global variable.
2026-05-01 13:42:57 +02:00
nanahi 81611b4a4e input/dnd: move built-in drag and drop handling to mpv client
This moves the drag and drop handling to an internal mpv client,
removing the hardcoded handling from core.
2026-05-01 13:42:57 +02:00
Kacper Michajłow eedadc24ae player/command: hide dependent tracks
They are unusable on thier own, and shouldn't be selected by the user.
Those tracks are ment to be used internally.
2026-05-01 10:42:00 +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
Julian Orth 4c9262664c wayland: implement session management
If the compositor supports session management, the mpv window is always
added to a session. The user can manage multiple sessions by using
`--wayland-session=<human-readable-name>`. Human-readable names are
mapped to session ids via files under `~/.local/state/mpv/sessions`. The
file name is computed as a hash of XDG_CURRENT_DESKTOP and the
human-readable name.

If multiple mpv instances are started with the same session name, the
latter mpv instance takes over the session.

Upon session restoration, the mpv window is restored by the compositor
according to its state from the previous session. What that entails is
compositor policy.
2026-04-24 15:36:44 +00: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
NRK 9251f871b6 options: preparse --shuffle
needed in order to correctly handle --directory-mode=auto

Fixes: https://github.com/mpv-player/mpv/issues/17601
2026-04-06 18:27:27 +02:00
nanahi d6e7fb0597 options/options: add several audio extentions
mp1 - MPEG-1 Audio Layer I
mp2 - MPEG-1 Audio Layer II
mpc - Musepack
tak - Tom's lossless Audio Kompressor
tta - The True Audio
2026-01-20 07:49:17 +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
Guido Cella acd3378c9b Revert "ytdl_hook: add option to extract chapters"
This reverts commit df1e71a7cc.

The next commit will make this unused since chapters will only be taken
from yt-dlp's JSON.
2025-12-19 18:06:14 +01:00
Kacper Michajłow 10c9b3381b options: add mxf to video file extensions list 2025-10-15 22:00:08 +02:00
llyyr be5e606377 sub: make --sub-fix-timing configurable
Instead of hardcoding the threshold and keep duration in a header,
expose them as options for users to configure and set old hardcoded
values as the new defaults for those options.
2025-10-05 21:35:20 +02:00
Kacper Michajłow b4c2471174 options: reduce swapchain-depth to 2 by default
It's enough to not wait for the flip and start with next frame and in
the same time minimized latency which helps display-sync modes, that are
not aware about swapchain depth.
2025-09-27 22:15:13 +02:00
ikas 0bbcc91e1b video/out/d3d11: add changing size support for composition mode 2025-09-19 02:26:08 +02:00
Guido Cella 8406834075 context_menu.lua: add this script
This implements a ASS context menu to be used on platforms other than
Windows.

The select script message will allow selecting an item with a single
click when releasing a mouse button, like in native context menus. This
is mainly useful to cycle pause with one click.
2025-09-15 04:12:57 +02:00
Kacper Michajłow 4f08802ff1 osdep/w32_register: add register/unregister options for Windows
On Linux, we have `mpv.desktop`, and on macOS, we have `osxbundle`, both
of which handle file associations and protocol registration in the
system environment.

On Windows, this information is stored in the registry, so this commit
adds support for it.

It registers the application, supported file types, and supported
protocols, and adds an uninstall entry so users can remove all
registrations via the control panel. Note that this does not remove the
binary itself.

The implementation is fully portable. There are no external installers,
as mpv handles everything automatically. This should improve usability
when moving binaries and so on.

- `mpv --register` registers mpv (see verbose output for a list of actions).
- `mpv --unregister` reverts all changes made during installation.
- `mpv --register-rpath <string>` allows specifying a string to be
  prepended to `PATH` before running mpv. This is useful when using
external dependencies that shouldn't be added globally to `PATH`.
2025-09-15 03:47:35 +02:00
verygoodlee 4c17803b91 options: delete the duplicated extension "wav" in --audio-exts
fixes: 44a3a3293f
2025-08-14 22:26:34 +02:00
nanahi 8b0b186147 options: handle runtime wid change
Add UPDATE_VO flag to the --wid option so that the window embedding
can be changed at runtime without needing to reset another UPDATE_VO
option.
2025-08-05 19:59:16 +02:00
nanahi c301667515 Revert "options: default to --prefetch-playlist=yes"
The decision was based on incorrect assumption that this option
"only opens a connection to the next file, and the cache of the next
video starts empty", a prequisite of the assumption that this option
has no major drawbacks, including incurring unwanted network traffic.

The assumption can be proven incorrect by testing with networked files
in playlist. With log level set to debug, the following lines are shown
after the next file is prefetched, while monitoring of network traffic
shows constant network traffic after the currect file cache reading
reaches EOF, which triggers prefetching:

[cplayer] Opening done: <url to prefetched file>
[lavf] select track 0
[lavf] select track 1
[lavf] EOF reached.
[ffmpeg] AVIOContext: Statistics: 37139315 bytes read, 0 seeks

It is clear that saying "there is nothing to prefetch after the first
frame" is a complete lie: in fact, it fetches the whole file to the
demuxer cache, according to the demuxer cache settings. And when the next
file plays, it also starts with full cache rather than "an empty cache".

In fact, what this option really does is written in
556e204a11: --prefetch-playlist calls
demux_start_prefetch() which does the same thing as the
--demuxer-cache-wait option:

"Before starting playback, read data until either the end of the file was
reached, or the demuxer cache has reached maximum capacity."

This is exactly what is happening with the testing. This option will indeed
cause large amount of unwanted network traffic - a concern raised in the
discussion concerning this option.

Revert this commit since it's based on incorrect assumption, and subsequent
incorrect conclusions derived from it in the subsequent discussions.

This reverts commit 978b219889.
2025-07-05 21:29:37 +02:00
Guido Cella 01b51d1f72 options: add cue to --playlist-exts's defaut value 2025-04-17 21:40:04 +02:00
llyyr 0dc24a2301 sub/osd: set osd-shaper to complex by default
I'd rather not argue about which is better so go back to status quo,
users can use the more sensible option of "simple" if it doesn't break
anything (which it won't).

Using simple has benefits of growing memory usage slower and much faster
OSD rendering when complex isn't needed.

Simple breaks rendering complex glyphs like Material font icons

Fixes: https://github.com/tomasklaen/uosc/issues/1086
Fixes: f24611980c ("sub/osd: add osd-shaper and set it to simple by default")
2025-04-17 15:44:15 +02:00
yumcookiez df1e71a7cc ytdl_hook: add option to extract chapters 2025-04-17 00:37:13 +02:00
Kacper Michajłow 1f809734b2 options: add ivf to video extensions 2025-04-17 00:07:49 +02:00
llyyr f24611980c sub/osd: add osd-shaper and set it to simple by default
This is a change in default for libass with harfbuzz enabled, previously
it would choose the best available shaper.

Harfbuzz isn't really needed for mpv's OSD and it comes with a
significant performance penalty, so use simple instead
2025-04-16 23:58:02 +02:00
llyyr efba6e7e5a sub/sd_ass: add sub-{glyph-limit,bitmap-max-size} 2025-04-16 23:58:02 +02:00
llyyr fc972d2049 sub/osd: add osd-{glyph-limit,bitmap-max-size} 2025-04-16 23:58:02 +02:00
llyyr ad61018294 sub/osd: add osd-prune-delay 2025-04-16 23:58:02 +02:00
Guido Cella 0b3cc3a167 commands.lua: split this script out of console.lua
It was suggested by CogentRedTester in
https://github.com/mpv-player/mpv/pull/10282#issuecomment-1858727729 and
https://github.com/mpv-player/mpv/pull/10282#issuecomment-1858809580 and
by avih that making running commands an mp.input client is a better
architecture.

A practical advantage is that completions are calculated in a different
thread, which prevents hanging when completing slow/network filesystems.

script-binding console/enable becomes script-binding commands/open,
though the console one is kept as an alias. I took the opportunity to
rename this because open makes more sense for a graphical modal, and it
is the word used in mp.input and user-data.

script-message-to console type becomes script-message-to commands type,
though the console one is kept as an alias. It is also changed to
automatically close on submit without having to append '; keypress ESC'
as you don't need to keep the console open after running prefilled
commands.

Also convert to double quotes like other scripts and rename some
inconsistent functions.
2025-03-08 19:09:23 +00:00
Guido Cella 978b219889 options: default to --prefetch-playlist=yes
--prefetch-playlist improves performance by starting to read the next
file in the last second or playback or while viewing an image. This is
obviously noticeable with playlists of direct media URLs, but can also
make a difference on local slow hardware, mainly large (in bytes) images
on HDDs. You can easily see the difference with 10+ MB images.

Since e7a253614c and 24db17d10f fixed niche issues, and it's known not
to cause other issues by users using since 2017 who haven't reported
issues, enable it by default to improve performance.

The only flaw is that it doesn't support ytdl-hook URLs, so in Youtube
playlist, it does a web request with ffmpeg that is doomed to fail since
the last second of playback, though this doesn't cause practical
disadvantages.
2025-02-24 15:54:33 +01:00
Guido Cella aa5d37bc8e positioning.lua: add this script
This script provides script bindings to pan videos and images, making
mpv a better image viewer out of the box.

Fixes #3038, fixes #15020.
2025-02-24 15:53:34 +01:00
Dudemanguy 319687f387 options: replace --wayland-disable-vsync with --wayland-internal-vsync
With the upcoming fixes to FIFO in wayland, it should be preferable to
use FIFO instead of our own hacky heuristic. This means
--wayland-disable-vsync should become a tristate option with an "auto"
behavior (not implemented in this commit). The semantics have to
slightly change so introduce --wayland-internal-vsync and deprecate
--wayland-disable-vsync.
2025-02-17 17:15:00 +00:00
nanahi 7f4add8ddb options: disable --input-ime by default
Enabling IME by default can cause problems when the player is
expecting keybinds and not text input. Windows IME implementation
mitigates this by switching IME to alphanumeric mode,
but this is impossible on Wayland with the text input protocol.

Disable it by default and add a note to recommend enabling IME only on
demand, like console.lua.
2025-02-17 16:56:47 +00:00
Kacper Michajłow 50f3c1c243 player/command: disable input-commands for fuzzing
Updating input-commands string list causes all commands to be rerun.
This happens during load-config-file command, so even with few commands
it is easy to amplify single command to run hundreds of times instead of
one. This causes timeouts and OOMs when specific command for example
reopens current playlist appending an item.

Also avoid even single input-commands, we want to test load-config-file
parsing and input-commands can do loadfile and trigger heavy code
paths. We don't want to mix this. Unfortunately parsing of
input-commands will not be tested.
2025-02-08 05:41:22 +01:00
Dudemanguy 8c4ca44e24 vd_lavc: separate opts to two structs and reorganize
The options in vd_lavc are all related, but they don't all require the
same thing for runtime changes. To avoid having to manually add UPDATE_*
to every single option flag, the options can be split into two separate
structs. The vd_lavc_conf becomes a catch all for all the --vd-lavc
options that require the full UPDATE_VD flag. The rest of the options
are split off into the new hwdec_conf instead. Additionally,
--vd-lavc-software-fallback is renamed to --hwdec-software-fallback and
moved to the hwdec_conf as well. The new name better reflects what it
does and it logically fits with those more. UPDATE_* flags are added on
everything now so these should all now be changeable on runtime.
2025-01-29 15:07:42 +00:00
Guido Cella 24db17d10f loadfile: discard prefetched files if demuxer options changed
When using --prefetch-playlist, if demuxer options are changed in the
time window between the start of prefetching and the playback of the
next file, the old values are used. This includes setting demuxer
options in legacy extension auto profiles.

Fix this by setting a flag when demuxer options change and not using the
prefetched data when that flag is true.

UPDATE_DEMUXER is not added to demux.c's options because those already
support updates while playing.
2025-01-27 19:32:52 +00:00
Guido CellaandKacper Michajłow b75ed73f4f loadfile: optionally save the watch history
The history could be formatted as CSV, but this requires escaping the
separator in the fields and doesn't work with paths and titles with
newlines. Or as JSON, but it is inefficient to reread and rewrite the
whole history on each new file, and doing so overwrites the history with
an empty file when writing without disk space left. So this uses a
hybrid of one JSON object per line to get the best of both worlds. This
is called NDJSON or JSONL.

Co-authored-by: Kacper Michajłow <kasper93@gmail.com>
2025-01-27 18:53:28 +01:00
Attila Fidan 51dc6286b6 video/out/wayland_common: support IME usage via text-input-v3
This is useful for text input in, for example, console.lua. Each
character in the commit string gets turned into an mpv key press.
Pre-edit strings are not handled, since there's currently no good way to
handle that or make it useful to text input scripts. Like win32, which I
tested in wine, another limitation is that the composition window is
always positioned at the top left of the window, since we cannot get
useful positioning hints from mpv scripts. It allows the composition
window to be within the window and avoids obstructing the console
prompt.

This can be enabled/disabled with --input-ime=<yes|no> (default: yes).
2025-01-25 03:14:44 +00:00
nanahi 0903e9fbd4 various: fix range for float options
The range of these options should be capped to FLT_MAX
instead of DBL_MAX.
2025-01-24 04:25:15 +00:00
llyyr baecbb12fa sub: add sub-scale-signs
Allows --sub-scale to alow scale typesetting
2025-01-05 01:14:42 +01:00
Kacper Michajłow 96da0cbcbd options: remove the player argument from --media-controls
It is now handled internally by the libmpv profile.

Since `player` was the default option, the impact should be minimal, as it
is uncommon to override the default option with the same value.
yes/no args will function the same way as before this commit.
2025-01-04 15:16:40 +01:00
Guido Cella e696b75f57 options: add --playlist-exts
And add playlist to --directory-filter-types' default.

Fixes
https://github.com/mpv-player/mpv/issues/15096#issuecomment-2466695186,
fixes https://github.com/mpv-player/mpv/discussions/15508
2024-12-28 14:24:00 +01:00
Guido Cella 114bdc24f2 options: add --archive-exts
And add archive to --directory-filter-types' default.

Fixes #15550, fixes #15096.
2024-12-28 14:24:00 +01:00
Guido Cella a6f93ac81e options: add heic and heif to --image-exts 2024-12-17 23:30:32 +00:00
Kacper Michajłow c14af4ebad options: disable playlist and include for fuzzing
Both of this options reads files, so there is not much to test there and
only creates problems with timeouts when too much is read.
2024-12-12 01:45:19 +01:00
Kacper Michajłow 04eb51246f options: remove old compatibility definitions
This makes things more readable.
2024-12-09 19:19:50 +01:00
Guido Cella f7e6e30a49 aspect: add --video-recenter
This ignores --video-align-{x,y} when the video is smaller than the
window in the respective direction.

After zooming in, panning and zooming out, this is useful to recenter
the video in the window.

Unlike doing this by observing osd-dimensions in a script, this is done
before rerendering, so you don't see the image being rendered uncentered
for an instant after zooming out, before being rerendered centered.

Also update --video-align docs while at it.

This doesn't work well with --video-pan-{x,y} because you can move the
output rectangle far away from the image, and when zooming out pan is
abruptly reset to the center. It doesn't feel like natural like zooming
out after changing --video-align-{x,y}. So this commit doesn't set pan
to 0. Also this leaves a way to move scaled images within the window
even with --video-recenter.
2024-12-02 22:31:14 +01:00
nanahi e1d30c4c5a clipboard: add clipboard API
This adds a clipboard API with multiple backend and format support.
--clipboard-enable option can be toggled at runtime to turn native
clipboard on and off.
2024-11-27 20:31:41 +01:00