summaryrefslogtreecommitdiffstats
path: root/player
Commit message (Collapse)AuthorAgeFilesLines
* stats.lua: display HDR peak in nitsdyphire2023-02-021-1/+1
| | | | | | | | The value of `sig-peak` is relative to the SDR peak. This is not a problem when used inside the player, but the `HDR peak` in stats should display human-readable information. So change to return the actual nits value of HDR. Closed https://github.com/mpv-player/mpv/issues/10127
* player/video.c: don't resync audio if video is an imageStratusFearMe212023-01-301-1/+1
|
* lua/js: remove user-data helpersAvi Halachmi (:avih)2023-01-292-43/+0
| | | | | | | | | | | | | | | 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.
* lua/js: fix user_data_del util functionrcombs2023-01-282-2/+2
|
* javascript/defaults: add user_data helpersrcombs2023-01-281-0/+24
|
* lua/defaults: add user_data helpersrcombs2023-01-281-0/+19
|
* player/command: add user-data propertyrcombs2023-01-281-0/+171
| | | | | | This will replace shared-script-properties in new usage. It can be used for all the same things, but is much more versatile. Clients can create arbitrary sub-objects, and text expansion can access them. For instance, if a script sets `user-data/my-script/property1` to "test", that value will be available by expanding ${user-data/my-script/property1}.
* javascript: add mp.del_property()rcombs2023-01-281-0/+8
|
* lua: add mp.del_property()rcombs2023-01-281-0/+9
|
* libmpv: add mpv_del_property() convenience functionrcombs2023-01-281-0/+6
|
* player/command: add "del" commandrcombs2023-01-281-0/+24
|
* player/client: support observing sub-propertiesrcombs2023-01-281-1/+26
| | | | This notifies if either a descendent or ancestor of the requested path is modified.
* audio: simplify implementation of property ao-volumeThomas Weißschuh2023-01-251-7/+4
| | | | | | | | | | | | | | ao-volume is represented in the code with a `struct ao_control_vol_t` which contains volumes for two channels, left and right. However the code implementing this property in command.c never treats these values individually. They are always averaged together. On the other hand the code in the AOs handling these values also has to handle the case where *not* exactly two channels are handled. So let's remove the `struct ao_control_vol_t` and replace it with a simple float. This makes the semantics clear to AO authors and allows us to drop some code from the AOs and command.c.
* msg: log-file set at mpv.conf: don't ignore early messagesAvi Halachmi (:avih)2023-01-231-2/+6
| | | | | | | | | | | | | | | | | Previously, if log-file was set not via a CLI option (e.g. set via mpv.conf or other config file, or set from a script init phase), then meaningful early log messages were thrown away because the log file name was unknown initially. Such early log messages include the command line arguments, any options set from mpv.conf, and possibly more. Now we store up to 5000 early messages before the log file name is known, and flush them once/if it becomes known, or destroy this buffer once mpv init is complete. The implementation is similar and adjacent, but not identical, to an existing early log system for mpv clients which request a log buffer.
* various: replace abort() with MP_ASSERT_UNREACHABLE() where appropriatesfan52023-01-123-4/+4
| | | | | | | | In debug mode the macro causes an assertion failure. In release mode it works differently and tells the compiler that it can assume the codepath will never execute. For this reason I was conversative in replacing it, e.g. in mpv-internal code that exhausts all valid values of an enum or when a condition is clear from directly preceding code.
* various: replace if + abort() with MP_HANDLE_OOM()sfan52023-01-121-4/+2
| | | | | MP_HANDLE_OOM also aborts but calls assert() first, which will result in an useful message if compiled in debug mode.
* player: don't force saving start in watch-later-optionsDudemanguy2023-01-091-2/+7
| | | | | | | | | | | | The watch-later mechanism has always unconditionally wrote start to files to save the playback position. When this was later expanded to watch-later-options, this logic was kept in place. But we don't actually have to unconditionally write this and can allow users to remove the option from the list if they want to. The start value still requires some special handling; it should always be written if possible regardless of the value changing. However, we can just place it within the default set of options for watch-later-options so it can be removed like any other.
* player: add video-sync=display-tempoChristoph Heinrich2023-01-092-8/+19
| | | | | | | | So far there was no way to sync video to display and have audio sync to video without changes in pitch. With this option the audio does not get resampled (pitch change) and instead the corrected audio speed is applied to audio filters.
* player: choose speed of smallest acceptable factor for display syncChristoph Heinrich2023-01-091-16/+13
| | | | | | Instead of choosing based on smallest deviation from set speed, use the speed change from the smallest factor that does not exceed `video-sync-max-video-change`.
* external_files: recognize webp files as cover artRon Shabi2022-12-291-0/+8
| | | | | | | | | | | | | mpv currently only recognizes jpg and png files named "AlbumArt", "Album", "cover", etc. which are in the same folder as the audio files as album/cover art and displays it when playing such audios. This feature adds support for webp files following the same naming scheme to be displayed as cover art for albums who have them. Webp variations are lower in priority compared to jpg or png files. Resolves: #11006
* external_files: set log level for potential files to traceNicolas F2022-12-211-1/+1
| | | | | | | | | | We ask users to freely share log files with us, which is usually okay, unless a user has some unrelated and potentially embarrassing files in their working directory. These would show up in the debug level message output that --log-file enables. Change the listing of potential external files to trace log level, to save the users and the developers the embarrassment.
* player: add window-id propertyNRK2022-12-051-0/+12
| | | | | | | | | | | | | | | | | | | | | 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
* osc: don't spam window-controls bindings on every renderDudemanguy2022-11-291-3/+9
| | | | | | | | | | | | | | | Not sure when this actually started happening, but it's probably been like this for years. Currently, the logic for the window-controls works by simply checking if the osc is visible and then either enabling or disabling the associated keybindings. The problem is that this can just constantly spam mp.enable_keybindings/disable_key_bindings on every single render call if the user disables the border at any point in time. This does a lot of pointless work and also results in the logs being spammed with lines like "disable-section". Clearly, this should just work like the code for checking the input keybindings just above it. Keep track of an internal state variable and check when it doesn't match the osc visibility. In that case, we can then either enable or disable the key bindings and just update the variable.
* player/video: add VOCTRL_CONTENT_TYPEDudemanguy2022-11-154-0/+18
| | | | | | | | | | | | mpv's core already keeps track of whether or not it thinks a track is an image. Some VOs (i.e. wayland) would benefit from knowing if what is currently being displayed is an image or not so add a new VOCTRL that signals this anytime we load a new file with a VO. Additionally, let's add a helper enum for signaling the kind of content that is being displayed. There is now MP_CONTENT_NONE (strictly for force window being used on a track with no image/video), MP_CONTENT_IMAGE, and MP_CONTENT_VIDEO. See the next commit for the actual usage of this (with wayland).
* player/main: log libplacebo version if built with itJan Ekström2022-11-151-0/+8
| | | | | As we start basing more and more functionality on it, it makes sense to start logging it more visibly as part of --version.
* console: add history deduplicationChristoph Heinrich2022-11-031-4/+21
| | | | | | | | | | | | | Deduplicate history like the fish shell. So for example entering "cmd 1" then "cmd 2" then "cmd 3" then "cmd 1" would result in a history of [cmd 2][cmd 3][cmd 1] instead of [cmd 1][cmd 2][cmd 3][cmd 1] Adds a function `history_add` to replace directly adding to history. Adds an option `history_dedup` to activate the deduplication. Defaults to on.
* ytdl_hook: reverse order of tracksChristoph Heinrich2022-11-011-1/+7
| | | | | | | | | | | | | Only matters when configuring ytdl_hook with `all_formats=yes`. So far the tracks were ordered from worst to best quality. Web players with quality selection always show the highest quality option at the top. Since tracks are usually listed with the first track at the top, that should also be the highest quality one. yt-dlp/youtube-dl sorts it's formats from worst to best. Iterate in reverse to get best track first.
* console: respect the top margin shared script propertyChristoph Heinrich2022-10-281-7/+17
| | | | | | | | | Console already respected the bottom margin to not overlap with the bottom bar from the OSC, but it would still overlap with the window decorations from the OSC. Now everything is clipped above the top margin and no superfluous lines are drawn.
* osc: scale rendered aspect ratio with window aspect ratioChristoph Heinrich2022-10-061-3/+7
| | | | | The logo stays centered better and it doesn't distort anymore due to a recent change in libass https://github.com/libass/libass/pull/645
* ytdl_hook: use subtitle `name` as title if availableChristoph Heinrich2022-09-231-1/+2
| | | | | So far the `ext` was always used as the title, but `name` is more appropriate when it's available.
* filters: lavfi: allow hwdec_interop selection for filtersPhilip Langdale2022-09-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Today, lavfi filters are provided a hw_device from the first hwdec_interop that was loaded, regardless of whether it's the right one or not. In most situations where a hardware based filter is used, we need more control over the device. In this change, a `hwdec_interop` option is added to the lavfi wrapper filter configuration and this is used to pick the correct hw_device to inject into the filter or graph (in the case of a graph, all filters get the same device). Note that this requires the use of the explicit lavfi syntax to allow for the extra configuration. eg: ``` mpv --vf=hwupload ``` becomes ``` mpv --vf=lavfi=[hwupload]:hwdec_interop=cuda-nvdec ``` or ``` mpv --vf=lavfi-bridge=[hwupload]:hwdec_interop=cuda-nvdec ```
* ytdl_hook: simplify exclude option parsingChristoph Heinrich2022-09-141-5/+2
| | | | | The parsing used to be unnecessarily complicated, now it's easier to read and understand.
* audio: try to use playback AO as hotplug AO firstThomas Weißschuh2022-09-112-3/+3
| | | | | | | | | | | | | | | | | | | | | When a platform has multiple valid AOs that can provide hotplug events we should try to use the one that also provides playback. Concretely this will help when introducing hotplug support for ao_pipewire. Currently ao_pulse is probed by ao_hotplug_get_device_list() before ao_pipewire and on the common setups where both AOs could work pulse will be selected for hotplug handling. This means that hotplug_init() of ao_pipewire will never be called and list_devs() has to do its own initialization. But if ao_pulse is non-functional or not compiled-in suddenly ao_pipewire *must* implement hotplug_init() for hotplugging events to work for all. Also if the hotplug ao_pulse connects to a PulseAudio instance that is not emulated by the same PipeWire instance as the playback ao_pipewire the hotplug events are useless.
* audio: add AOCONTROL_UPDATE_MEDIA_ROLEThomas Weißschuh2022-09-103-0/+30
| | | | | | This is used to notify an AO about the type of media that is being played. Either a movie or music.
* player/audio: remove explicit drain on EOFPhilip Langdale2022-08-231-2/+0
| | | | | | | | | | | | | | | We have previously had a problem where pull AOs (such as pipewire) would not reinitialize on a format change when going between two audio-only files. In such a situation, playback would stop after the first file. We initially attempted to fix this by explicitly draining on EOF, which solves that problem but introduces a blocking step where we don't actually want one, breaking gapless audio, and causing dropped frames at the end of playback for files with video in them too. So, let's undo these changes and do something better in the next commit.
* audio: don't try to drain non-existent AOThomas Weißschuh2022-08-211-1/+2
| | | | | | | | 52aed495cb ("audio: drain ao on EOF") introduced logic to drain an AO when EOF of the input has been reached. When no AO however is present this leads to a NULL-dereference. Fixes #10556
* ytdl_hook: improve track detectionChristoph Heinrich2022-08-171-13/+12
| | | | | | | | | | | | | | | | Every format that was not detected as a video format was added to the audio tracks. This resulted in e.g. YouTube storyboards from ending up in the list of audio tracks. Now formats that are already known to be neither video formats nor audio formats, will also not end up in any track list. Formats where it is unknown if they are video or audio get added to tracks if `force_all_formats` is used, otherwise only formats that are known to contain video or audio become video or audio tracks respectively. https://github.com/yt-dlp/yt-dlp/issues/4373#issuecomment-1186637357
* ytdl_hook: consistant behavior for single formatChristoph Heinrich2022-08-141-1/+17
| | | | | | | | | | | | | | One would expect that e.g. `--script-opts=ytdl_hook-all_formats=no --ytdl-format=bestaudio` and `--script-opts=ytdl_hook-all_formats=yes --ytdl-format=bestaudio` to play the exact same tracks without manual intervention. This already worked when two formats were requested. For a single format with `all_formats=yes` it would also play a track that was not requested when available. This was inconsistant with the behavior of `all_formats=no` (default), which would not play a second track when only a single one was requested. This combined with #10395 now plays the exact same tracks with `all_formats=yes` as without, even when only one format is requested.
* ytdl_hook: fix default track for single formatChristoph Heinrich2022-08-121-2/+2
| | | | | | | | | | | | | | | | | Tracks are marked as default tracks based on what yt-dlp/youtube-dl returns in the field `requested_formats`. The problem is that this field only exists when there is more then one requested format. So `ytdl-format=bestvideo+bestaudio` would have that field, but `ytdl-format=bestaudio` would not, leading to no tracks being marked as default tracks. The requested formats can also be found under `requested_downloads`, which exists regardless of the number of requested formats. However when there is more then one requested format, `requested_downloads` doesn't contain those formats directly and instead has a field `requested_formats` that is identical to the other `requested_formats`. Therefore use `requested_downloads` as a fallback for when `requested_formats` doesn't exist.
* audio: drain ao on EOFThomas Weißschuh2022-08-091-0/+1
| | | | | | | | | | This gives pull-based AOs the chance to play all queued audio. Also it will make sure that the audio has finished playing so we can reinitialize the AO if format changes are necessary. Fixes #10018 Fixes #9835 Fixes #8904
* ytdl_hook: fix playlist index extractionChristoph Heinrich2022-07-261-2/+4
| | | | | | | The example given in #3024 would not play the correct video when combined with `--ytdl-raw-options=yes-playlist=`. Allowing `youtube:tab` as extractor and correcting the id check fixes that.
* osc.lua: add osc-tcspace script optionRyan Hendrickson2022-07-191-0/+6
| | | | | | | | | | Generally, the hard-coded sizes used for the OSC elements are comfortable regardless of the font used, but the timecode fields have relatively many characters, and so are affected to a greater degree by fonts with a wider or narrower average character width than expected. This allow users to adjust the space reserved for the timecode fields to compensate.
* osc.lua: add osc-unicodeminus script optionRyan Hendrickson2022-07-191-2/+6
| | | | | | This option enables the use of the Unicode U+2212 Minus Sign character when displaying the time remaining, instead of "-" (U+002D Hyphen-Minus).
* ytdl_hook: always set HTTP headersChristoph Heinrich2022-07-181-2/+6
| | | | | In some cases HTTP headers were not set, leading to some sites not working despite being supported by yt-dlp/youtube-dl.
* js: key bindings: ensure priorities for same-key - againAvi Halachmi (:avih)2022-06-231-1/+1
| | | | | | | | | | | | Commit 7f4841ff sorted the bindings so that if the same key was bound more than once, then the newest binding takes priority (sorted last). However, it got the comparison function wrong, which means the result of the sort depended on the algorithm and not on the actual data, so the priority for keys with more than one binding was still arbitraty. Fix the sort function, and finally ensure that later binding acutally override earlier bindings of the same key.
* lua: command_native_async: make the callback optionalCogentRedTester2022-06-221-0/+1
| | | | | | | The documentation states that the callback is optional, but it actually was not. Now it's optional, as docuented.
* lua: command_native_async: always callback a-syncCogentRedTester2022-06-221-1/+1
| | | | | | | | | | | | | | | | | Previously if the raw command_native_async returned an error then the callback function was run directly. This meant that script writers potentially had to account for both synchronous and asynchronous logic in the callback, which can happen even with seemingly 'safe' commands if the mpv event queue is full. This was at odds with the Javascript implementation of the function, which always runs the callback asynchronously. Now the mp.add_timeout function is used to run the callback asynchronously on error, replicating the Javascript implementation. This provides consistency for developers in how the callback is handled in Lua, and increases consistency between the Lua and Javascript APIs.
* player: add tiff/tif (TIFF) to list of image extensionsAtticFinder655362022-06-071-1/+1
|
* player: add jxl (JPEG XL) to list of image extensionsAtticFinder655362022-06-071-1/+1
|
* osc.lua: add idlescreen and osc-idlescreenDudemanguy2022-06-041-8/+39
| | | | | | | | | | | | | | | This is mainly for other user scripts that may conflict with the osc logo in some way. Although it is possible to listen for shared-script-properties, this has many edge cases that could easily pop up. A user could want other OSC things to happen at the same time (say osc-message). They just don't want the logo. The idlescreen option disables all idlescreen related things (including the santa hat) if it is set to "no". A new script message (osc-idlescreen) is also added so users can easily toggle the value (passing "cycle" or just explictly setting "yes" or "no"). Some more discussion on this is found in the below github issues. https://github.com/mpv-player/mpv/issues/10201 https://github.com/CogentRedTester/mpv-file-browser/issues/55
* osc.lua: fix crash when calling osc-tracklist while idleCogentRedTester2022-05-191-1/+1
| | | | | | | | | | | | | | If the player is started with --idle and the osc-tracklist script-message is called then the tracks_osc table will be nil, which caused the OSC to crash due to attempting to index a nil value. This appears to be because the osc_tracklist variable is both initialised and updated by (ultimately) the render() function, which is not run when the player is idling. Rather than mess with the existing OSC logic it's easier to either add this single check, or alternatively to initialise the the tracks_osc table somewhere before this.
* player: check for argv before printing help textDudemanguy2022-05-161-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Both mpv's main function and the client API use mp_initialize to start up. In general, these work the same however the client API had one slight, unnecessary limitation: you can't start it up with idle=no. In practice, the libmpv profile (used with the client API) sets idle to yes, so it's rarely encountered, but there's no particular reason why this policy needs to be enforced. It turns out that mp_initialize does a quick check to see if there are any entries in the playlist and if idle mode is set. If not, it prints the help message and exits. Basically, it's just the part that handles the terminal message when you type "mpv" with no arguments. Unfortunately with idle=no, the client API also hits this code path, exits prematurely with 1 and thus returns an API error. Fortunately, the fix is very simple. If the client API is used instead of the "normal" mpv executable, then the mp_initialize function gets a NULL for the options argument. When starting mpv from the terminal (when you would want to see the before mentioned help text), there will always be at least an argv[0] (the mpv executable name itself) so we can reliably distinguish between the two. The other case where there could be no argv is if the pseudo-gui profile is used, but this always enforces idle so we don't have to worry about it either. In other words, with this combination of conditions (options, no idle, and no playlist entries), we can be sure this is from a user calling mpv in the terminal with no arguments. Therefore, other cases can be allowed which means client API users can initialize with idle=no. Fixes #10162.
* player: set EOF when seeking to end with keep-openDudemanguy2022-05-141-1/+4
| | | | | | | | | | | | | | | Normally with the keep-open option, mpv is supposed to set the eof-reached property to true so clients can possibly do interesting things at this step. However, there was actually an edge case where this property notification did not occur. If you use keep-open and then seek in the file past the end (so mpv stops), property notification is not actually sent in this case. Internally, mpv does a very exact seek at this step which also ends playback, but it does not set STATUS_EOF to the ao and vo before the core idle s