Commit Graph

50614 Commits

Author SHA1 Message Date
Dudemanguy e8a77e5279 player: add playlist-path properties
A bit of a long standing pain with scripting is that when opening a file
that gets interpreted as a playlist (like an m3u), the original path of
the file gets thrown away later. Workarounds basically consist of
getting the filename before mpv expands the path, but that's not really
reliable. Instead of throwing it away, save the original playlist path
by copying to the playlist entries when applicable (demuxer playlist and
the playlist option). Then expose these as properties: playlist-path for
the currently playing entry and playlist/N/playlist-path for each
specific entry. Closes #8508, #7605.
2023-08-13 19:58:20 +00:00
Dudemanguy a177fb6188 vf_vapoursynth: save display resolution as a variable
mpv has a generic method for getting the display resolution, so we can
save it in vf_vapoursynth without too much trouble. Unfortunately, the
resolution won't actually be available in many cases (like my own)
because the windowing backend doesn't actually know it yet. It looks
like at least windows always returns the default monitor (maybe we
should do something similar for x11 and wayland), so there's at least
some value. Of course, this still has a bunch of pitfalls like not being
able to cope with multi monitor setups at all but so does display_fps.
As an aside, the vapoursynth API this uses apparently requires R26 (an
ancient version anyway), so bump the build to compensate for this.
Fixes #11510
2023-08-13 19:58:20 +00:00
Dudemanguy c62b45ec2a player: add --term-remaining-playtime option
The OSC reports the speed-adjusted remaining time, but the terminal does
not. This is a weird mismatch and the OSC's default behavior makes
sense, so let's just do some division and add an option to disable it.
Also named "remaining-playtime" after the OSC option. Fixes #10445.
2023-08-13 19:58:20 +00:00
Dudemanguy 6ea08be59a player: make sub-pos a float value
mpv makes this option an integer, but the underlying ass API actually
accepts doubles. From some testing, there is no meaningful precision
difference between float or double (it seems to go in roughly 0.05
steps), so just make it a float. sd_lavc also can handle non-integer
values here. Closes #11583.
2023-08-13 19:58:20 +00:00
NRK 331832f55d x11_common: drop unnecessary NULL check
similar to free(), XFree() is a no-op if argument is NULL
2023-08-13 19:57:55 +00:00
NRK 5d2d7cde8e x11_common: avoid unnecessary XUnmapWindow() call
XDestroyWindow() is called immediately after, which also unmaps window
if needed. according to the manpage:

> If the window specified by the w argument is mapped, it is unmapped
> automatically.
2023-08-13 19:57:55 +00:00
Kacper Michajłow e85d70f84f stats.lua: use video-params/aspect-name 2023-08-13 15:04:33 +00:00
Kacper Michajłow 2a7639f452 player/command: add video-params/aspect-name
With pretty printed aspect ratio and related format.
2023-08-13 15:04:33 +00:00
fireattack 3954660f03 ytdl_hook: improve Windows exe search with suffix 2023-08-13 14:40:36 +00:00
Dudemanguy 598e30173d command: don't print "unknown" on video tracks
When printing the name of the video track on the OSC, mpv almost always
prefixes it with "unknown". This is referring to the language tag which
essentially nobody ever does for the video track since it doesn't make
any sense. Instead of putting unknown when there's no language, just
make it an empty string instead. "Unknown" confuses can confuse users
here and practically nobody would guess that it's referring to language.
We still will print the language for a video track in case someone out
there really does tag it, but that should be rare.
2023-08-11 22:28:50 +00:00
Dudemanguy fccb4466cd player/video: avoid spamming logs with EOF
When playing a sparse video stream, the debug log gets hit with the
video EOF constantly since the audio is still playing. There's no
practical use for this so just do add some logic to only signal it once
if it is sparse.
2023-08-11 22:28:50 +00:00
Dudemanguy 41c0321208 audio: drain ao before setting pause
There's an edge cause with gapless audio and pausing. Since, gapless
audio works by sending an EOF immediately, it's possible to pause on the
next file before audio actually finishes playing and thus the sound gets
cut off. The fix is to simply just always do an ao_drain if the ao is
about to set a pause on EOF and we still have audio playing.
Fixes #8898.
2023-08-11 22:28:50 +00:00
Dudemanguy 908dc79129 command: show "no" for hwdec-current if hwdec failed
Now actually matches the documentation (was an empty string not null).
Fixes #11464.
2023-08-11 22:28:50 +00:00
Dudemanguy 692ccca3a2 command: fix some fringe play-dir behavior
This is pretty obscure but if you screw around with the play-dir option
to essentially create a ping-pong loop; mpv will get hit by an assertion
error. What's happening here is that changing the play-dir always
requires a seek. This is handled in player/command along with the other
runtime option changes. However, queue_seek can actually clear the value
of mpctx->stop_play if the file is ending. So while loadfile is
terminating playback and the play-dir gets changed, the value of
mpctx->stop_play gets cleared because of seek. This then hits that
assertion later when mpv tries to finish the file.

The fix is to just add some weird logic to play-dir in player/command.
We have to be sure that mpctx->play_dir matches the new direction
immediately when we get the change so explictly set it here and don't
wait for it later. Secondly, keep the old value of mpctx->stop_play
before the seek and restore it afterwards. This ensures that termination
still happens cleanly and allows the ping-pong loop to work. Fixes #10782
2023-08-11 22:28:50 +00:00
Dudemanguy 02a80f850b sub/sd_lavc: don't check endpts when getting subs
When getting subtitles, sd_lavc checks if the current pts plus a small
offset (1e-6) is greater than the sub->pts as well as checking if the
pts is less than the sub->endpts. The problem with the endpts check is
that there are subtitles out there (pgs ones) that have overlapping
durations and thus you'll get a case where pts is greater than endpts
because a new subtitle shows up. However, the old subtitle is still
meant to be on the screen. This results in a flickering effect where the
subtitle flashes and then appears the next frame. The easy enough fix is
to just loosen the condition and remove the endpts check altogether.
That ensures that the subtitle remains selected for the entire duration.
Unsure if this possibly could regress some other kind of subtitle out
that that uses sd_lavc, but this does appear to fix a real issue with
pgs subtitles. Fixes #8202 and #10051.
2023-08-11 22:28:50 +00:00
Dudemanguy a323dfae42 sub: fix switching tracks while paused
Internal subtitles were not shown when switching between tracks while
mpv was paused. The reason for this is simply because the demuxer data
isn't available yet when the track switch happens. Fixing it is
basically just retrying until the packet is actually available when the
player is paused. Fixes #8311.
2023-08-11 22:28:50 +00:00
NRK 9ff2caff98 path-unix: abort on path truncation
instead of silently proceeding with a truncated path.
2023-08-12 00:20:27 +03:00
Dave dfbdf75165 osc: support speed-independent time-remaiing display
The new OSC config option "remaining_playtime" controls whether the
time-remaining display considers speed (yes - default) or ignores it.
2023-08-11 14:30:42 +03:00
llyyr b51036cdc0 command: fix stack smashing when displaying aspect-ratio
1df0a42a8c changed aspect-ratio from
floats to doubles, but forgot to change this function for
pretty-printing them as fractions for the video-aspect-override property
2023-08-11 13:04:52 +02:00
Dudemanguy 13c6e060e2 external_files: add sbv to the sub whitelist 2023-08-10 13:50:34 -05:00
Dudemanguy 5ffa3681ff external_files: alphabetize file extensions
Looks nicer.
2023-08-10 13:48:03 -05:00
lights0123 f118faed42 DOCS: update LGPL building instructions
previous build system used --enable-lgpl
2023-08-10 11:05:31 +02:00
Dudemanguy 1df0a42a8c m_option: change m_option_type_aspect to double
This specific option type is only used for the video aspect. The
underlying type was a float to represent the inputted value, but it's
actually not precise enough. When using something like 4:3, the values
of the incorrect digits are actually significant enough to make av_d2q
return a very funky numerator and denominator which is close to 4/3 but
not quite. This leads to some "off by one pixel" errors. Weirdly, mpv's
actual calculations for this were already being done as double, but then
converted to floats for this specific type. Just drop the conversion
step and leave it all as double which has the precision we need (i.e.
AVRational is now 4/3 for the this case). Fixes #8190.
2023-08-09 13:51:28 +00:00
Dudemanguy efefe3a6dc vo_gpu_next: actually fix screenshots with PAR
983e8f0100 resulted in the correct
dimensions, but it was not actually right because vo_gpu_next still had
the src and dst rects the same. This just needs to work like how vo_gpu
does where the src is the image params and the dst is desired output. So
basically, just copy that code over here. Fixes #12108 and as a bonus,
overriding the aspect ratio now results in correct screenshots
(previously didn't work at now and then with the above commit it had
correct dimensions but still incorrect output).
2023-08-08 21:28:10 -05:00
sfan5 bc52159cb9 ao_audiotrack: enable pcm-float by default
Since recent commits this should work 100% as well as s16.
2023-08-08 20:15:20 +02:00
sfan5 862011942f ao_audiotrack: support more channel layouts 2023-08-08 20:15:20 +02:00
sfan5 dae0340620 ao_audiotrack: support media role
maybe this is good for something, who knows
2023-08-08 20:15:20 +02:00
sfan5 9faf9932a4 ao_audiotrack: don't ignore ao_read_data return value
The difference this makes is that the OS API will notice
when we underrun (as opposed to being fed silence).
Other AOs mostly seem to not do this because they've committed
to filling a buffer of a certain size no matter what, but I have
not observed any ill effects for AudioTrack in my testing.
2023-08-08 20:15:20 +02:00
sfan5 8b7904618e ao_audiotrack: allow byte buffer data transfer for float samples 2023-08-08 20:15:20 +02:00
sfan5 36bea732fb ao_audiotrack: align buffer size to sample size
This looks like a pretty bad bug but only became a problem
with the last commit that allows rates like 22.5kHz to pass through
directly instead of being resampled.
2023-08-08 20:15:20 +02:00
sfan5 d9072fef2a ao_audiotrack: do not needlessly resample
Resampling when the driver says it isn't outputting more than
a certain rate anyway makes sense, the inverse does not.
2023-08-08 20:15:20 +02:00
sfan5 a949e58362 ao_audiotrack: fix broken exception checks
The exception always has to be checked and cleared even if we
can already see that no valid value was returned.
2023-08-08 20:15:20 +02:00
sfan5 efebd50a6c ao_audiotrack: remove unused writeV23
The piece of code where it would make sense to use this
never runs with API 21 or newer, so calling it there would be useless.
2023-08-08 20:15:20 +02:00
Dudemanguy 983e8f0100 vo_gpu_next: take into account PAR when taking screenshots
Using the width and height params directly doesn't actually work if PAR
is something other than 1. Instead, use mp_image_params_get_dsize and
calculate the correct dimensions which matches the vo_gpu behavior.
2023-08-07 21:09:30 -05:00
sfan5 a9c0ad149f ad_spdif: fix this not working at all
fixes 4c3ed843dc
closes #12102
2023-08-07 23:15:00 +02:00
Niklas Haas cf01646c39 vo_gpu_next: add ability to use named hook params
Closes: https://github.com/mpv-player/mpv/issues/12093
2023-08-07 19:34:44 +02:00
Kacper Michajłow 1b10d9dd9c mp_image: properly infer color levels for some pixfmts
ffmpeg does not tag yuv levels for GRAY formats, but apparently they
should be infered as full range. Instead of defaulting to limited range
always. Fixes (M)JPEG playback.

This mimic ffmpeg's behaviour.

See: d295b6b693/libswscale/utils.c (L926-L962)
Fixes: #12089
2023-08-07 18:22:41 +02:00
Niklas Haas 35a6b26b78 vo_gpu_next: increase non-interpolation queue size
1 is not enough to prevent PL_QUEUE_MORE, because the pl_queue is
designed to always know the next frame (in addition to the current).
Before haasn/libplacebo@112bb886, this was was (wrongly) silently
omitted by the pl_queue code, but that fix exposed this.

While it's technically API misuse on mpv side, due to the mpv vo code
having its own internal queueing and timing control, it shouldn't
actually make any difference in practice (and likely, the error message
showing up is the only meaningful bug here - the issue is entirely
cosmetic).

Fixes: https://github.com/mpv-player/mpv/issues/12101
2023-08-07 10:42:08 +02:00
Niklas Haas f6de44dd6a vo_gpu_next: update for new pl_filter configuration API
Configuration of filter parameters was moved from pl_filter_function (of
which the user had to make a copy) to pl_filter_config, with the
pl_filter_function remaining immutable.

Implement this new logic in a way that can reasonably exist side-by-side
with the old configuration API. Once we drop support for PL_API_VER
below 303, we can drastically simplify this code.
2023-08-06 22:44:54 +02:00
Dudemanguy 8417804224 win32: signal VO_EVENT_DPI on dpi changes
The win32 code already updates itself on dpi changes. However, it never
signalled mpv's core when this happened which meant that the
display-hidpi-scale property never changed. Simply send the
VO_EVENT_DPI event when appropriate. Fixes #12081.
2023-08-06 19:09:44 +00:00
Jan Ekström 10087b4086 test/meson: add missing avutil dependency to chmap test
Found out with a CI image where FFmpeg is not located in the default
sysroot.
2023-08-06 20:36:12 +03:00
sfan5 38b59408c2 test: indicate test function ran in log 2023-08-06 18:49:54 +02:00
sfan5 b68491e9a6 test: enable log messages for libmpv test 2023-08-06 18:49:54 +02:00
sfan5 5d71f858c2 test: refactor helper methods to be universally usable 2023-08-06 18:49:54 +02:00
m154k1 a173b47748 options: fix relative time parsing
Currently relative time parsing is buggy when any of the non-leading
units are non zero. For example, "-1:30" should result in -90 but
currently it results in -30 (as a result of `-60 + 30`).

Also reject timestamps where non-leading units are out of range. E.g.
"1:100" would be rejected, but "100" will still be accepted as 100
seconds.
2023-08-06 13:48:17 +02:00
m154k1 8a7cd20480 options: rename variables in parse_timestring 2023-08-06 13:48:17 +02:00
Philip Langdale e8144ac231 vd_lavc: repeatedly attempt to fallback if hwdec fails in reinit
In the same way that fallback in receive_frame() needs to be repeated
until we get a working decoder, we have to do the same thing in
reinit(). Calling force_fallback() only once can still yield a non
functional decoder.

The reason why we have these multiple paths which each require their
own fallback logic is that we can fail at different stages:
* hwdec init
* decoder init <- repeated fallback was missing here
* frame decoding

Fixes #12084
2023-08-06 04:42:13 -07:00
Alexander Georgiadis 6729285502 DOCS/options: fix typo in hdr-peak-percentile 2023-08-05 16:46:28 +02:00
Dudemanguy 59ac302dff vo_gpu/vo_gpu_next: fix setting an empty dscale
The manual currently says that if dscale is unset, --scale will be
applied. However, this only works at init time. If you change the dscale
filter to be empty later, vo_gpu will segfault and vo_gpu_next will
throw an error and refuse the changes. That's because when the option is
unset at runtime, the value becomes "" not NULL and the vo's never
accounted for this. Fixes #12031.
2023-08-05 14:01:02 +00:00
Niklas Haas 65a95a721e builtin.conf: add --hdr-peak-percentile=99.995 to gpu-hq
This is higher quality but comes with a slight performance hit,
especially for weaker iGPUs, so I don't want to enable it out of the box
even when --hdr-compute-peak=auto.
2023-08-04 16:58:44 +02:00