0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
Commit Graph

3590 Commits

Author SHA1 Message Date
Kacper Michajłow
a41cdf0289 stats.lua: align 100% correctly on page 2
It is not common to have one pass with 100% usage, but it is not
impossible, so handle this case too.
2024-06-14 00:26:04 +02:00
Guido Cella
5158a3d779 console.lua: don't enable the console-input input section
https://github.com/rossy/mpv-repl enabled and disabled its keybindings
with input sections (define-section, mp.enable_key_bindings and
mp.disable_key_bindings), but when wm4 merged it in mpv, he changed it
to use mp.add_forced_key_binding and mp.remove_key_binding because he
deprecated input sections, but he forgot to remove the
mp.enable_key_bindings line. Remove it now.
2024-06-09 20:50:03 +02:00
nanahi
22103b8a8f osc.lua: fix timetotal and timems settings 2024-06-09 06:08:10 +02:00
nanahi
d2bd77ada0 stats.lua: display file tags
This adds file tags to display along with the title, including
album/artist etc. for music, and series etc. for some videos.
The list of tags to display is identical to the tags printed to
the terminal and is controlled by the --display-tags option.

To filter out overlength tags (such as long comments and lyrics) and
files with too many tags, add file_tag_max_length and file_tag_max_count
options so that tags longer than this length are not displayed, and only
the first few tags are displayed.

Also makes tags show on page 5 only.
2024-06-09 00:58:48 +02:00
Guido Cella
948faa5482 lua: don't pass nil as the second argument of mp.get_property_number
This doesn't do anything because nil is already the default value of
unavailable properties.
2024-06-08 23:10:37 +02:00
Guido Cella
1a5edb1e49 stats.lua: remove print_perfdata_passes
22a8b99 introduced print_perfdata_passes as a stopgap until a dedicated
performance stats page would be implemented. Since it has been
implemented for many years, remove this option, which isn't even
documented, and is likely to make the stats overflow beyond the screen.
2024-06-08 23:07:17 +02:00
Kacper Michajłow
73e779a1ee stats.lua: add page 5 for currently selected tracks information 2024-06-08 23:06:22 +02:00
nanahi
6679ef003e stats.lua: make the append function increment index only on newline
To avoid a large append parameter refactoring is to make the append
function add the table index only if the newline character is not empty.
Otherwise, new strings are appended to the existing string.
2024-06-08 23:06:22 +02:00
nanahi
f8f47d06f4 osc.lua: add option to use display fps for update interval
If the display fps is unavailable, use the tick_delay as a fallback.
2024-06-08 13:46:11 +02:00
nanahi
fa525265b4 osc.lua: unify observe_property style 2024-06-08 13:46:11 +02:00
nanahi
6337bc27ff osc.lua: add option to make rendering smoother
OSC rendering used to be smooth (up to OSD rendering fps) before
48f906249e, but after that commit the
frame duration is hardcoded to 30 ms. This is too high and results in
choppy OSC rendering, which is very noticeable with the progress bar
while moving mouse over it or playing a short 60 fps video.

This makes the duration an option so that it can be decreased to make
OSC rendering smoother.
2024-06-08 13:46:11 +02:00
Guido Cella
dc998560aa options: add --osd-playlist-entry
Allow configuring whether to print the media-title, the filename or both
(as `<title> (<filename>)`) in show-text ${playlist}, the OSC playlist
and in the playlist selector.

Showing only titles hides information when files are badly tagged, or
when it hides the track numbers of album songs. But showing filenames is
not as useful as titles e.g. when playing URLs with media titles. This
option lets the user choose which one to show, or show both if switching
is inconvenient.

The OSC's playlist_media_title script-opt is removed because this option
is better since it works everywhere after configuring it once.

Closes #11653.

Also show the full URLs of playlist entries instead of their basenames
in osc.lua and select.lua, consistently with mp_property_playlist().

For simplicity, this just checks if entries contain :// instead of
replicating all of mp_is_url().

Co-authored-by: Kacper Michajłow <kasper93@gmail.com>
2024-06-08 01:43:15 +02:00
Guido Cella
2becb971e9 console.lua: prettify unselected track log messages
After d49879f1f7 terminal escape sequences are printed in the console
log for unselected tracks. Remove them and make those lines grey.
2024-06-07 22:47:44 +02:00
Guido Cella
75645263dd select.lua: support extracting ytdl_hook subtitles
They don't work because they have EDL URLs, but we can attempt to
extract their real URLs.
2024-06-07 22:45:41 +02:00
Guido Cella
5657cd65b7 select.lua: hide the hour when it's 0
Omit the hour in the chapter and subtitle line selectors when the file
is shorter than an hour.
2024-06-07 22:45:41 +02:00
Guido Cella
8939bfc3ef select.lua: seek to the currect subtitle line when paused without video
Add an offset to sub seek correctly like in b35e34ae2f. The extra 0.01
offset apparently isn't necessary in this case.
2024-06-07 22:45:41 +02:00
Guido Cella
4059d1832b select.lua: preselect the correct sub line with duration >= 100 minutes
ffmpeg outputs timestamps like '100:00.00' in LRCs instead of adding
hours, and timestamps like '100:00' are < '10:00', so since these
strings are being compared, if there is no current subtitle line, there
are subtitle lines at >= 100 minutes, and time-pos is between 10 minutes
and 100 minutes, one of the last subtitle lines gets preselected.

Fix this by converting the timestamps to numbers before comparing them.

Also simplify the logic by merging the 2 loops to determine the default
line, and reformat the timestamps by adding hours to not print minutes >
60 in the selector, and by removing the hundredths of seconds. This
requires storing the accurate timestamps in a table to seek to them on
submit.
2024-06-07 22:45:41 +02:00
Guido Cella
d49879f1f7 loadfile: improve the format of terminal track information
Print vlang if present.

Make unselected tracks and editions grey instead of adding (+) before
selected tracks. Mark them with the same circles as show-text
${track-list} and script-message osc-tracklist when not outputting to a
TTY.

Don't print a different symbol with --sub-forced-events-only because
nobody uses this option, and subtitles are very unlikely to mix forced
and non-forced events.

Align 2-digit track IDs.

Align languages of up to 7 characters (the length of zh-Hans).

Leave spaces when a track has no language but at least another track
does to align the following track data with the other tracks.

Add a space between values and their units.

Convert Hz to kHz.

Pretty print FPS and kHz with mp_format_double().

Don't print images' FPS because it's just a bogus value taken from
--mf-fps.

Co-authored-by: Kacper Michajłow <kasper93@gmail.com>
2024-06-07 22:24:25 +02:00
UNIVPM-S1079707
b6d7f778b8 osc.lua: fix user configurable colors 2024-06-07 19:45:46 +02:00
nanahi
31ae111ff5 default.js: handle canceled key bindings 2024-06-06 23:38:39 +03:00
nanahi
eeb8e6e451 defaults.lua: handle canceled key bindings
There is a subtle behavior difference for built-in/input.conf key bindings
and key bindings registered by scripts: when a key binding is canceled
(e.g. a mouse button is bound to a command, is pressed down, and then
another key is pressed which is bound to another command), the command is
not invoked if the binding is built-in/input.conf, but is invoked if it's
registered by scripts, because it's handled with a different mechanism,
which gives no way for scripts to detect this.

Fix this by using the newly available canceled flag to detect this.
If a key binding is canceled, the callback is now not invoked unless
the key binding is registered with the complex option. In this situation,
the callback is invoked with the canceled state available so that scripts
can detect and handle this situation.
2024-06-06 23:38:39 +03:00
nanahi
5fcbe1c417 command: add canceled state to key-binding client message
This allows libmpv clients to know whether the key binding is canceled
and thus should normally be ignored.
2024-06-06 23:38:39 +03:00
Kacper Michajłow
f40b569426 player/main: concat string at compile time 2024-06-05 19:16:35 +02:00
Dudemanguy
fa89082f2e sub: avoid unneeded calls to is_animated
4e5d996c3a added this as part of a series
of patches written to avoid wasteful sub redraws when playing a still
image with subs. The is_animated special case was specifically for ASS
subtitles that have animations/effects and would need repeated redraws
in the still image case. This check was done unconditionally for all ASS
subtitles, but for very big ASS subtitles, this text parsing can get a
bit expensive.

Because this function call is only ever needed for the weird edge case
of ASS subtitles over a still image, some additional logic can be added
to avoid calling is_animated in the vast majority of cases. The animated
field in demux_packet can be changed to a tristate instead where -1
indicates "unknown" (the default state). In update_subtitle, we can look
at the current state of the video tracks and decide whether or not it is
neccesary to perform is_animated and pass that knowledge to sd_ass
before any subtitle packets are decoded and thus save us from doing this
potentially expensive call.
2024-06-04 12:29:13 +00:00
Kacper Michajłow
d70a0b4494 player/playloop: remove now unused get_percent_pos() 2024-06-03 19:16:35 +02:00
Kacper Michajłow
37127276cc win32: quantize taskbar playback position into uint8 range
Also, if the position is valid, set it to 1 / INF. Windows interprets 0
as non-progress.

Progress is quantized into uint8 range, it is good enough for this
use-case. This avoids unnecessary vo_control and
ITaskbarList3::SetProgressValue calls and should be visually
indistinguishable in practice.

Fixes #14282
2024-06-03 19:16:35 +02:00
nanahi
cfc651a805 osd: don't use get_percent_pos function
Use get_current_pos_ratio instead, and round the value to integer with
printf precision specifier.
2024-06-03 15:14:40 +02:00
nanahi
b77c5168b4 command: simplify printing floats as integers
For this purpose, the printf precision specifier can be used.
No need to call lrint.
2024-06-03 15:14:40 +02:00
Guido Cella
525fa85932 osc.lua: fix lint warnings 2024-06-02 22:26:00 +02:00
Guido Cella
62868beffe ytdl_hook.lua: fix lint warnings 2024-06-02 22:26:00 +02:00
Guido Cella
fe760f2b8a console.lua: fix lint warnings 2024-06-02 22:26:00 +02:00
Dudemanguy
5988473b76 player: replace get_current_time with get_playback_time in some spots
The problem with using get_current_time is that it can return negative
values. Interally in mpv, we need this but for some spots negative
values are not great. Since the previous commit enforced nonnegative
returns for get_playback_time, we can use that instead. The two areas
changed here are watch later configfile writing (clearly should always
be a positive number) and the time-pos property (negative numbers are
nonsense for users). This fully fixes #10346.
2024-05-29 13:48:40 +00:00
Dudemanguy
d93f53b324 player/playloop: force get_playback_time to be at least 0
Except for MP_NOPTS_VALUE. We keep that as is. When this was originally
added in a73415584c, it appears like
having the time always start at 0 was the intent. In cases where
get_current_time returns a negative that isn't MP_NOPTS_VALUE, force
this to 0.
2024-05-29 13:48:40 +00:00
Dudemanguy
652036ba54 player: put speed adjustment back into playing_audio_pts
Effectively reverts 7051e94e4b. There's
been some confusion with how audio pts gets used internally in mpv which
leads to weird results. The crux of the problem is essentially that
playing_audio_pts can return negative numbers and in many places this is
not expected. This is the first step in trying to hopefully iron out all
the weird corner cases.
2024-05-29 13:48:40 +00:00
nanahi
eaae9e9cf5 player/video: fix incorrect VO frame duration and frame drops
The logic in question was added in 201bef7ee1
for the VDPAU vsync frame timing algorithm, but after the code was moved
around for several times, it is now used for all VOs with non-display-sync
mode (where the video is synced to audio or system time). It nonetheless
likely never did whatever it was intended for.

This "correction" reduced the VO frame duration by the amount that the
frame is fallen behind the ideal time. Since a frame is presented between
pts (the ideal time for which the frame is scheduled) and pts + duration
(the end time for which frame drop is determined), and pts is already
computed from the current time and the deviation from the ideal time, this
"correction" causes the end time to have the deviation added twice, which
is nonsense: if the deviation is -0.5x the frame duration, the frame is
dropped, even though it should be displayed from now to 0.5x the frame
duration from now.

It was not noticed at that time probably because the VDPAU secret rabbit
code undid some of its damage, and the subsequent development focus on
display-sync modes resulted in negligence and simplification of audio mode
(e.g. b8bcf0f466), but the generic VO frame
drop algorithm has been observed to cause inconsistent frame drops with
this "correction": playing a 59.94 Hz video at 2x speed on a 60 Hz display
results in spending over half of the time dropping adjacent frames instead
of every other frames, visually causing stuttering, while it should only
happen briefly when the pts is very close to vsync time.

Fix this by deleting this logic, making the VO frame always having the
duration of the video frame.

Fixes: 201bef7ee1
2024-05-29 13:39:32 +00:00
Guido Cella
15ea0d1987 console.lua: fix crash with set ;<Tab>
Fixes https://github.com/mpv-player/mpv/pull/14247#issuecomment-2134418206
2024-05-28 13:25:37 +00:00
nanahi
75f252c47c console.lua: fix crash if no completions exist
If complete is case-sensitive and no completions exist the script crashes
with the following:

Lua error: @console.lua:1417: attempt to concatenate local 'prefix'
(a nil value)
2024-05-28 13:24:16 +00:00
Guido Cella
021c5dedb1 playloop: don't loop when seeking to the end of cover art while paused
Fix the bug that seeking to the end of cover art while paused goes back
to the beginning of the file because of this condition meant for videos.

This doesn't check mpctx->vo_chain->is_sparse because prevent_eof should
be true with actual sparse videos.
2024-05-26 14:23:57 +00:00
Kacper Michajłow
c3bf2c72a6 select.lua: allow ffmpeg to print errors if it fails
Also don't print subprocess result to OSD, as it is not comprehensible.
2024-05-20 18:32:22 +02:00
nanahi
691a25de38 osc.lua: handle osd-scale-by-window runtime update
Allows the scale mode to be changed at runtime if vidscale is set to auto.
2024-05-20 18:29:44 +02:00
nanahi
de371a579f stats.lua: handle osd-scale-by-window runtime update
Allows the scale mode to be changed at runtime if vidscale is set to auto.
2024-05-20 18:29:44 +02:00
nanahi
85b3a6e567 {stats,osc}.lua: respect --osd-scale-by-window by default
This lets these scripts scale the elements with OSD by default.
2024-05-20 18:29:44 +02:00
nanahi
1f29d037a0 stats.lua: add add auto value to vidscale option
This adds auto to vidscale script option, which lets the scale be
inherited from OSD --osd-scale-by-window option.
2024-05-20 18:29:44 +02:00
nanahi
0c74199a8f osc.lua: add auto value to vidscale option
This adds auto to vidscale script option, which lets the scale be
inherited from OSD --osd-scale-by-window option.
2024-05-20 18:29:44 +02:00
rcombs
843259ad0f playloop: don't redraw without subs on quit
handle_osd_redraw is called while we're in the middle of the cleanup portion
of play_current_file (via kill_demuxers_reentrant and mp_idle). This happens
after we've torn down the subtitle track, so we end up requesting a redraw
from the vo, which results in a 1-frame flash of the video without subs
before we either quit or switch to the next file (or the force-window state).
This detects that condition and skips the redraw, without interfering with
drawing the osd during idle (eg for pseudo-gui mode).
2024-05-20 18:05:38 +02:00
Guido Cella
d3800a67fc console.lua: fix completing change-list ao/vo/gpu-context remove
The value of list options is a table not just for vf and af but for all
object settings lists. Extract just the names from the tables returned
when retrieving these options.
2024-05-20 17:58:28 +02:00
Guido Cella
5e65999eb2 console.lua: fix the max log lines calculation 2024-05-20 17:56:42 +02:00
Guido Cella
daba15b272 stats.lua: prevent freeze in certain cases with vidscale=no
If using --script-opts=stats-vidscale=no, until osd-height changes from
0 to the correct value, stats.lua's text sizes are multiplied by a scale
of 720, which with the default font size results in a font size of 5760.
Depending on the order of operations, if the stats are drawn at this
size before osd-height is updated, mpv freezes. I get this with
--input-commands=script-message-to stats display-stats-toggle in
conditional profiles, e.g.:

mpv --script-opts=stats-vidscale=no --include=<(echo $'[test]\nprofile-cond=true\ninput-commands=script-message-to stats display-stats-toggle') av://lavfi:testsrc

Fix this by setting a scale to 1 until osd-height is updated to the
correct value.
2024-05-20 17:56:17 +02:00
Guido Cella
657ad9db00 console.lua: use all available lines for selection
Refine populate_log_with_matches()'s logic to not reserve 2 lines for "n
hidden items" when it is not necessary. This avoids printing "1 hidden
items", and doesn't leave an empty line when there are hidden items only
in one direction.
2024-05-20 17:55:36 +02:00
Guido Cella
b82d437ea4 select.lua: strip trailing zeros from FPS values
Show e.g. "30 fps" instead of "30.000 fps".

Also switch to %.4f for consistency with pretty_print_double().
2024-05-20 17:54:57 +02:00