Commit Graph

3000 Commits

Author SHA1 Message Date
Dudemanguy fe6d9b6962 player: rearrange video sync opts/enums/defines
The video sync logic for mpv lies completely within its core at
essentially the highest layer of abstraction. The problem with this is
that it is impossible for VOs to know what video sync mode mpv is
currently using since it has no access to the opts. Because different
video sync modes completely changes how mpv's render loop operates, it's
reasonable that a VO may want to change how it renders based on the
current mode (see the next commit for an example).

Let's just move the video sync option to mp_vo_opts. MPContext, of
course, can still access the value of the option so it only requires
minor changes in player/video.c. Additionally, move the VS_IS_DISP
define from to player/core.h to common/common.h. All VOs already have
access to common/common.h, and there's no need for them to gain access
to everything that's in player/core.h.
2022-04-11 18:14:22 +00:00
Guido Cella 4d12dfb75a options.lua: remove unused function
val2str isn't used anywhere. Its only use was removed in dd3e52fe68,
when it was still part of osc.lua.
2022-04-08 19:20:49 +03:00
Guido Cella d6affda0a7 options: add osd-playing-msg-duration 2022-04-07 22:13:50 +00:00
sfan5 84821dbcb6 lua: use correct chunkname when loading script files
This was brought up in #10007 and it turned out mpv did not follow Lua conventions.
2022-03-23 21:09:53 +01:00
Avi Halachmi (:avih) b15b3f6711 ytdl_hook.lua: consider any subprocess status != 0 as error
Previously only status<0 was considered as error, but status>0 is
also an error (the process exit code). Change to status != 0.

This likely makes little to no difference in practice, because if
stdout is empty or can't be parsed as JSON then it's considered
an error anyway, but still, this is more correct.

Also, on error, add the complete subprocess result to the verbose log.
2022-03-03 15:01:40 +02:00
George Brooke 1a3e85ec33 ytdl_hook: fix url_is_safe to match URL protocols properly
Some youtube_dl extractors retrieve URLs which contain other URLs
inside of them, for example Funimation, like this:
https://example.com/video?parameter=https://example.net/something

The url_is_safe function uses a pattern to match the protocol at the
start of the URL. Before this commit, this pattern was not compliant
with the URL spec (see the definition of "A URL-scheme string"):
https://url.spec.whatwg.org/#url-writing
Therefore it would match any characters, including "://", until the
last occurence of "://" in the string. Thus the above URL would match
https://example.com/video?parameter=https
which is not in safe_protos so the video will not play.

Now the protocol can only start with a letter and only contain
alphanumerics, "." "+" or "-" as the spec says, so it will only match
the first protocol in the URL ("https" in the above example.)
Previously the URL also had to contain "//" after the ":". Data URLs
do not contain "//": https://datatracker.ietf.org/doc/html/rfc2397
so now the pattern does not look for "//", only ":".
2022-03-02 20:59:33 +02:00
Avi Halachmi (:avih) 57f42cee84 stats.lua: page 2 - frame timing: use fixed display order
Page 2 displays the frame timing info for each type (currently "Fresh"
and "Redraw"), but since they're unordered keys of a map, their
iteration order and hence their order on screen could (and did) change
depending on $things, which was annoying.

haasn thinks none of them should be considered more important (and
therefore maybe worthy of being displayed on top), so we go with
lexicographic order, which currently means that "Fresh" is first.

Fixes #9901
2022-02-23 02:20:49 +02:00
Avi Halachmi (:avih) 37927b65f7 stats.lua: graphs: fix bad rendering due to division by 0
This fixes two potential divisions by 0 at generate_graph(...):
- If v_avg is (given and) 0.
- if v_max is 0.

The former doesn't seem to happen in practice because v_avg is only
used at one generate_gpah call, where it's apparently not 0.

The latter triggers if all the graph values are 0 (hence v_max is
also 0).

The implication of these divisions by 0 is an invalid y-value which
ends up at the ASS coordinates string for the graph inner content.

On linux the value ends as "nan" (luajit) or "-nan" (lua 5.1/5.2), and
on Windows it's "nan" (luajit) or "-1.#IND00" (lua 5.1/5.2), maybe due
to msvcrt's snprintf.

All these strings are wrong as ASS numbers, but due to luck in how
libass parses the coordinates, "nan" and "-nan" result in empty graph
(which looks OK for "all values are 0"), while "-1.#IND00" is parsed
as -1, which breaks the graph rendering (affects other graphs too).

One example of "all values are 0" is at page 0 (internal performance
graphs) on Windows - because the cpu metrics don't work.
So this fixes at least page 0 on Windows with lua 5.1/5.2.

While at it, move the scale calculations to one place, which now
avoids division by 0, instead of duplicating this calculation.

In the future, we can consider improving the generate_graph API:
- It needs one peak value, but takes 3 (v_max, v_avg, scale) which
  are meshed into one final value.
- v_avg is only used in 1 of 6 call sites, but at the middle of the
  arguments, so all other call sites need to pass explicit "nil".
- "scale" is arbitrary and used to leave some space at the top of the
  graph. 5 places use 0.8, one uses 0.9. Could probably be unified.
2022-02-21 16:05:02 +02:00
Niklas Haas fbe154831a vo_gpu_next: refactor subtitle rendering
Render subs at the output resolution, rather than the video resolution.
Uses the new APIs found in libplacebo 197+, to allow controlling the OSD
resolution even for image-attached overlays.

Also fixes an issue where the overlay state did not get correctly
updated while paused. To avoid regenerating the OSD / flushing the cache
constantly, we keep track of OSD changes and only regenerate the OSD
when the OSD state is expected to change in some way (e.g. resolution
change). This requires introducing a new VOCTRL to inform the VO when
the UPDATE_OSD-tagged options have changed.

Fixes #9744, #9524, #9399 and #9398.
2022-02-21 12:01:44 +01:00
Dudemanguy 27c38eac10 options: add always to stop-screensaver
The stop-screensaver option is currently limited to a simple yes/no
option. While the no option does always disable mpv trying to stop the
screensaver, yes does not mean the screensaver is always stopped. The
screensaver will be enabled again depending on certain conditions (like
if the player is paused). Simply introduce a new value for this option,
always, which does exactly what the name implies: the screensaver will
always be disabled.
2022-02-18 22:04:08 +00:00
Avi Halachmi (:avih) 0197729949 osc.lua: seekbar hover: speed-up chapter access
This speeds up chapter name access while hovering the seekbar:

- Fetch the chapter-list property using observation rather than on
  every render while hovering the bar. Property access, especially
  with potentially lots of values (chapters), can be expensive-ish,
  and can involve locking, so the less per-render the better.

- Sort the list once (on change) to simplify the iteration logic when
  searching the chapter which matches the mouse position. It's still
  O(N) (no binary search currently), but with less work.

The cached sorted list is stored at the state. While there are other
places which access this property and could use this cache, for now we
don't touch them, because they're not performance-critical (on init
for the chapter markers, on ch_{prev,next} button click for OSD).

Caching properties using observation instead of using mp.get_property
can indeed speedup other places too, but it should be part of a system
rather than implemented per-property. Maybe some day.
2022-02-06 11:02:39 +02:00
Avi Halachmi (:avih) 7849a36beb js: utils.get_user_path: make wrapper of expand-path
When utils.get_user_path was added, the expand-path command didn't
exist. Now it does, so remove the C code, make it a trivial wrapper.

Keep this function for backward compat to not break scripts, but
technically it's not required anymore.
2022-02-04 12:53:16 +02:00
CogentRedTester 712ef65e2a auto_profiles.lua: don't warn if profile-restore=default
The code assumed that the value of the profile-restore field is
"default" for such profiles, but the C implementation is such
that the field is intentionally omitted in such case.

This resulted in incorrectly trying to restore such profiles. However,
there are no stored values with profile-restore=default, so it only
resulted in a harmless warning, but otherwise behaved correctly (i.e.
nothing is restored).

Fix the condition by taking into account that missing field means
"default", so that it doesn't try to restore in such case, and
avoid the warning.
2022-01-30 15:13:10 +02:00
Avi Halachmi (:avih) 9cddd73f67 Revert "options: add --sub-visibility=<primary-only|secondary-only>"
This reverts commit 04f0b0abe4.

It's not a good idea to unify the names only for visibility, while
keeping secondary-* for everything else.

This needs a bit more thought before we allow secondary sub to be
visible on its own.
2022-01-19 21:56:28 +02:00
Ripose 04f0b0abe4 options: add --sub-visibility=<primary-only|secondary-only>
Adds --sub-visibility choices 'primary-only' for only displaying the
primary subtitle track, and 'secondary-only' for only displaying
secondary subtitle track.

Removes --secondary-sub-visibility and displays a message telling the
user to use --sub-visibility=yes/primary-only instead.

These changes make it so that the default 'sub-visibility' bind 'v'
cycles through all the 'sub-visibility' choices, 'no', 'yes',
'primary-only', and 'secondary-only'.
2022-01-19 14:27:04 +00:00
chelobaka 1ab3f56df0 player: add thd (TrueHD) to whitelist of audio extensions 2022-01-19 14:00:05 +00:00
LaserEyess 471b3c2b59 player: fix parentheses warning with &&
Was tripping -Wparantheses as the && after the || was not explicitly
wrapped. However, due to operator precedence the intended effect was
still correct.
2022-01-18 13:49:19 +00:00
Niklas Haas 9e2c0b8baa sub: rename SUBBITMAP_RGBA to SUBBITMAP_BGRA
This was a misnomer, the actual channel order is IMGFMT_BGRA (as the
comment explicitly point out). Rename the enum for consistency.
2022-01-11 23:45:08 +02:00
Avi Halachmi (:avih) 2157bb1995 js: events registration: clarify breakage/fix
This commit is mainly for correcting the previous commit message.

The previous commit fixed an issue where [un]registering events above
the first event ID "hole" is not requested from libmpv, and that's
indeed true.

However, this had nearly zero impact in practice, because libmpv
enables all events by default anyway (except TICK).

Therefore, above the first ID "hole" [un]register requests are not
sent to libmpv, and the events just keep arriving.

But the callback functions are still added/removed correctly (at
defaults.js), and so the script is not called back even if unregister
did not actually happen with libmpv.

The only event which was affected is TICK - which is not enabled by
default as it's deprecated, and before the previous commit could not
be enabled.

So the fix is more a general correctness fix now that the IDs array
can have "holes", but with effctively no impact in practice.
2021-12-26 21:00:21 +02:00
Avi Halachmi (:avih) 5c5e35c1bc js: fix event registration (keys, script-message, more)
Commit 63205981 removed some events but left all other event IDs at
their original values, which created "holes" at the events IDs array.

The JS backend for mp.register_event maps a name to an ID by scanning
all IDs and stopping when the name was found or a NULL name was
returned. Lua does the same except that it doesn't stop on NULL name.

Previously it was not possible to have a NULL name before the end of
the array, but now it is possible due to the enumeration holes.

Fix by skipping missing names, like lua does.
2021-12-26 20:02:45 +02:00
sfan5 f9fd50c654 player: make deprecated track/chapter/metadata events internal
We still need these to track or notify of modifications to certain properties,
but they're now gone from the libmpv ABI.
2021-12-15 12:29:10 +01:00
sfan5 dfcd561ba9 lua: remove mp.suspend, resume and resume_all
These functions were deprecated in v0.21.0 and no-ops
since v0.23.0. The matching client API functions were
removed in the previous commit.
2021-12-15 12:29:10 +01:00
sfan5 632059816a libmpv: remove opengl_cb API and other deprecated symbols
Not all deprecated symbols were removed. Only three events were removed for now
since these are not used internally.
This bumps the library version to 2.0.
2021-12-15 12:29:10 +01:00
sfan5 72915e8b76 {player,video}: remove references to obsolete opengl-cb API 2021-12-15 12:29:10 +01:00
Aman Karmani 181656955b audio: fix typo 2021-12-03 14:04:58 -08:00
Leo Izen ac39af461d player: make --keep-open=always work with --loop-playlist
Allow --keep-open=always to work with --loop-playlist, where
before this patch it would work only on the last playthrough of the
playlist. This patch allows it to work on all playthroughs.

Fixes #9470.
2021-11-28 19:45:52 -05:00
Funami580 448fe0226b osc: fix cache displaying 60s in some cases
It was caused by string.format rounding e.g. 59.9 to 60.
2021-11-27 21:37:24 +02:00
Avi Halachmi (:avih) b8926dd484 osc: add options: chapters/playlist OSD, hover chapter format
Previously OSD was always displayed on {ch,pl}_{next,prev} left-click,
and seekbar-hover-chapter was always enabled and with fixed format.

Now it can be controlled with:
- chapters_osd, playlist_osd: yes/no (only affects left-click).
- chapter_fmt: lua string.format template, or "no" to disable.

Fixes #4675
2021-11-25 21:20:48 +02:00
Umar Javed 923c0f0370 ytdl_hook.lua: improve check for sub language before inserting all-subs
youtube-dl and yt-dlp both support --sub-langs and --srt-lang in
addition to --sub-lang for defining languages of subtitles. This hook
only checked for sub-lang in --ytdl-raw-options and inserted --all-subs
in its absence.
2021-11-15 15:08:22 +01:00
Emil Velikov b44f522dba options: const annotate all m_opt_choice_alternatives accessors
Constant data, most accessors are good but some were missing the
explicit notation.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-11-15 14:02:08 +00:00
Emil Velikov f09396ab7d options: const annotate m_obj_list accessors
Nearly all the code base correctly references the data as constant. But
a couple of instances - fix those.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-11-15 14:02:08 +00:00
Niklas Haas 8bd0dee531 osdep: rename MP_UNREACHABLE
It was pointed out on IRC that the name is misleading, since the actual
semantics of the macro is to assert first.
2021-11-03 15:15:20 +01:00
Niklas Haas c704824b45 osdep: add MP_UNREACHABLE
This seems to work on gcc, clang and mingw as-is, but I made it
conditional on __GNUC__ just in case, even though I can't figure out
which compilers we care about that don't export this define.

Also replace all instances of assert(0) in the code by MP_UNREACHABLE(),
which is a strict improvement.
2021-11-03 14:09:27 +01:00
Avi Halachmi (:avih) f6b834a2fc js: ~~/init.js: use mp.find_config_file
The problem with the previous code - which used mp.get_user_path, is
that it returns a path even with --no-config, and even if the file
doesn't exist.

This is why we tested the "config" property, and also used
mp.utils.file_info to check that the file exists.

mp.find_config_file doesn't return a path with no-cofig and doesn't
return a path if the file doesn't exists. It's simpler and better.
2021-11-01 14:31:18 +01:00
Guido Cella 87c9eefb29 console.lua: define remaining emacs keybindings 2021-11-01 23:42:16 +11:00
Avi Halachmi (:avih) 32e851d2bc lua: makenode: prevent lua stack corruption
Normally there was no issue, but when the code converted a deeply
nested table into an mpv node - it didn't ensure the stack has room.

Lua doesn't check stack overflow when invoking lua_push* functions,
and leaves this responsibility to the (c) user via lua_checkstack.

Normally that's not an issue because when a lua (or autofree) function
is called, it's guaranteed at least LUA_MINSTACK (20) pushes.

However, pushnode and makenode are recursive, and each iteration can
add few values at the stack (which are popped when the recursion
unwinds), so checkstack must be used on (recursive) entry.

pushnode already checked the stack, makenode did not.

This commit checks the stack at makenode as well. The value of 6
(stack places to reserve) is with some room to spare, and in pratice
each iteration needs 2-3 at most (pushnode also leaves room).

Example which could previously corrupt the stack:
  utils.format_json({d1={d2={<8 more times>}}}

This uses makenode to convert the lua table into an mpv node which
the json writer uses as input, and if the depth is 10 or more then
corruption could occur. mp.command_native is also affected, as well as
any other mp/utils command which takes a lua table as input.

While at it, fix the error string which pushnode used (luaL_checkstack
uses the provided string with "Stack overflow (%s)", so the user
message only needs to be additional info).
2021-10-20 12:07:30 +03:00
Avi Halachmi (:avih) 2249f3f81a lua: autofree infrastructure: x2 faster
The speedup is due to moving big part of the autofree runtime overhead
(new lua c closure) to happen once on init at af_pushcclosure, instead
of on every call. This also allows supporting upvalues trivially, even
if mpv doesn't use it currently, and is more consistent with lua APIs.

While x2 infrastructure speedup is meaningful - and similar between
lua 5.1/5.2/jit, in practice it's a much smaller improvement because
the autofree overhead is typically small compared to the "real" work
(the actual functionality, and talloc+free which is needed anyway).

So with this commit, fast functions improve more in percentage.
E.g. utils.parse_json("0") is relatively fast and is now about 25%
faster, while a slower call like mp.command_native("ignore") is now
about 10% faster than before. If we had mp.noop() which does nothing
(but still "needs" alloc/free) - it would now be about 50% faster.

Overall, it's a mild performance improvements, the API is now more
consistent with lua, and without increasing code size or complexity.
2021-10-19 15:45:16 +03:00
Avi Halachmi (:avih) 4703b74e6c js: custom-init: use ~~/init.js instead of ~~/.init.js (dot)
mpv doesn't have other dot files in its config dir, and it also
shouldn't be "invisible".

The new name ~~/init.js now replaces ~~/.init.js

While mpv usually deprecates things before outright removing them,
in this case the old (dot) name is replaced without deprecation:
- It's a bad idea to execute hidden scripts, even if at a config dir,
  and we don't want to do that for the next release cycle too.
- We warn if the old (dot) name exists and the new name doesn't,
  which should be reasonably visible for affected users.
- It's likely niche enough to not cause too much pain.

If for some reason both names are needed, e.g. when using also an old
mpv versions, then the old name could be symlinked to the new one, or
simply have one line: `require("~~/init")` to load the new name, while
a new mpv version will load (only) the new name without warning.
2021-10-19 15:43:39 +03:00
Guido Cella e16d0dd15d command: with lavfi-complex, make current-tracks return the first one
This behavior is more convenient and allows profile conditions like:

[video]
profile-cond=get('current-tracks/video/image') == false

[image]
profile-cond=get('current-tracks/video/image')

Otherwise, these profiles have to be manually applied and restored in a
script.

The note about discouraging the use of current-tracks in scripts is
removed, because it makes people avoid using this convenient property.
It was added in 720bcd79d0 without leaving an explanation of why you
shouldn't use it, and the only reason seems to be that it doesn't work
with lavfi-complex, but this commit changes that.
2021-10-15 15:11:00 +00:00
Guido Cella 9954fe01a9 player: add track-list/N/image sub-property
This exposes whether a video track is detected as an image, which is
useful for profile conditions, property expansion and lavfi-complex.

The lavf demuxer sets image to true when the existing check detects an
image.

When the lavf demuxer fails, the mf one guesses if the file is an image
by its extension, so sh->image is set to true when the mf demuxer
succeds and there's only one file.

The mkv demuxer just sets image to true for any attached picture.

The timeline demuxer just copies the value of image from source to
destination. This sets image to true for attached pictures, standalone
images and images added with !new_stream in EDL playlists, but it is
imperfect since you could concatenate multiple images in an EDL playlist
(which should be done with the mf demuxer anyway). This is good enough
anyway since the comment of the modified function already says it is
"Imperfect and arbitrary".
2021-10-14 15:39:07 +00:00
Avi Halachmi (:avih) f386fd79b2 js: custom init: ignore ~~/.init.js with --no-config
The custom init script should be considered a configuration file, and
as such it should be ignored when the user wants vanilla mpv - and now
it is ignored with --no-config.
2021-10-12 14:12:24 +03:00
Avi Halachmi (:avih) ca6108baf4 osc.lua: avoid infinite ticks loop on idle
Before this commit, animation-end was handled at render(), however,
it's not called on idle, which resulted in state.anitype ~= nil, with
nothing to reset it during idle, which caused in an infinite tick()
loop (starts on first mouse move).

Now tick resets the animation on idle, and also, as a safety measure,
if we're past 1s after the animation deadline.

The safety measure is because the osc states are complex, and it's
easier to detect a "we really shouldn't be animating now" at tick()
itself rather than detecting the exact states where animation should
be reset. Generally, the safety mmeasure is not needed.
2021-10-03 19:52:58 +03:00
Avi Halachmi (:avih) bc6dab6d92 osc.lua: unify animation reset function (no-op) 2021-10-03 19:52:58 +03:00
Jan Ekström 5304e9fe31 Revert "player: add track-list/N/image sub-property"
Unfortunately, this functionality in large part based on a struct
member that was made private in FFmpeg/FFmpeg@7489f63281
in May. Unfortunately, this was not noticed during review.

This reverts commit 0862664ac9.
2021-10-02 16:55:13 +00:00
Guido Cella 0862664ac9 player: add track-list/N/image sub-property
This exposes whether a video track is detected as an image. This is
useful for profile conditions, property expansion and lavfi-complex, and
is more accurate than any detection even Lua scripts can perform, since
they can't differentiate between images and videos without container-fps
and audio and with duration 1 (which is the duration set by the mf
demuxer with the default --mf-fps=1).

The lavf demuxer image check is moved to where the number of frames is
available for comparison, and is modified to check the number of frames
and duration instead of the video codec. This doesn't misdetect videos
in a codec commonly used for images (e.g. mjpeg) as images, and can
detect images in a codec commonly used for videos (e.g. 1-frame gifs).

pix files are also now detected as images, while before they weren't
since the condition was checking if the AVInputFormat name ends with
_pipe, and alias_pix doesn't.

Both nb_frames and codec_info_nb_frames are checked because nb_frames is
0 for some video codecs (hevc, av1, vc1, mpeg1video, vp9 if forcing
--demuxer=lavf), and codec_info_nb_frames is 1 for others (mpeg, mpeg4,
wmv3).

The duration is checked as well because for some uncommon codecs and
containers found in FFMpeg's FATE suite, libavformat returns nb_frames =
0 and codec_info_nb_frames = 1. For some of them it even returns
duration = 0, so they are blacklisted in order to never be considered
images.

The extra codecs that would have to be blacklisted without checking the
duration are AV_CODEC_ID_4XM, AV_CODEC_ID_BINKVIDEO,
AV_CODEC_ID_DSICINVIDEO, AV_CODEC_ID_ESCAPE130, AV_CODEC_ID_MMVIDEO,
AV_CODEC_ID_NUV, AV_CODEC_ID_RL2, AV_CODEC_ID_SMACKVIDEO and
AV_CODEC_ID_XAN_WC3, while the containers are film-cpk, ivf and ogg.

The lower limit for duration is 10 because that's the duration of
1-frame gifs.

Streams with codec_info_nb_frames 0 are not considered images because
vp9 and av1 have nb_frames = 0 and codec_info_nb_frames = 0, and we
can't rely on just the duration to detect them because they could be
livestreams without an initial duration, and actually even if we could
for these codecs libavformat returns huge negative durations like
-9223372036854775808.

Some more images in the FATE suite that are really frames cut from a
video in an uncommon codec and container, like cine/bayer_gbrg8.cine,
could be detected by allowing codec_info_nb_frames = 0, but then any
present and future video codec with nb_frames = 0 and
codec_info_nb_frames = 0 would need to be added to the blacklist. Some
even have duration > 10, so to detect these images the duration check
would have to be removed, and all the previously mentioned extra codecs
and containers would have to be added added to the blacklists, which
means that images that use them (if they exist anywhere) will never be
detected. These FATE images aren't detected as such by mediainfo either
anyway, nor can a Lua script reliably detect them as images since they
have container-fps and duration > 0 and != 1, and you probably will
never see files like them anywhere else.

For attached pictures the lavf demuxer always set image to true, which
is necessary because they have duration > 10. There is a minor change in
behavior for which audio with attached pictures now has mf-fps as
container-fps instead of unavailable, but this makes it consistent with
external cover art, which was already being assigned mf-fps.

When the lavf demuxer fails, the mf one guesses if the file is an image
by its extension, so sh->image is set to true when the mf demuxer
succeds and there's only one file.

Even if you add a video's file type to --mf-type and open it with the mf
protocol, only the first frame is used, so setting image to true is
still accurate.

When converting an image to the extensions listed in demux/demux_mf.c,
tga and pam files are currently the only ones detected by the mf demuxer
rather than lavf. Actually they are detected with the image2 format, but
it is blacklisted; see d0fee0ac33.

The mkv demuxer just sets image to true for any attached picture.

The timeline demuxer just copies the value of image from source to
destination. This sets image to true for attached pictures, standalone
images and images added with !new_stream in EDL playlists, but it is
imperfect since you could concatenate multiple images in an EDL playlist
(which should be done with the mf demuxer anyway). This is good enough
anyway since the comment of the modified function already says it is
"Imperfect and arbitrary".
2021-10-02 14:44:18 +00:00
Avi Halachmi (:avih) 6123e97e31 js: custom init (~~/.init.js): fail loudly on errors
Previously, loading ~~/.init.js was inside a try block, in order to
quietly ignore errors if the file doesn't exist.

However, that also prevented any real errors from showing up even when
the file does exist, and the script continued as if everything is OK,
while in fact the custom init script didn't complete correctly.

Now we first check if the file exists, and then load it without
try/catch, so that any error shows up normally (and abort the script).
2021-09-30 18:28:28 +03:00
Guido Cella cc4ada655a ytdl_hook.lua: search for yt-dlp by default
Because youtube-dl is inactive and the yt-dlp fork is becoming more
popular, make mpv use yt-dlp without any extra configuration.

yt-dlp is ordered before youtube-dl because it's more obscure, so users
who have yt-dlp installed are more likely to want to use it rather than
youtube-dl.

Fixes #9208.
2021-09-25 13:57:36 +02:00
Avi Halachmi (:avih) 007c728ad2 command: cycle: respect the prefix "repeatable"
The "cycle" command _declaration_ enables repeatability by default,
however, the command handler applies additional logic to augment it,
based on the property which is being cycled - using some guesswork.

Specifically, properties with discrete values are not repeatable
(like sub or osd-level), while continuous properties are repeatable
(like volume).

Previously, the "repeatable" prefix could not override this additional
logic.

This commit changes the behavior so that the logic affects only the
default repeatability (still based on the property like before),
however, the "repeatable" prefix is now allowed to override it.
2021-08-19 15:39:19 +03:00
Stefan de Konink 0c9e1e34fd stats.lua: typo lavfi-complex
Fix typo lavi-complex to lavfi-complex.
2021-08-15 12:27:40 +03:00
Guido Cella d8e5f6ff3a sub: show subs without duration on vid change
When changing video track with subtitles with unknown duration, they
aren't shown until you seek, cycle sub back and forth, or apply a video
filter. This is caused by reinit_video_chain_src() calling
reset_subtitle_state() -> sub/sd_ass.c:reset() -> ass_flush_events()
when ctx->duration_unknown is true.

The ass_flush_events() call was added in a714f8e so subs with unknown
duration wouldn't multiply on seek, i.e. when reset_subtitle_state() is
called from reset_playback_state(). So keep calling it from there, and
in reinit_video_chain_src() use just term_osd_set_subs(mpctx, NULL)
instead to clear any subtitles printed to the terminal. The
reset_subtitle_state() call was added in c1ac97b to "reset the state
correctly when switching between video/no-video", but with it removed I
no longer notice any issue doing that.
2021-08-13 17:16:43 +00:00