Commit Graph

3940 Commits

Author SHA1 Message Date
Dudemanguy
694817121a command: don't run UPDATE_{AD,VD} if the {ao,vo}_chain doesn't exist
As described in 544240c829, the callbacks
are all run on init so UPDATE_AD and UPDATE_VD both executed. While this
is probably not harmful, it is completely pointless work and results in
extra event notifications being sent. Just skip these if there is no
matching chain.
2025-01-29 15:07:42 +00:00
Dudemanguy
be15be3a83 various: expand paths for all file/directory related options
There's several path-related options that do not handle common shortcuts
(like ~/). Fix this by using mp_get_user_path where appropriate which
expands the path so users get more intuitive behavior. Fixes #15598.
2025-01-29 14:49:06 +00:00
Dudemanguy
c7c09fdb8b command: fix spammy events when frame stepping forward with seek
The frame-step command also signals on up events. This is only useful
when using the default "play" mode. For seek mode, it triggers another
frame step which is not what you want. Rearrange the logic so the up
event is ignored for the seek flag. The frames check is also not needed
since add_step_frame already handles it.

Fixes 9661a3839b
2025-01-29 14:48:55 +00:00
Attila Fidan
3544728991 clipboard-wayland: initialize offer fd
Fixes: https://github.com/mpv-player/mpv/issues/15763
2025-01-29 13:19:04 +01:00
Dudemanguy
0e03fdf0f7 f_decoder_wrapper: allow changing --ad and --vd at runtime 2025-01-28 15:48:15 +00:00
Dudemanguy
8d665ac2df osc.lua: add visibility_modes script opt
This allows users to choose what visibility modes they want to cycle
through when calling the osc-visibilty cycle script binding.
2025-01-28 15:47:47 +00:00
Dudemanguy
fd4aa9b533 osc.lua: deprecate pointless script-messages
1a558bf5c2 effectively aliased the custom
OSC printing to actual mpv properties instead. These only exist for
backwards compatibility which hopefully will get removed one day so
instead deprecate them and warn users of what they should be using.
2025-01-28 15:47:47 +00:00
Kacper Michajłow
1d352f8527 stream_file: allow to open only our fd in case of fuzzing
This ensures that we don't open some other fd, for example when loading
playlist. Also filters out loading any local files.

This also allows to remove custom filtering from fuzzer itself.
2025-01-28 07:59:04 +01:00
Dudemanguy
9661a3839b command: allow frame-step to go through multiple frames and/or seek
Previously, the default behavior of frame-step and frame-back-step is to
play forward 1 frame or seek back 1 frame. We keep this behavior but
introduce additional flags to control the exact behavior of the frame
stepping. The first argument simply specifies how many frames to go
through. The second argument specifies whether to play video to step
through frames or to seek to step through frames. Playing through the
video to step through frames only works going forwards (otherwise it
will always seek). In theory we could use backwards playback for this,
but that can be decided later.

As a minor note, MPSEEK_BACKSTEP is renamed to MPSEEK_FRAMESTEP since
forward seeks can use this as well. Fixes #10128.
2025-01-28 04:20:16 +00:00
Guido Cella
1f6bba19d7 osc.lua: add an icon for the miscellaneous menu
Add the generic menu to bar layouts to provide discoverability for the
select menus to users who don't realize you can right click OSC buttons.

There's no space to add it in box layout.
2025-01-27 21:06:50 +01:00
Guido Cella
3e0b3373df select.lua: add a miscellaneous menu 2025-01-27 21:06:50 +01: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 Cella
130128762b command: group flag updates together 2025-01-27 19:32:52 +00:00
Guido Cella
e2090533cf select.lua: select from the watch history with g-h
Implement selection of the entries in the watch history.

The last entry in the selector deletes the history file.
2025-01-27 18:53:28 +01:00
Guido Cella
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
Guido Cella
908dc02eb9 misc: extract mp_find_non_filename_media_title() from command.c
This will be used to write the title in the watch history.
2025-01-27 18:53:28 +01:00
nanahi
ab461e0209 console.lua: use clipboard property for native Wayland backend
This backend does not require the window focus quirk handling,
and also supports primary selection.
2025-01-27 18:51:31 +01:00
nanahi
3be195e616 console.lua: autocomplete clipboard/text-primary property 2025-01-27 18:51:31 +01:00
nanahi
481646da37 command: add current-clipboard-backend property
Useful to know which clipboard backend is active.
2025-01-27 18:51:31 +01:00
nanahi
b2165c263a clipboard: add function to get clipboard backend name
Some platforms like Wayland may have support for multiple backends,
so add this function to make it possible to determine the current
active backend.
2025-01-27 18:51:31 +01:00
nanahi
46e2f55338 command: add clipboard/text-primary property
This property contains the text in the primary selection.
2025-01-27 18:51:31 +01:00
nanahi
9f2ac08851 clipboard-wayland: add Wayland clipboard backend
This adds a "native" Wayland clipboard backend based on the
ext-data-control-v1 protocol.
This backend overcomes the limitation of the VO (Wayland core protocol)
backend, and does not require the presence of the VO window to receive clipboard
updates.
This backend also supports primary selection if supported by the compositor.

The backend runs in a separate thread, so clipboard reading
does not stall the player like the VO backend.
2025-01-27 18:51:31 +01:00
nanahi
589e34cebd clipboard-vo: use clipboard parent log context
This adds clipboard backend names to backend-specific logs,
e.g. clipboard/vo.
2025-01-27 18:51:31 +01:00
nanahi
dc5c857f7b clipboard: don't store mpv_global context
It's only used for logging, and further creation of log contexts
can use the parenting feature instead, so there is no need to
store it.
2025-01-27 18:51:31 +01:00
Guido Cella
04c328f784 console.lua: use the same blur amount as --osd-blur
I have no idea why, but console's blur is smaller than in OSD messages
and stats (regardless of persistent_overlay). It's smaller regardless of
scale_with_window, or if using 0 PlayRes like stats with
persistent_overlay=yes.

With scale_with_window=yes, multiplying the blur by 2.5 seems to make it
the same. This is probably because 2.5 is 720 / 288, which are the base
height sizes scale from and the OSD's PlayResY. With
scale_with_window=no, we need to multiply by osd_h, which is always 720
with scale_with_window=yes.
2025-01-25 03:14:59 +00:00
Guido Cella
20375d1133 select.lua: show the ID of editions without title
MKV editions can have no title. Print "Edition" and their IDs instead of
showing an empty selection.
2025-01-24 04:35:36 +00:00
Guido Cella
5bbeabf450 console.lua: sort completions
With the previous commit, this sorts completions with the same score
alphabetically.
2025-01-24 04:35:27 +00:00
Guido Cella
8ae3beeb98 console.lua: preserve the order of items with equal score
table.sort() is unstable, meaning that it randomly reorders items with
the same score, so currently fuzzy_find() checks if the line is empty to
not change the original order of the unsorted items. But actually filled
lines have the same problem: e.g. searching foo with filenames like
foo_{1..99}, they are returned in random order.

To fix this sort by score only when 2 items have different score, else
sort by the original position.
2025-01-24 04:35:27 +00:00
Guido Cella
7ded290e2c console.lua: rename format_table() to format_grid()
Since there is no table header or predetermined columns.
2025-01-24 04:34:49 +00:00
Guido Cella
0c5d966f47 console.lua: always say completions instead of suggestions
Both completions and suggestions were being used inconsistently. Just
always use completions which is much more common.
2025-01-24 04:34:49 +00:00
Guido Cella
a2ce811b28 console.lua: rename update() to render()
It is not clear what update() updates, in fact this rename allows
removing the comment explaining it. render() is clearer and is the same
term used by the OSC.
2025-01-24 04:34:49 +00:00
Guido Cella
df3872e318 loadfile: fix --loop-playlist + --shuffle + --prefetch-playlist
With this combination of options, the playlist is shuffled every time
the last playlist is reached, instead of when restarting from the first
playlist entry. Abort prefetching in this case, as we can't predict
which file to prefetch until the playlist is shuffled when actually
going to the first file again.
2025-01-22 14:01:11 +00:00
Guido Cella
304a620b0b loadfile: return earlier if prefetch already started
There is no need to call mp_next_file() if prefetching already started,
so return earlier.
2025-01-22 14:01:11 +00:00
Guido Cella
e7a253614c loadfile: fix --loop-playlist=N with --prefetch-playlist
With --prefetch-playlist and --loop-playlist, mp_next_file() is called
continously since the last second of playback or when viewing an image,
which decreases --loop-playlist=N to 1.

Fix this by adding a flag to mp_next_file() to specify whether to
decrement --loop-playlist=N. The first playlist entry is still
prefetched when it's the next one, but without decrementing
--loop-playlist=N.
2025-01-22 14:01:11 +00:00
Guido Cella
effa81eb6e console.lua: set a high z in select mode
Give console's overlay a high z only in select mode, since in this case
you want to click it so it should be above other overlays. In particular
console should be above the OSC's box layout with visibility=always when
you show it by clicking its buttons.

Keep using z=0 otherwise when it doesn't handle clicks, to avoid
unintuitive behavior of overlays handling clicks like the OSC being
drawn below console.

Since the legacy mp.set_osd_ass() doesn't accept z, we need to repeat
its caching logic, like 490b3ba007 and 86d24b069b did for the OSC.
2025-01-22 12:55:24 +02:00
Guido Cella
2ecfe3ecf7 Revert "osc.lua: draw box layout below console"
This reverts commit 2dd5bd4cd1.

Instead of drawing the box layout below any other overlay with z >= 0
which may not be wanted, the next commit will increase console's z only
in select mode instead.
2025-01-22 12:55:24 +02:00
Guido Cella
c438732b23 console.lua: improve the hovered item calculation
Currently determine_hovered_item() assumes that each item is
opts.font_size pixels tall, which usually works well. This breaks with
fonts that get drawn taller than that, such as Japanese text, which
makes the calculation inaccurate for the top items and clips the
counter. A couple of users reported that it is inaccurate for them for
the top items even with ASCII characters in track selectors, presumably
because the circles are taken from a different font and make all lines
taller.

To fix this place each selectable item in its own ASS event positioned
like determine_hovered_item() expects.

Unfortunately this breaks --profile=box, so keep placing every item in
one ASS event with it.
2025-01-18 12:52:02 +01:00
Guido Cella
89c42e4481 console.lua: deduplicate y position calculation in update()
This deduplicates the calculation of the y position by assigning it to a
y variable, which will also be used in the next commit. margin_x is also
renamed to x for consistency.
2025-01-18 12:52:02 +01:00
Guido Cella
a06883f79a console.lua: refactor some log code
Rename lines_max to max_lines which is the name used in other functions,
and inline the log_messages variable because its name was confusing.

The math.max(0, lines_max) call was not necessary because console
doesn't crash with 0 or negative max lines.
2025-01-18 12:52:02 +01:00
Guido Cella
ca211b5b88 ytdl_hook.lua: fix start and end conditions
Fixes #13358, fixes fcc67cc6c1.
2025-01-10 14:06:16 +01:00
Guido Cella
7a59a12b76 select.lua: select files with watch later files with g-w
Implement selection of files to resume playing from watch later config
files. Requires --write-filename-in-watch-later-config.
2025-01-05 23:21:50 +01:00
Guido Cella
b530b402bf command: add current-watch-later-dir property
It will be used in the next commit.
2025-01-05 23:21:50 +01:00
Guido Cella
0c3c4a315b select.lua: use mp.msg.warn for unavailable messages 2025-01-05 23:21:50 +01:00
Guido Cella
31d4515157 osc.lua: extract icon_font and icons variables
Define the icon font and icons in variables instead of scattering them
throughout the code to make it easy to change them in the future, or for
forks to change them. Also put the hex values in comments to easily
compare which icons in the font are unused, and explain how to get the
decimal values of the bytes.

Copied from ModernX.
2025-01-05 22:31:59 +01:00
nanahi
72550aa7df console.lua: complete screenshot-raw format parameter 2025-01-05 21:28:57 +01:00
nanahi
ab47e95197 player/screenshot: support more formats for screenshot-raw command
This adds a format parameter to screenshot-raw command which controls
the format of the returned image data. In addition to the bgr0 format,
this adds support for 3 other formats: bgra, rgba, rgba64.

bgra is used by overlay-add command and several window systems.
rgba and rgba64 are used by several GPU APIs and are the formats
returned by the gpu and gpu-next screenshot code, which avoid the need
for further format conversion (see convert_image function).
rgba64 also adds the ability to acquire high bit depth screenshots
for screenshot-raw command.
2025-01-05 21:28:57 +01:00
nanahi
c1237c1d48 player/screenshot: add high depth and format parameters
Add the ability for screenshot_get_rgb to request high depth and other
formats. Will be used for the next commit.
2025-01-05 21:28:57 +01:00
Guido Cella
8ed672ffc8 osc.lua: add slimbottombar and slimtopbar layouts
Add layouts with only the top line of bottombar to be used with images.
2025-01-05 21:24:02 +01:00
Guido Cella
850e03d29f console.lua: add pause_on_open script-opt
Add a script-opt to pause when console opens and unpause when it closes,
disabled by default.

This is particularly useful for selectors that take several seconds to
open so you don't have to guess when to pause, like the subtitle line
selector with embedded subtitles, or my script which lets you select
which lyrics to download after requesting them with curl.
2025-01-05 21:21:32 +01:00
Guido Cella
996e58a738 stats.lua: only reprint stats on video-reconfig when toggled
Make this behave like the comment says it should, because currently when
you show oneshot stats and change file, stats are printed again and hide
--osd-playing-msg. This happens even if you hide the stats by
show-texting something else and change file before the timer expires.
2025-01-05 00:52:49 +01:00