summaryrefslogtreecommitdiffstats
path: root/player
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* ytdl_hook: expose some JSON fields as tagsYour Name2021-05-111-0/+29
| | | | | | | | | | Shows uploader, channel, description fields. This works only if the media media is constructed as EDL (for youtube it usually does this), and if the all_formats option is not set to true (does anyone even use it?). The former usually happens because youtube serves audio and video separately, though it will not for live HLS/DASH. The latter uses delayed media opening, which breaks the global_tags mechanism (see previous commit).
* audio: fix replaygain being completely brokenYour Name2021-05-071-0/+1
| | | | | | | | | | | | | | | | | | Switching to a new file while keeping the AO didn't update the volume. While there's an explicit audio_update_volume() call in reinit_audio_chain_src(), it doesn't work, because at that point ao_chain->ao is still NULL, and it does nothing. That's pretty weird and might cause other problems (what happens if you try to mute while the AO is "floating"?). Regarding gapless, trying to use the AO gain for replaygain is also gross nonsense, because the new replaygain computed gain would affect audio from the previous file. It looks like replaygain should be in an af_volume filter maybe. On the other hand, I enjoy setting ridiculous replaygain-preamp values and compensating with a low volume setting, which would not work well if both gains were applied to the audio independently. For now, just add the missing call. This is orthogonal to fixing replaygain "properly".
* Revert "audio: set audio chain ao on reinit"Your Name2021-05-071-3/+1
| | | | | | | | | | | | This reverts commit 3239e41277173bace5ecc2a22910c4660642429c. I'm fairly sure this is wrong, and my next commit should fix it properly. I'm not really sure, though. Normally, the AO is set again by reinit_audio_filters_and_output() after the new audio chain has decoded a frame and knows the new format. The reason replaygain (and apparently the thing the reverted commit tried to fix) didn't work is because they work asynchronously to the audio played by the AO (i.e. buggy and hard to fix).
* 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.
* scripting (lua/js): utils.getpid: make wrapper of pid propertyAvi Halachmi (:avih)2021-05-014-16/+5
| | | | | | | | | We now have at least 3 scripting APIs which are trivial wrappers around properties: mp.get_mouse_pos, utils.getcwd, utils.getpid. After some discussion on IRC it was decided that it's easier for us to maintain them as trivial wrappers than to deprecate them and inflict pain on users and script authors, so currently no plan to deprecate.
* 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.
* audio: add two minor log messagessfan52021-04-291-2/+6
| | | | | This would have made the problem fixed in the previous commit a bit more obvious from the log output.
* osc: reset margins when using boxvideo with showfullscreen/showwindowedossifrage2021-04-271-1/+11
| | | | | | | | | | | | | | | | | | | This fixes a bug where using boxvideo with showfullscreen=no or showwindowed=no resulted in the margins not resetting when the OSC wasn't visible. For example, using: script-opts=osc-visibility=always,osc-boxvideo=yes,osc-showfullscreen=no and then going fullscreen would make the OSC disappear but the video margins would remain. This is because boxvideo was missing a dependence on the showfullscreen and showwindowed user options. This is fixed by adding the corresponding conditions to update_margins() and setting state.marginsREQ on fullscreen changes. update_margins() is called on tick() if there's a margins update pending, which guarantees the boxvideo margins are reset appropriately.
* osc: display immediately when visibility changes from never to alwaysossifrage2021-04-251-1/+2
| | | | | | | | | | | | | | | | | | | | | | Clearing state.osd.data with an empty string at render_wipe() fixes an issue where changing the OSC visibility from "never" directly to "always" didn't immediately update the display when the player was paused. This could be verified by starting the player with `--script-opts=osc-visibility=always --pause` and then running `script-message osc-visibility never` followed by `script-message osc-visibility always`. Removing the overlay without changing the contents meant the overlay wouldn't update and display when enabled again until the fields changed in some way (e.g. seeking, mousing over the OSC area, etc.). Clearing state.osd.data before removal of the OSC makes sure set_osd doesn't return on re-enable and instead displays the OSC immediately as the data is now different. render_wipe() is now also used when the OSC needs to be cleared at tick() as using set_osd to clear it with an empty string did not call state.osd:remove() which can allow cleanups related to bitmap memory allocations etc.
* audio: set audio chain ao on reinitDudemanguy2021-04-181-1/+3
| | | | | | | | | Seems to be a slight corner case with the audio API rewrite. When switching from one file to another one, the volume of the ao would never be set because the audio chain's ao wasn't set. This caused a bug with the reset-set-on-file option. The volume/property would be correctly set internally, but the gain was not actually set when the file switched. Fixes #8287.
* player/scripting: fix use-after-free when loading script folderssfan52021-04-081-2/+3
|
* demux: Move demuxer help to new standard mechanismPhilip Langdale2021-03-281-8/+0
| | | | | Previously, demux help was handled as a special case in main.c and this is no longer necessary.
* stats.lua: include a filter's @label when displaying filters on page 1Chris Varenhorst2021-03-151-0/+4
|
* audio: prevent uninit_audio_out during encodingTom Wilson2021-03-151-1/+2
| | | | | | | | | | | There was a simple oversight that meant audio outputs were uninitialized during an encoding, which is not allowed, the encoding would stop with numerous errors. I added a single line to prevent the call of uninit_audio_out in reinit_audio_chain if the encoder was active and this appears to have fixed the problem without breaking anything else. Fixes #8568
* 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-093-10/+16
| | | | | | | | | | | | | 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
* ytdl_hook: fix crash on missing track bitraternhmjoj2021-03-081-1/+1
| | | | | | | | Some tracks happen to lack bitrate information (ie. no tbr value). In that case, just ignore the track while computing the max bitrate. For an example, this is a stream in which all audio tracks have no bitrate: https://www.raiplay.it/dirette/rai1
* 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
|
* console: use wl-paste on WaylandGuido Cella2020-12-141-1/+11
|
* auto_profiles: fix compile_cond on lua 5.1Philip Sequeira2020-12-081-6/+10
| | | | | | 5.1's load() doesn't accept strings; loadstring must be used instead. In 5.2, loadstring is deprecated and setfenv is gone.
* player: allow vo to be switched at runtimesfan52020-11-273-7/+23
|
* 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.
* lua/js: mp.get_mouse_pos: use the mouse-pos propertyAvi Halachmi (:avih)2020-11-164-22/+6
| | | | | | | mp.get_mouse_pos() is undocumented and is no longer required - the property can be used officially by any client now, however, osc.lua uses it, and also some user scripts learnt to rely on it, so we keep it - as a trivial wrapper around the new mouse-pos 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: add internal INPUT_PROCESSED eventAvi Halachmi (:avih)2020-11-162-0/+5
| | | | | | Fires after a non-empty input queue was processed. Currently yet unused, but the next commit will use it.
* js: report scripts CPU/memory usage statisticsAvi Halachmi (:avih)2020-11-151-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This can be viewed at page 4 of the internal stats display (i or I). CPU time report is the same as at lua.c, but untested - doesn't seem to work on windows - also not for lua. TL;DR: Set env MPV_LEAK_REPORT=1 to enable js memory reporting stats. This also almost doubles the memory usage by js scripts. For memory reporting, we don't have enough info by default, because even when using a custom allocator, mujs doesn't report the old size (on free or realloc) because it doesn't track this value, and as a result we can't track the overall size. Our option are either to track the size of each allocation on our own, or use talloc which tracks this value. However, using talloc for mujs allocations adds a considerable overhead, and almost doubles(!) the overall memory used, because each individual allocation includes a considerable talloc header, and mujs does many small allocations. So our solution is that by default we behave like previously - not using a custom allocator with mujs, and stats does not display memory usage for js scripts. However, if the env var MPV_LEAK_REPORT is set to 1, then we use a custom allocator with talloc and track/report memory usage. We can't switch allocator at runtime, so an mpv instance either tracks or doesn't track js scripts memory usage, according to the env var. (we could use a property and apply it whenever a new script starts, so that it could change for newly launched scripts, but we don't).
* command: make subtitle time properties observableBen Kerman2020-11-111-1/+2
|
* player: fix external cover file prioritizationsfan52020-10-281-4/+8
| | | | | Array order was ignored entirely instead of being used as intended. Fixes: c07089a250
* console: let type set the cursor positionGuido Cella2020-10-271-4/+10
| | | | | | | | | | | | | | | | | | This allows keybindings such as: a script-message-to console type "seek :0 absolute" 6 % script-message-to console type "seek absolute-percent" 6 The cursor position 0 isn't allowed because it has the weird effect of filling the console with the text twice, leaving the cursor in the middle. Negative positions would put the cursor n characters before the end, and positions greater than the text's length at the end. They seem to work at first, but the console breaks when you move the cursor, so they aren't allowed. It seems that float values don't cause issues, but I'm using the argument's floor anyway to be safe. Using >= 1 instead of > 0 ignores values like 0.5.
* ytdl_hook: if ytdl not found in config dirs, use ytdl_path as isRicardo Constantino2020-10-271-1/+4
|
* ytdl_hook: support alternative youtube-dl pathRicardo Constantino2020-10-271-2/+4
| | | | | Allows using a youtube-dl not in PATH or a compatible fork of youtube-dl.
* player: reorder list of external cover files for optimal resultssfan52020-10-251-7/+9
|
* command: add delete-watch-later-configVladimir Panteleev2020-10-223-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.)
* stats: display hw pixel format toosfan52020-10-161-0/+4
|
* command: expose underlying pixfmt for hwdecsfan52020-10-161-0/+2
|
* player: fix another nightmarish corner casewm42020-10-081-3/+14
| | | | Pretty much fuck this shit.
* screenshot: add --screenshot-sw optionwm42020-10-051-1/+2
| | | | | Probably worthless. As usual, the manpage dumps all the subtle differences due to implementation details on the user.
* player: cosmetically change around some codewm42020-09-281-9/+9
| | | | Is this better?
* player: add automatic loading of external cover art fileswm42020-09-283-5/+50
| | | | | | | | | | | | | | | | | | | | | | | Picks up files like "cover.jpg". It's made part of normal external file loading, so I'm adding 3 new options that are direct equivalents for the options that control loading of external subtitle and audio files. Even though I bet nobody wants them and they just increase confusion... I guess the world is actually hell, so this outcome should be fine. It prefers non-specific external files like "cover.jpg" over embedded cover art. Not sure if that's wanted or unwanted. There's some pain over explicitly marking such files as external pictures. This is basically an optimization: in most cases, a heuristic would treat an image file loaded with --external-file the same (it's a heuristic because ffmpeg can't tell us whether something is an image or a video). However, even with this heuristic, it would decode the cover art picture again on each seek, which would essentially slow down seeking in audio files. This bothered me greatly, which is why I'm adding these additional options at all, and bothered with the previous commit. Fixes: #3056
* player: let frontend decide whether to use cover-art modewm42020-09-281-1/+4
| | | | | | | | | | | | | Essentially, this lets video.c decide whether to consider a video track cover art, instead of having the decoder wrapper use the lower level sh_stream flag. Some pain because of the dumb threading shit. Moving the code further down to make some of it part of the lock should not change behavior, although it could (framedrop nonsense). This commit should not change actual behavior, and is only preparation for the following commit.
* player: add pause state to playback start messagewm42020-09-211-2/+3
| | | | | Now the player tells you that audio or video are playing while paused, or something.
* 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-122-8/+3
| | | | | | | | | | | | | | | | | | 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
* player: some minor code golfwm42020-09-101-11/+6
|
* player: clamp relative seek base time to nominal durationwm42020-09-101-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since b74c09efbf7, audio-only files let you seek to arbitrary points beyond the end of the file (but still displayed the time clamped to the nominal file duration). This was confusing and just not wanted. The reason is probably that the commit removed setting the audio PTS for data before the seek target, so if you seek past the end of the file, the audio PTS is never set. This in turn means the logic to determine the current playback time has no PTS at all, and thus falls back to the seek PTS. This happened in the past for other reasons (like efe43d768f). I have enough of this, so I'm just changing the code to clamp the seek timestamp to a "known" range. Do this when seeking ends, because in the fallback case, the playback time shouldn't be stuck at e.g. "end + seek_argument". Also do it when initiating a new seek (mp_seek), because if the previous seek hasn't finished yet, it shouldn't add them up and allow it to go "out of range" either. The latter is especially relevant for hr-seeks. Doing this clamping is problematic because the duration is a possibly invalid value from the demuxer, or just missing. Especially with timestamp resets, fun sometimes happens, and in these situations it might be better not to clamp. One could argue you should just use the last audio timestamp returned by the decoder or demuxer (even if that directly conflicts with --end), but that sounds even more hairy. In summary: what a dumb waste of time, what the fuck.
* command: add read-only focused propertyGuido Cella2020-09-083-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a property that returns whether the window is focused, currently on