Commit Graph

422 Commits

Author SHA1 Message Date
Dudemanguy 80feac62f1 command: add platform property
This returns the value of the target OS that mpv was built on as
reported by the build system. It is quite conceivable that script
writers and API users would need to make OS-dependent choices in some
cases. Such people end up writing boilerplate/hacks to guess what OS
they are on. Assuming you trust the build system (if you don't, we're in
really deep trouble), then mpv actually knows exactly what OS it was
built on. Simply take this information at configuration time, make it a
define, and let mp_property_platform return the value.

Note that mpv has two build systems (waf and meson), so the names of the
detected OSes may not be exactly the same. Since meson is the newer
build system, the value of this property follows meson's naming
conventions*. In the waf build, there is a small function to map known
naming deviations to match meson (i.e. changing "win32" to "windows").
waf's documentation is a nightmare to follow, but it seems to simply
take the output of sys.platform in python and strip away any trailing
numbers if they exist (exception being win32 and os2)*.

*: https://mesonbuild.com/Reference-tables.html#operating-system-names
*: https://waf.io/apidocs/Utils.html#waflib.Utils.unversioned_sys_platform
2023-02-27 17:13:21 +00:00
Christoph Heinrich 048d4d8b75 player: set playlist title to media title if not set already
The playlist title only got set when it was specified in the
playlist file.
If there is a title after opening a file, that should also be reflected
in the playlist.

ref. #4780
2023-02-26 22:39:54 +00:00
Max Dunbar 5bd991f338 DOCS/input: remove experimental note from sub-text 2023-02-05 16:23:29 +00:00
Avi Halachmi (:avih) 86093fcae7 lua/js: remove user-data helpers
This reverts:
  3fb4140c lua/defaults: add user_data helpers
  68a20e7a javascript/defaults: add user_data helpers
  00510379 lua/js: fix user_data_del util function

As well as the lua/js parts of:
  3ec2a098 docs: document new user-data property

user-data and its sub-properties can be set/get/observed/deleted
via the standard properties interface, so there's no need for
additional helpers specific to user-data, which only added maintenance
burden.
2023-01-29 01:52:31 +02:00
rcombs 3ec2a0988a docs: document new user-data property 2023-01-28 14:37:24 -06:00
rcombs 04241ab731 player/command: add "del" command 2023-01-28 14:20:20 -06:00
NRK 25b66256d7 player: add window-id property
currently only supported on x11.

one practical use-case of this is wanting to embed something (such as
dmenu) into the mpv window to use as a menu/selection. there might be
other use-cases as well (e.g doing some shenanigans with `xdotool` or
whatnot).

it's currently possible to:

* listen for 'current-window-scale' change (to check if the
  window has been created or not)
* call an external tool like `xdo` or `xdotool` and grab the xid
  from mpv's pid.

however it adds unnecessary dependency on external tools when mpv is
fully capable of easily providing this information.

closes: #10918
2022-12-05 02:03:25 +00:00
25792431 beac0d729b DOCS: fix typo 2022-07-01 14:11:01 +00:00
Emanuele Torre 90d291dce7 DOCS/input: fix typo "NANME" -> "NAME" 2022-05-02 13:24:07 +00:00
Guido Cella c8125119fa DOCS/input: update the ASS tags documentation URL
The current one hasn't worked in years.
2022-04-21 16:53:46 +00:00
Guido Cella 120989f56a DOCS/{mpv,options}: document the watch later functionality
This adds a section to the documentation to explain how resuming
playback works, and in particular it explains how it affects which
playlist entry mpv starts playing from, since this feature was only
implied in the --playlist-start documentation.

It also groups the documentation of the watch later options together to
make them easier to find.
2022-04-21 15:07:56 +00:00
Guido Cella 4930667784 DOCS/input: mark chapter-list as writable 2022-04-07 16:21:22 +00:00
Guido Cella beac97ba07 DOCS/input: document subprocess more clearly
- Make it clearer that playback_only affects subprocess' behavior when
  the playback of the current playlist entry terminates, rather than
  when mpv quits.
- Explain when status is positive and when it is negative.
- Replace "exited gracefully" in status' and error_string's
  documentation with "terminated normally" so it can't be misinterpreted
  as exiting successfully.
- Reword the playback_only warning
2022-02-18 19:39:10 +02:00
Guido Cella b89ca0c552 DOCS/input: fix typo 2022-02-18 19:39:10 +02:00
Avi Halachmi (:avih) 9fd9239990 DOCS/input.rst: profile-list: profile-restore could be missing
Currently the profile-restore field is intentionally omitted if it
holds the default value (i.e. no values are stored for the profile,
and trying to restore would only warn).

See m_config_get_profiles at command.c .
2022-01-30 15:13:10 +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 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
Guido Cella 4a80de90d2 DOCS/input: fix subprocess typo 2021-10-26 20:29:18 +00: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
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) 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
Avi Halachmi (:avih) 3abb23d70f command: don't hardcode commands list to be repeatable
Previously, a list of commands was always considered repeatable.

This behavior was added at 6710527a (and moved around since then),
in order to fix #807 (impossible to make a repeatable list).

The problem was that a list doesn't have the normal repeatability
flags and so it was never repeatable, so it was hardcoded to be
repeatable instead. Presumably it was deemed good enough.

However, this made it impossible to have a non-repeatable list.

This commit changes the behavior so that a list repeatability is
that of the first command at the list.

This way, any list can be made either repeatable or non-repeatable
using the following idiom (e.g. at input.conf), based on the fact
that the "ignore" command is not repeatable by default:

  x            ignore; cmd1...; cmd2...   # non-repeatable
  y repeatable ignore; cmd1...; cmd2...   # repeatable

Fixes #7841
2021-08-17 22:45:39 +03:00
Guido Cella 013985b872 DOCS/input: update osd-ass-cc documentation
- Replace the legacy --osd-status-msg with the newer --osd-msg3.
- Escape \b in show-text "This is ${osd-ass-cc/0}{\b1}bold text".
- Link the Flat command syntax section because it's no longer true that
  you always need to escape \, since C escape sequences are not
  interpreted with single and custom quotes.
2021-08-16 01:33:11 +03:00
Dudemanguy 25cfc815f5 manpage: clarify window-scale behavior 2021-08-07 19:50:24 +00:00
Dudemanguy a0441ddb5e command: make current-window-scale writeable, 2nd attempt
The window-scale property mirrors the respective option (not the
effective scale derived from the current window size), and as such
setting its value to the same value it had before has no effect.
Specifically - the window will not resize.

This is consistent as far as property-option bridge behavior goes,
but we do end up with an issue that we can't set an arbitrary scale
and expect the window to always resize accordingly.

We do also have a current-window-scale property which does reflect
the actual window size, however, it's been read-only till now.

This commit makes current-window-scale RW so that it's now always
possible to set an arbitrary scale and expect the window to resize
accordingly (without affecting window-scale - like manual resize).

Also, mention window-scale no-effect-if-not-changed at the docs.

Based on code by @Dudemanguy from commit 873ae0d, with same effect.
2021-08-07 17:30:19 +03:00
Avi Halachmi (:avih) 2667dd6643 Revert "command: make current-window-scale writeable"
This reverts commit 873ae0de2a.

The next commit will restore this functionality, with the
following differences from the reverted commit:
- Smaller and simpler code change.
- On bad scale: use "Invalid value" (compared to "no such property").
- Doesn't combine the docs for window-scale and current-window-scale.
- Doesn't remove the docs for window-scale behavior prior to 0.31.0.
2021-08-07 17:30:19 +03:00
Dudemanguy 873ae0de2a command: make current-window-scale writeable
Somewhat confusingly, mpv has both a window-scale option and a
current-window-scale property. The documentation lists window-scale
under properties (and it is technically is one), but at its core it is
actually an option which means it behaves subtly different. Options in
mpv are runtime-configurable, but they only change anything if the value
of the option itself changes. window-scale is an option and not meant to
keep track of the actual scale of the window (intended behavior
introduced by d07b7f0). This causes window-scale to do nothing in
certain cases (ex: the window is manually resized and window-scale is
set to 1.00 again). This is logical and consistent with the behavior of
the rest of the mpv options, but it also makes it a poor candidate for
setting the mpv window scale dynamically.

As a remedy, we can just make current-window-scale writeable instead.
current-window-scale is intended to always report the actual scale of
the window and keep track of any window size changes made by the user.
By making this property also writeable, it allows the user to have more
intuitive behavior (i.e. setting current-window-scale to 1.00 always
sets the window to a scale of 1). Additionally, the default input.conf
is changed to use current-window-scale instead of window-scale. The
window-scale documentation under property list is removed since it is
already documented under options and users should probably set the
current-window-scale property instead in most cases.
2021-08-05 19:13:10 +00:00
hooke007 6b828113a8 DOCS/input.rst: key names: add shift modifier note
Fixes #9060
2021-07-30 11:08:19 +03:00
Avi Halachmi (:avih) 9f6cbf3a4d input: arguments quoting: support single-quotes
Users expect single quotes to work when the value includes literal
backslashes or double-quotes (or as general quoting like in shell).

The updated docs also include some previously-missing notes:
- newline is only supported in double quotes.
- adjacent (quoted) arguments don't join into one.

Supporting mixed quoting (adjacent quoted strings) would make
mpv's parsing more complete, but would require delicate effort of
larger scope, for two reasons:
- We'd need to also support escaping outside of quotes and do our
  best about backward compatibility.
- The parsed value can either be a substring of the input or
  a newly-allocated string, which would be delicate when joining.

Not critical to add right now.
2021-07-30 09:52:34 +03:00
Avi Halachmi (:avih) 73c9509720 input: argument custom quotes: use ` instead of !
Custom quotes were added in 4f129a3e and began with !, however, this
required quoting "!reverse" (used for the cycle-values command), which
is inconvenient, and was not taken into account when ! was chosen for
custom quotes. Also, ` is more natural for quoting than !.

This does break backward compatibility with the earlier form of custom
quotes, but at least we didn't make a release yet since custom quotes
were added (the last release - 0.33[.1] doesn't support it).
2021-07-30 09:52:34 +03:00
Guido Cella 3f0e8bd506 options: audio-display determines cover priority
Let audio-display determine whether embedded images or external cover
art tracks should be selected when both are present.

Attached pictures are given priority by default as requested in #8539.

Also updates references to attached pictures in the log and manpage to
refer to cover art as well.

Closes #8539.
2021-07-29 13:38:28 +00:00
Guido Cella ecd06a5d01 manpage: explain when properties are expanded 2021-07-27 20:35:07 +03:00
Guido Cella 23e3b0ad98 manpage: minor fixes
- The video filter to turn the video upside-down is vflip. There is no
  filter called "flip" so using it just causes an error.
- Reword a sentence.
- Add exact and all to the values accepted by cover-art-auto. They were
  implemented in 029ff1049b but not added to the accepted arguments.
2021-07-21 13:38:11 +03:00
Ripose c4f982637f command: adds support for secondary subs to sub-seek and sub-step
Modifies the sub-seek and sub-step commands with a second <flags>
argument to specify whether to seek/step on the primary or secondary
subtitles. The flag is used to index into the current_track array in
cmd_sub_step_seek.
2021-07-12 21:07:37 +00:00
Ripose 34cfe9d89b command: add secondary-sub-start and secondary-sub-end properties
Adds secondary-sub-start and secondary-sub-end properties by setting
the current_track index in the m_property's priv variable which later
gets accessed in get_times. Also adds a test of the secondary subtitle
time properties in tests/subtimes.js bound to 'T'.
2021-07-12 21:07:37 +00:00
Guido Cella f049acfd43 manpage: fix typo 2021-07-08 13:22:38 +00:00
Guido Cella b3fccf0803 player: add append-play flag to loadlist
Closes #5664.
2021-07-06 15:46:45 +00:00
Guido Cella 151b039879 manpage: mention cover-art-auto
--cover-art-auto affects rescan-external-files, and --autoload-files
affects cover art.
2021-05-28 16:10:48 +00:00
Avi Halachmi (:avih) 89684976ac win32: support the property 'focused'
And also change the existing WM_KILLFOCUS handler to return 0 instead
of 'break' (which later calls DefWindowProcW), as MSDN says we should
do for WM_{KILL,SET}FOCUS.

It seems that the 'focused' property is now supported by all main VOs:
x11, macOS, wayland, Windows.

TCT/sixel/caca probably don't support it, and unknown with SDL.

Fixes #8868
2021-05-27 13:49:07 +03:00
Zsolt Vadasz 83b4bc622a player/command: add secondary-sub-text property 2021-05-19 15:57:01 +00:00
Dudemanguy a88fdfde0c command: add display-width/display-height property
For some reason, this never existed before. Add VOCTRL_GET_DISPLAY_RES
and use it to obtain the current display's resolution from each
vo/windowing backend if applicable. Users can then access the current
display resolution as display-width and display-height as per the client
api. Note that macOS/cocoa was not attempted in this commit since the
author has no clue how to write swift.
2021-05-06 17:36:55 +00:00
Avi Halachmi (:avih) f3b2ea9de5 command: new property: pid (process id)
Fixes #7562
2021-05-01 16:07:04 +03:00
Dudemanguy 7df9ebda6c DOCS: clarify how client/script names work
This isn't really clearly stated anywhere and could understandably lead
to some confusion.
2021-04-29 15:56:11 -05:00
Dudemanguy 029cd8a813 command: osd-dimensions: return ints and doc fixes
Some subproperties in osd-dimensions were returned as doubles despite
actually being integers. Additionally, correct a highly misleading line
in the osd-width/osd-height documentation.
2021-04-29 15:37:33 +00:00
Tom Wilson d7f6eba233 player/command: add albumart argument to video-add
Enables marking of specific video sources as album art.

Co-authored-by: Jan Ekström <jeebjp@gmail.com>
2021-03-09 23:28:21 +02:00
Avi Halachmi (:avih) 4f129a3eca input.conf syntax: support custom quotes !XstringX!
Where X is any ASCII char chosen by the user. An argument is only
interpreted as custom-quoted if it starts with '!' and the line doesn't
end right after it. Custom quotes don't interpret backslash-escape.

This change only affects command arguments which mpv parses (not array
commands), and not tokens before the arguments (where applicable - key
name, input section, command prefixes, command name).
2020-12-31 12:54:33 +02:00
Avi Halachmi (:avih) bb439efe0d input.rst: fix typo commands -> arguments 2020-12-31 12:54:33 +02:00
Emanuele Torre 38275338ee doc: split BNF definitions of <command> and <argument> in separate lines
Having them in the same line made it hard to read them in the man page
since they are formatted in the same way and they look as though they
are only one definition.
2020-11-22 01:23:42 +02:00