1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-06 15:11:58 +00:00
Commit Graph

3730 Commits

Author SHA1 Message Date
nanahi
2af0b0b34b player/javascript: allow reading partial result for af_push_file
ca7006a6a2 replaced file reading with
stream_read_file which results in error when af_push_file is used
to test existence with 1-byte limit. Fix this by using
STREAM_ALLOW_PARTIAL_READ flag to restore the old loading behavior.
2024-10-22 03:16:51 +03:00
nanahi
fad946d778 player/javascript: use af for stream_read_file talloc context
Needed because js_pushlstring can throw and skip the free below.
2024-10-22 03:16:51 +03:00
Sam
2173565b56 osc.lua: replace escaped double quotes with single quotes 2024-10-22 00:02:38 +02:00
Guido Cella
0dc2e85ff8 console.lua: exit when left clicking outside of selectable items 2024-10-21 22:25:54 +02:00
Guido Cella
15ad917bb1 stats.lua: remove term_height_limit script-opt
It is excessive control to manually configure the terminal height limit
just for stats, if anything this should be added as an option used all
throughout mpv.
2024-10-21 20:07:01 +02:00
Guido Cella
d6951e4039 stats.lua: don't print the scroll hint with bindlist 2024-10-21 20:07:01 +02:00
Guido Cella
a187110f4a stats.lua: clip lines with ${term-clip-cc}
Use the property introduced in bf025cd289 to clip the lines of stats.lua
with accurate unicode width detection and considering --msg-module and
--msg-time. This allows removing the term ellipsis functions.

Also use script-opts-append instead of script-opts in the docs so
script-opts in mpv.conf, which could change keybindings, are not
overriden.
2024-10-21 20:07:01 +02:00
Guido Cella
f72f6b0fc4 stats.lua: indent terminal output with 4 spaces instead of tab
Because the default tab width of 8 cells wastes too much space, and 4
spaces is closer to the width of ass_indent.
2024-10-21 20:07:01 +02:00
Kacper Michajłow
cd62cc7ecb player/osd: don't add newlines when message would be empty anyway
When only control char is present there is no point to add part for it.
2024-10-21 20:06:48 +02:00
nanahi
ca7006a6a2 player/javascript: use stream_read_file for af_push_file
Remove the complicated fopen/realloc logic.
2024-10-20 19:31:49 +02:00
Kacper Michajłow
08e2acbae1 stats.lua: don't use io.write from builtin script
Scripts and especially internal scripts shouln't bypass msg.c logging
code for various resons, ranging from processing the input, filtering
the log levels, truncating the output and so on. io.write() is lazy way
of outputing to stdout without respecting mpv's logging module.

Uses osd message, because this has no prefixes. Added internal
flush-status-line command to flush current output without clearing
before exiting.

This commit will allow us to remove duplicated terminal handling code
from stats.lua, mpv core already handles all that and does it in better
way, without taking shortcuts.
2024-10-17 22:32:10 +02:00
Kacper Michajłow
c3404fdf37 console.lua: don't clear not ours osd messages
Note that this still is not perfect, because if osd message is changed,
console cannot know about it and would still clear it, but this change
make it at least not do it to every message even if console is not used.
2024-10-17 22:32:10 +02:00
Guido Cella
50faafd8bd stats.lua: exit with ESC if being toggled
If not opened in oneshot mode, close the stats with ESC. Especially now
that ? toggles showing key bindings by default, this provides an
intuitive way to close the stats.

Also do some minor reformatting of key binding documentation.
2024-10-17 16:57:35 +02:00
Guido Cella
1a558bf5c2 osc.lua: remove NIH list formatting
All of the code to format playlist/track-list/chapter-list is
unnecessary when mpv's core can already show-text these properties.

Also an issue with this custom formatting is that showing fewer entries
than can fit on the OSD can make it seem like the playlist ends there
and there are no entries afterwards.

Also remove lots of pointless code around the track-list (mpv's track id
and the osc_id are exactly the same).

This simplification will make it easier to bind customizable commands,
otherwise yet another script message to call set_track would have to be
added, when cycle sub/audio already output information about the new
track on their own.
2024-10-16 15:10:23 +02:00
Guido Cella
3522dd836e command: implement printing ${track-list/{video,audio,sub}}
This brings show-text ${track-list} in line with osc.lua's
get_tracklist(type) before replacing it with show-text.
2024-10-16 15:10:23 +02:00
Guido Cella
89d78369c6 command: print the number of chapters in show-text ${chapter-list}
Call cut_osd_list() like with ${playlist} to print position/count above
the chapters. This is useful for movies with many chapters.

Stop printing the chapter numbers because they are not useful here, they
are only useful when navigating to a chapter.

Remove one of the spaces before the circles because they are too many.

This replicates osc-chapterlist before replacing it with show-text
${chapter-list}.
2024-10-16 15:10:23 +02:00
Guido Cella
841b66d3ec command: consider the terminal height in cut_osd_list()
cut_osd_list() calls osd_get_text_size() even when outputting to the
terminal, which results in max_lines = 19. Use the actual terminal
height instead.
2024-10-16 15:10:23 +02:00
Guido Cella
be1be8ca61 command: print position/count in show-text ${playlist}
...instead of "n hidden items". This brings it in line with osc-playlist
before replacing it with show-text ${playlist}. Also make count_lines()
return the correct count.
2024-10-16 15:10:23 +02:00
Guido Cella
0f74b1bc2d console.lua: improve hovered line calculation
- Don't do anything if clicking on the top counter, the input line or
  the new line between the items and the input line

- Don't scroll upwards when hovering the counter

- Don't redraw before clicking to avoid quickly updating the overlay
  before closing it with touch input, where the item you touch can be
  different from the one that was highlighted
2024-10-16 14:29:21 +02:00
Guido Cella
b0f1830a8e console.lua: make the wheel scroll selectable items instead of the match
This makes scrolling with the wheel more usable because it doesn't
matter if the focused item is reset by moving the mouse slightly, and
scrolling always begins immediately.

This makes the MBTN_MID binding to handle_enter() unnecessary so it is
removed.
2024-10-16 14:29:21 +02:00
Guido Cella
e88a1a7de7 console.lua: print position/count instead of n hidden items
This makes it consistent with the new changes to show-text ${playlist}
and greatly simplifies the logic, making it sane to implement scrolling
the view with the wheel in the commit.
2024-10-16 14:29:21 +02:00
Dudemanguy
0721b87237 player: make redraw_sub flag work on a per track basis
There can be multiple subtitle tracks (secondary subs) so this logic
should be handled separately.
2024-10-16 02:26:06 +00:00
Dudemanguy
fe758a1761 player/command: destroy cached packets after UPDATE_SUB_{FILT,HARD}
Otherwise, the index can technically grow forever because
sub_read_packets will trigger again, read the same packets, then add
them to the list. We should just clear the cache here in this case to
reset it back to 0. Also flag redraw_subs here as well.
2024-10-16 02:26:06 +00:00
Dudemanguy
d2d8667259 player: move a redraw_subs edgecase to loadfile
Putting this in handle_osd_redraw was strange and my own comments didn't
help me remember what this was even for. The actual purpose here is that
the osd needs to be redrawn in the still image edge case as you go
through a playlist. This is because all the logic with checking
timestamps isn't applicable and we need to essentially clear the screen
with another redraw. Clearly, it makes more sense for this to be done
when a new file is successfully loaded and not in the osd_redraw where
that happens to work but was called repeatedly pointlessly.
2024-10-16 02:26:06 +00:00
Dudemanguy
dfe3edee76 player/sub: avoid pointlessly redecoding subs
This was added in 8f043de961 but the
redecode is a special case that is only ever needed for subtitles on a
still image. Normal video never needs this so just modify the
conditional to avoid doing more work.
2024-10-16 02:26:06 +00:00
Guido Cella
661bd61af8 console.lua: center selectable items around the default item 2024-10-14 20:14:27 +02:00
Guido Cella
3e63c97677 console.lua: highlight the select menu's preselected item
Requested in
https://github.com/mpv-player/mpv/pull/14087#issuecomment-2110889436 and
https://github.com/mpv-player/mpv/pull/15031#issuecomment-2401328081

This is mainly useful to keep highlighting the current playlist entry
after moving the mouse.
2024-10-14 20:14:27 +02:00
Guido Cella
ad0c29e5ac console.lua: close with right click
Useful to close the console after it was opened with the mouse.

Also fix the spacing of the previous line.
2024-10-14 20:14:27 +02:00
nanahi
86e8cae9ca stats.lua: add nonscalable prefix to cmd_prefixes 2024-10-14 01:55:49 +02:00
nanahi
72a705c598 console.lua: add nonscalable prefix to command_prefixes 2024-10-14 01:55:49 +02:00
Guido Cella
e34f6569ee stats.lua: rename a variable 2024-10-12 21:24:41 +02:00
Guido Cella
ba3b4eda64 console.lua: use ${term-clip-cc} to clip lines
Instead of considering every non-ASCII character 2-cell wide, use this
newly introduced property to let msg.c clip the select menu using all
available with.
2024-10-11 15:31:17 +02:00
Kacper Michajłow
bf025cd289 msg: allow to truncate the message to terminal width 2024-10-11 15:16:33 +02:00
Crend King
c8860fd816 ytdl_hook.lua: always specify --write-srt
Currently by default mpv sets --all-subs when calling yt-dlp for JSON
info. --all-subs is an option that simply expands to --sub-langs all
--write-subs. --write-subs is special that without it yt-dlp will no
longer extract any subtitle info.

mpv's yt-dlp hook has a logic that if user specify any sub-langs in
--ytdl-raw-options, it no longer uses --all-subs. Unfortunately, this
means unaware users will not get any subtitle any more until they study
the mpv internal code and add their own --write-subs.

This PR always specifies --write-srt, an alias of --write-subs, in the
hook, so users don't have to. The alias is used to maintain
compatibility with youtube-dl.

Fixes issue #14818
2024-10-10 18:28:41 +02:00
Dudemanguy
901b9bc888 player/sub: ensure subtitles are updated for images with no audio
The video_pts condition here would bail out on still images with no
audio since their pts is always MP_NOPTS_VALUE. This is not exactly
great because the subtitles may need to be updated so just let these
files also go through the subtitle redraw logic below.
2024-10-10 13:17:47 +00:00
Guido Cella
6ed3781a3d ytdl_hook.lua: add include script-opt of URLs to try with ytdl first
By the default mpv tries opening URLs with ffmpeg first, and users who
don't configure try_ytdl_first get a slower startup for youtube URLs, on
top of yt-dlp already being slow.

Fix this by adding a script-opt of URL pattern to try with ytdl first.
Youtube and twitch are included by default.

Compared to the alternative of trying ytdl first by default and
excluding URLs with a media extension, this only works for the sites
explicitly included in the new option's value, but doesn't have false
positives on media URLs without an extension.
2024-10-09 01:08:31 +02:00
Guido Cella
92403a068c ytdl_hook.lua: lower case URLs for exclude matching 2024-10-09 01:08:31 +02:00
Mohammad AlSaleh
28a4e19a67 command: avoid division by zero in av_timecode_make_string()
`av_timecode_make_string()` divides by fps unconditionally. And
 relying on container_fps always carrying a meaningful value was
 misguided. So we now check that fps is non-zero before calling that
 function.

 Issue encountered with a couple of old FLV files triggering a segfault.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-10-09 00:36:35 +02:00
Guido Cella
8bf5548589 console.lua: allow clicking selectable items
This adds click support for the select menu. Scrolling with the wheel
already worked.

If a custom OSC binds a button to a select.lua script-binding, this lets
users keep using the mouse to select an item.

While the OSC and the select menu are open at the same time, you can no
longer click the OSC's buttons. By using mp.add_key_binding instead of
add_forced_key_binding you could click both, but the console's binding
would be shadowed by MBTN_LEFT bindings in input.conf.
2024-10-08 20:37:56 +02:00
Guido Cella
493cab7efc stats.lua: allow keybindings to toggle the display of a specific page
This lets you define bindings like h script-binding
stats/display-page-4-toggle. Requested in #14966.
2024-10-04 21:13:29 +03:00
Guido Cella
be814e3753 stats.lua: scroll keybindings while filtering them
console.lua binds up and down to navigate its history. Add a private
flag to mp.input.get to instruct console.lua not to bind up and down, so
you can use them to scroll the keybindings page while filtering
keybindings.

If it is requested, this can be replaced with an argument to input.get
to not bind arbitrary keys.

Fixes #14966.
2024-10-04 21:13:29 +03:00
Guido Cella
b3f8464fa9 input.lua,defaults.js: don't hardcode mp.input arguments
Pass everything in the tables passed by mp.input callers to console.lua
so new flags can be added without modifying these clients.

In Lua, callbacks have to be excluded from the argument tables to not
make utils.format_json() error, while with JSON.stringify they are
automatically omitted.
2024-10-04 21:13:29 +03:00
Guido Cella
dcd681ecdd stats.lua: filter keybindings by comment
Requested in #14966.
2024-10-04 21:13:29 +03:00
Kacper Michajłow
7202406fe8 various: remove global.h inclusion where not needed 2024-10-01 12:23:44 +02:00
nanahi
151fa74806 player/external_files: fix null deref when cover-art-whitelist is empty
This can happen when using --cover-art-whitelist-clr.

Fixes: d384a6b793
2024-09-29 22:56:40 +02:00
Andreas Klauer
c365e2f7b1 misc/random: seed using libavutil/random_seed
When starting multiple processes of `mpv --shuffle` in parallel,
sometimes the random seed happens to be identical, so files are
played in the same random order.

mp_rand_seed(0) now uses a random seed provided by libavutil,
and only falls back to time in case of failure.
2024-09-28 14:11:56 +02:00
Guido Cella
69ced646f8 lua: remove unused #define mp_lua_len
This is unused since 548ef07864 and 7f91e2684e.
2024-09-26 16:45:08 +02:00
Dudemanguy
b52a67dde2 meson: bump required version to 1.3.0
Newer meson versions added support for features that mpv has been using
for a long time. Annoying fallbacks were left in place to not break old
versions but ideally everyone should be using the newer build features.
Both the latest ubuntu LTS and debian stable (in backports) have 1.5.0
in their repos, so go ahead and bump the version so we can drop some old
code and let developers use newer meson features if applicable.
2024-09-24 22:16:59 +00:00
Kacper Michajłow
1c55d600ab stats.lua: add timecode display 2024-09-24 19:47:42 +02:00
llyyr
d33bcc51a7 command: add video-frame-info/{gop,smpte,estimated-smpte}-timecode
Co-authored-by: Kacper Michajłow <kasper93@gmail.com>
2024-09-24 19:47:42 +02:00