summaryrefslogtreecommitdiffstats
path: root/player/command.c
Commit message (Collapse)AuthorAgeFilesLines
* options: const annotate all m_opt_choice_alternatives accessorsEmil Velikov2021-11-151-1/+1
| | | | | | | Constant data, most accessors are good but some were missing the explicit notation. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
* options: const annotate m_obj_list accessorsEmil Velikov2021-11-151-1/+1
| | | | | | | 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>
* osdep: rename MP_UNREACHABLENiklas Haas2021-11-031-1/+1
| | | | | It was pointed out on IRC that the name is misleading, since the actual semantics of the macro is to assert first.
* osdep: add MP_UNREACHABLENiklas Haas2021-11-031-1/+1
| | | | | | | | | 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.
* command: with lavfi-complex, make current-tracks return the first oneGuido Cella2021-10-151-0/+10
| | | | | | | | | | | | | | | | | | | 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 720bcd79d03 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.
* player: add track-list/N/image sub-propertyGuido Cella2021-10-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | 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".
* Revert "player: add track-list/N/image sub-property"Jan Ekström2021-10-021-1/+0
| | | | | | | | Unfortunately, this functionality in large part based on a struct member that was made private in FFmpeg/FFmpeg@7489f632815c98ad58c3db71d1a5239b5dae266c in May. Unfortunately, this was not noticed during review. This reverts commit 0862664ac952d21fef531a8923a58ae575268fc5.
* player: add track-list/N/image sub-propertyGuido Cella2021-10-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 d0fee0ac33a. 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".
* command: cycle: respect the prefix "repeatable"Avi Halachmi (:avih)2021-08-191-1/+3
| | | | | | | | | | | | | | | | | 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.
* command: check for monitor par in window-scaleDudemanguy2021-08-091-0/+6
| | | | | | | | When performing the scaling calculations, the window scale properties do not bother checking for potential monitor par. The vo keeps track of this via vo->monitor_par. Simply multiply/divide the video's width or height depending on the value of monitor_par. We also clamp the values to avoid the values running away to infinity in extreme cases.
* command: check for rotation in window-scaleDudemanguy2021-08-091-0/+3
| | | | | | | | | | | | | | | The vo currently handles rotations in 90 degree steps and some VOs set this via VO_CAP_ROTATE90. When the rotation exactly hits either 90 or 270 degrees, this causes the values of dwidth and dheight to perfectly swap like one would expect. However, the mp_image_params_get_dsize function call in both of the window scale functions do not take this special case into account. So the width/height values returned will be incorrectly flipped in the 90 and 270 degree cases if the vo driver does implement VO_CAP_ROTATE90 (like vo=gpu). Fortunately, the mp_image_params struct keeps track of the rotation for us. So all we need to do is check if the image is rotated at 90 or 270 degrees and check that the current vo driver supports VO_CAP_ROTATE90. If so, then swap vid_w and vid_h to their true, correct values.
* command: merge window-scale code togetherDudemanguy2021-08-091-13/+3
| | | | | | | Based on a small patch originally written by @avih. Instead of duplicating the window-scale logic in update_window_scale, just call the mp_property_current_window_scale function with the M_PROPERTY_SET action and a NULL property.
* command: make current-window-scale writeable, 2nd attemptDudemanguy2021-08-071-0/+9
| | | | | | | | | | | | | | | | | | | | | | 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.
* Revert "command: make current-window-scale writeable"Avi Halachmi (:avih)2021-08-071-34/+25
| | | | | | | | | | | This reverts commit 873ae0de2af3bb84a11e5e57f6e3a8942b2263c2. 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.
* command: make current-window-scale writeableDudemanguy2021-08-051-25/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* command: handle changes to image-display-durationGuido Cella2021-07-251-0/+5
| | | | | | | | | | When changing image-display-duration at runtime, make the new value take effect immediately, rather than from the next playlist-position change. This allows toggling the slideshow mode while viewing images (without hacks like executing playlist-play-index current afterwards). All the conditions are just to be safe since even if you set time_frame while playing a video, it's immediately overwritten by the next value.
* command: adds support for secondary subs to sub-seek and sub-stepRipose2021-07-121-7/+26
| | | | | | | 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.
* command: add secondary-sub-start and secondary-sub-end propertiesRipose2021-07-121-4/+11
| | | | | | | 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'.
* player: add append-play flag to loadlistGuido Cella2021-07-061-3/+6
| | | | Closes #5664.
* command: add a missing comma to MP_EVENT_WIN_STATEDudemanguy2021-05-231-1/+1
| | | | In my defense, it still compiled.
* player/command: add secondary-sub-text propertyZsolt Vadasz2021-05-191-5/+19
|
* sub/osd: hide secondary subtitles if secondary-sub-visibility is falseZsolt Vadasz2021-05-191-0/+3
|
* command: add display-width/display-height propertyDudemanguy2021-05-061-1/+21
| | | | | | | | | 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.
* command: new property: pid (process id)Avi Halachmi (:avih)2021-05-011-0/+9
| | | | Fixes #7562
* command: osd-dimensions: return ints and doc fixesDudemanguy2021-04-291-6/+6
| | | | | | 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.
* player/command: add albumart argument to video-addTom Wilson2021-03-091-2/+6
| | | | | | Enables marking of specific video sources as album art. Co-authored-by: Jan Ekström <jeebjp@gmail.com>
* player/{core,loadfile}: make cover art loading more explicitJan Ekström2021-03-091-2/+3
| | | | | | | | | | | | | Now loading cover art through mp_add_external_file requires an additional argument to be set to true. This way not all video-add commands end up being marked as cover art when they move through mp_add_external_file, as originally changed in 55d7f9ded197d82d172b7baf74b1a07640361ae8 . Additionally, this lets us clean up some logic that would otherwise be duplicated between open_external_files and autoload_external_files, if the logic had been kept split from mp_add_external_file. Fixes #8358
* command: add label for on-all-workspaces commandEvgeny Zinoviev2021-02-211-0/+1
|
* player: make resetting of track selection to "auto" worksfan52021-01-161-9/+21
|
* player: allow vo to be switched at runtimesfan52020-11-271-0/+10
|
* command: mouse: generate MOUSE_{ENTER,LEAVE} if requiredAvi Halachmi (:avih)2020-11-161-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously the mouse command never ended up in enter/leave keypresses for the default section even when logically required, because input.c does not know the area of the default section and relies on something feeding it ENTER/LEAVE presses - which the VO typically does but the mouse command didn't. Now the mouse command feeds it ENTER/LEAVE if required. It's possible to handle it differently and more consistently by: 1. reverting this commit. 2. Updating the default section area whenever the osd dimensions change. 3. Always ignore MOUSE_ENTER keys because the position is not known yet (but MOSE_MOVE typically follows right away). 4. On mouse move: first generate ENTER/LEAVE if required. That would guarantee consistency between mouse position and enter/leave events but could be more sensitive to manage (the default section has "infinite" area which is used to capture any event outside of specific section areas), while this commit keeps consistency same as before and depending on correct external feeding - which we now do better, even if still not optimally (like before, it's still technically possible that a script recieves MOUSE_ENTER and then reads the position before it got updated after the ENTER).
* command: mouse-pos property: add field "hover"Avi Halachmi (:avih)2020-11-161-2/+3
| | | | | | | | | | | | | | | | | | | | | Add a third field: "hover", which is updated from input.c after input keys MP_KEY_MOUSE_LEAVE and MP_KEY_MOUSE_ENTER - which are typically sent by the VO. It's part of mouse-pos and not a new property because it's highly tied to mouse-pos - it makes x/y invalid while the cursor doesn't hover the window. Unike mouse-move, no dummy command was generated, so we add dummy command in order for observer notification to work even while nothing is bound. Like mouse-pos, clients could not detect whether the mouse pointer hovers the window because the OSC force-binds the MOUSE_LEAVE key, and now they can using the hover field. The lua mp.get_mouse_pos() wrapper still returns only x, y because that's what osc.lua needs. Other clients can simply read the property.
* command: new property: mouse-posAvi Halachmi (:avih)2020-11-161-0/+30
| | | | | | | | | | | | | | | This is a read-only MPV_NODE value with integer fields: x, y. The values are unmodified from mp_input_get_mouse_pos(...). Observer notification of this property is tied to the INPUT_PROCESSED event, which fires after mouse move even if no command is bound (dummy commands are generated if nothing is bound to ensure that mp_input_get_mouse_pos returns the latest values - see ac927e39 ). This allows clients such as JSON IPC to observe mouse position even while the OSC is enabled - the OSC force-binds mouse move for most of the window area, making it impossible for other clients to bind mouse move without breaking the OSC.
* command: make subtitle time properties observableBen Kerman2020-11-111-1/+2
|
* command: add delete-watch-later-configVladimir Panteleev2020-10-221-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces the delete-watch-later-config command, to complement write-watch-later-config. This is an alternative to #8141. The general problem that this change is attempting to help solve has been described in #336, #3169 and #6574. Though persistent playback position of a single file is generally a solved problem, this is not the case for playlists, as described in #8138. The motivation is facilitating intermittent playback of very large playlists, consisting of hundreds of entries each many hours long. Though the current "watch later" mechanism works well - provided that the files each occur only once in that playlist, and are played only via that playlist - the biggest issue is that the position is lost completely should mpv exit uncleanly (e.g. due to a power failure). Existing workarounds (in the form of Lua scripts which call write-watch-later-config periodically) fail in the playlist case, due to the mechanism used by mpv to determine where within a playlist to resume playback from. The missing puzzle piece needed to allow scripts to implement a complete solution to this problem is simply a way to clean up the watch-later configuration that the script asked mpv to write using write-watch-later-config. With that in place, scripts can then register an end-file event listener, check the stop playback reason, and in the "eof" and "stop" case, invoke delete-watch-later-config to delete any saved positions written by write-watch-later-config. The script can then proceed to immediately write a new one when the next file is loaded, which altogether allows mpv to resume from the correct playlist and file position upon next startup. Because events are delivered and executed asynchronously, delete-watch-later-config takes an optional filename argument, to allow scripts to clear watch-later configuration for files after mpv had already moved on from playing them and proceeded to another file. A Lua script which makes use of this change can be found here: https://gist.github.com/CyberShadow/2f71a97fb85ed42146f6d9f522bc34ef (A modification of the one written by @Hakkin, in that this one takes advantage of the new command, and also saves the state immediately when a new file is loaded.)
* command: expose underlying pixfmt for hwdecsfan52020-10-161-0/+2
|
* options: simplify --android-surface-size handlingsfan52020-09-201-1/+1
|
* command, demux: make drop-buffers reset state even harderwm42020-09-171-2/+1
| | | | Leave nothing left when it's executed.
* command: add property track-list/N/main-selectionwnoun2020-09-121-0/+11
|
* player: fix inconsistent AO pause state in certain situationswm42020-09-121-7/+2
| | | | | | | | | | | | | | | | | | Pause can be changed during a file change, such as with for example --reset-on-next-file=pause, or in hooks, or by being quick, and in this case the AO's pause state was not updated correctly. mpctx->ao_chain is only set if playback is fully initialized, while the AO itself in mpctx->ao can be reused across files. Fix this by always running set_pause_state() if the pause option is changed. Could cause new bugs since running this used to be explicitly avoided outside of the loaded state. The handling of time_frame is potentially worrisome. Regression due to recent audio refactor; before that, the AO didn't have a separate/persistent pause state. Fixes: #8079
* command: add read-only focused propertyGuido Cella2020-09-081-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a property that returns whether the window is focused, currently only for X11 and Wayland. My use cause for this is having an equivalent of pause-when-minimize.lua for tiling window managers: make mpv play only while it's in the current workspace or is focused (I'm fine with either one but prefer focus). On X I do this by observing display-names, which is empty when the rectangles of the display and mpv don't intersect, but on Wayland its value doesn't change when mpv leaves the current workspace (and the same check doesn't work since the geometries still intersect). This could later be made writable as requested in #6252. Note that on Wayland se shouldn't consider an unactivated window with keyboard input focused. The wlroots compositors I tested set activated after changing the keyboard focus, so if you set wl->focused only in keyboard_handle_enter() and keyboard_handle_leave() to avoid adding the "has_keyboard_input" member, focused isn't set to true when first opening mpv until you focus another window and focus mpv again. Conversely, if that order can't be assumed for all compositors, we should toggle wl->focused when necessary in keyboard_handle_enter() and keyboard_handle_leave() as well as in handle_toplevel_config().
* command: extend subprocess command stdin, change behaviorwm42020-08-161-1/+26
| | | | | | | | | | | | | | | Make it possible to feed a string to stdin of a subprocess. Out of laziness, it can't be an arbitrary byte string. (Would require adding an option type that takes in a Lua byte string.) Do not set stdin of a subprocess to fd 0 (i.e. mpv's stdin) anymore, because it makes things more consistent. Enabling stdin didn't make too much sense in the first place, so this behavior change seems justifiable. win32 support missing. Fixes: #8003
* command: export alpha type in format propertieswm42020-08-151-0/+11
|
*