summaryrefslogtreecommitdiffstats
path: root/player
Commit message (Collapse)AuthorAgeFilesLines
* 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 state is updated. To fix this edge case, it's simply just a matter of explictly setting STATUS_EOF after seek_to_last_frame in handle_keep_open. This logic will only ever trigger if keep-open is being used and the seek goes past the end of the file, so we know that there will always be an EOF here.
* various: remove trailing whitespaceGuido Cella2022-05-141-1/+1
|
* lua: avoid rare memory leak in mp.join_pathGuido Cella2022-05-121-4/+3
| | | | | If lua_pushstring is OOM, then our joined path allocation is leaked. Use autofree to ensure it's not leaked in case of Lua OOM.
* console.lua: don't render a 2nd cursor on the OSCGuido Cella2022-05-011-1/+1
| | | | | | | | | | 09ea3a424fe moved the console above the OSC when it is visible so they don't overlap, but only changed the first ass:pos() call and forgot to update the second one, which redraws the cursor on top of the text, so when both the OSC and the console are visible, a second cursor is drawn on the OSC. You have to type past where the buttons are to notice it. This commit synchronizes the position of the 2 ASS events.
* various: fix typosCœur2022-04-256-11/+11
|
* player: add cover-art-whitelist optionGuido Cella2022-04-211-1/+1
| | | | | | | | This allows more fine grained control over which cover art to load. With --cover-art-auto=exact and --cover-art-whitelist=yes, you can now load cover art with the exact media filename and the whitelisted filenames, but not cover art that contains the media filename (--cover-art-auto=fuzzy).
* player: rearrange video sync opts/enums/definesDudemanguy2022-04-113-22/+4
| | | | | | | | | | | | | | | | | The video sync logic for mpv lies completely within its core at essentially the highest layer of abstraction. The problem with this is that it is impossible for VOs to know what video sync mode mpv is currently using since it has no access to the opts. Because different video sync modes completely changes how mpv's render loop operates, it's reasonable that a VO may want to change how it renders based on the current mode (see the next commit for an example). Let's just move the video sync option to mp_vo_opts. MPContext, of course, can still access the value of the option so it only requires minor changes in player/video.c. Additionally, move the VS_IS_DISP define from to player/core.h to common/common.h. All VOs already have access to common/common.h, and there's no need for them to gain access to everything that's in player/core.h.
* options.lua: remove unused functionGuido Cella2022-04-081-7/+0
| | | | | val2str isn't used anywhere. Its only use was removed in dd3e52fe68, when it was still part of osc.lua.
* options: add osd-playing-msg-durationGuido Cella2022-04-071-1/+3
|
* lua: use correct chunkname when loading script filessfan52022-03-231-3/+6
| | | | This was brought up in #10007 and it turned out mpv did not follow Lua conventions.
* ytdl_hook.lua: consider any subprocess status != 0 as errorAvi Halachmi (:avih)2022-03-031-1/+6
| | | | | | | | | | | Previously only status<0 was considered as error, but status>0 is also an error (the process exit code). Change to status != 0. This likely makes little to no difference in practice, because if stdout is empty or can't be parsed as JSON then it's considered an error anyway, but still, this is more correct. Also, on error, add the complete subprocess result to the verbose log.
* ytdl_hook: fix url_is_safe to match URL protocols properlyGeorge Brooke2022-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | Some youtube_dl extractors retrieve URLs which contain other URLs inside of them, for example Funimation, like this: https://example.com/video?parameter=https://example.net/something The url_is_safe function uses a pattern to match the protocol at the start of the URL. Before this commit, this pattern was not compliant with the URL spec (see the definition of "A URL-scheme string"): https://url.spec.whatwg.org/#url-writing Therefore it would match any characters, including "://", until the last occurence of "://" in the string. Thus the above URL would match https://example.com/video?parameter=https which is not in safe_protos so the video will not play. Now the protocol can only start with a letter and only contain alphanumerics, "." "+" or "-" as the spec says, so it will only match the first protocol in the URL ("https" in the above example.) Previously the URL also had to contain "//" after the ":". Data URLs do not contain "//": https://datatracker.ietf.org/doc/html/rfc2397 so now the pattern does not look for "//", only ":".
* stats.lua: page 2 - frame timing: use fixed display orderAvi Halachmi (:avih)2022-02-231-1/+10
| | | | | | | | | | | | | Page 2 displays the frame timing info for each type (currently "Fresh" and "Redraw"), but since they're unordered keys of a map, their iteration order and hence their order on screen could (and did) change depending on $things, which was annoying. haasn thinks none of them should be considered more important (and therefore maybe worthy of being displayed on top), so we go with lexicographic order, which currently means that "Fresh" is first. Fixes #9901
* stats.lua: graphs: fix bad rendering due to division by 0Avi Halachmi (:avih)2022-02-211-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes two potential divisions by 0 at generate_graph(...): - If v_avg is (given and) 0. - if v_max is 0. The former doesn't seem to happen in practice because v_avg is only used at one generate_gpah call, where it's apparently not 0. The latter triggers if all the graph values are 0 (hence v_max is also 0). The implication of these divisions by 0 is an invalid y-value which ends up at the ASS coordinates string for the graph inner content. On linux the value ends as "nan" (luajit) or "-nan" (lua 5.1/5.2), and on Windows it's "nan" (luajit) or "-1.#IND00" (lua 5.1/5.2), maybe due to msvcrt's snprintf. All these strings are wrong as ASS numbers, but due to luck in how libass parses the coordinates, "nan" and "-nan" result in empty graph (which looks OK for "all values are 0"), while "-1.#IND00" is parsed as -1, which breaks the graph rendering (affects other graphs too). One example of "all values are 0" is at page 0 (internal performance graphs) on Windows - because the cpu metrics don't work. So this fixes at least page 0 on Windows with lua 5.1/5.2. While at it, move the scale calculations to one place, which now avoids division by 0, instead of duplicating this calculation. In the future, we can consider improving the generate_graph API: - It needs one peak value, but takes 3 (v_max, v_avg, scale) which are meshed into one final value. - v_avg is only used in 1 of 6 call sites, but at the middle of the arguments, so all other call sites need to pass explicit "nil". - "scale" is arbitrary and used to leave some space at the top of the graph. 5 places use 0.8, one uses 0.9. Could probably be unified.
* vo_gpu_next: refactor subtitle renderingNiklas Haas2022-02-211-0/+2
| | | | | | | | | | | | | | | Render subs at the output resolution, rather than the video resolution. Uses the new APIs found in libplacebo 197+, to allow controlling the OSD resolution even for image-attached overlays. Also fixes an issue where the overlay state did not get correctly updated while paused. To avoid regenerating the OSD / flushing the cache constantly, we keep track of OSD changes and only regenerate the OSD when the OSD state is expected to change in some way (e.g. resolution change). This requires introducing a new VOCTRL to inform the VO when the UPDATE_OSD-tagged options have changed. Fixes #9744, #9524, #9399 and #9398.
* options: add always to stop-screensaverDudemanguy2022-02-181-1/+2
| | | | | | | | | | The stop-screensaver option is currently limited to a simple yes/no option. While the no option does always disable mpv trying to stop the screensaver, yes does not mean the screensaver is always stopped. The screensaver will be enabled again depending on certain conditions (like if the player is paused). Simply introduce a new value for this option, always, which does exactly what the name implies: the screensaver will always be disabled.
* osc.lua: seekbar hover: speed-up chapter accessAvi Halachmi (:avih)2022-02-061-8/+9
| | | | | | | | | | | | | | | | | | | | | | This speeds up chapter name access while hovering the seekbar: - Fetch the chapter-list property using observation rather than on every render while hovering the bar. Property access, especially with potentially lots of values (chapters), can be expensive-ish, and can involve locking, so the less per-render the better. - Sort the list once (on change) to simplify the iteration logic when searching the chapter which matches the mouse position. It's still O(N) (no binary search currently), but with less work. The cached sorted list is stored at the state. While there are other places which access this property and could use this cache, for now we don't touch them, because they're not performance-critical (on init for the chapter markers, on ch_{prev,next} button click for OSD). Caching properties using observation instead of using mp.get_property can indeed speedup other places too, but it should be part of a system rather than implemented per-property. Maybe some day.
* js: utils.get_user_path: make wrapper of expand-pathAvi Halachmi (:avih)2022-02-042-7/+2
| | | | | | | | When utils.get_user_path was added, the expand-path command didn't exist. Now it does, so remove the C code, make it a trivial wrapper. Keep this function for backward compat to not break scripts, but technically it's not required anymore.
* auto_profiles.lua: don't warn if profile-restore=defaultCogentRedTester2022-01-301-1/+1
| | | | | | | | | | | | | | | The code assumed that the value of the profile-restore field is "default" for such profiles, but the C implementation is such that the field is intentionally omitted in such case. This resulted in incorrectly trying to restore such profiles. However, there are no stored values with profile-restore=default, so it only resulted in a harmless warning, but otherwise behaved correctly (i.e. nothing is restored). Fix the condition by taking into account that missing field means "default", so that it doesn't try to restore in such case, and avoid the warning.
* Revert "options: add --sub-visibility=<primary-only|secondary-only>"Avi Halachmi (:avih)2022-01-191-7/+5
| | | | | | | | | | This reverts commit 04f0b0abe48d664aaa1400d1dddb02b434999b85. It's not a good idea to unify the names only for visibility, while keeping secondary-* for everything else. This needs a bit more thought before we allow secondary sub to be visible on its own.
* options: add --sub-visibility=<primary-only|secondary-only>Ripose2022-01-191-5/+7
| | | | | | | | | | | | | Adds --sub-visibility choices 'primary-only' for only displaying the primary subtitle track, and 'secondary-only' for only displaying secondary subtitle track. Removes --secondary-sub-visibility and displays a message telling the user to use --sub-visibility=yes/primary-only instead. These changes make it so that the default 'sub-visibility' bind 'v' cycles through all the 'sub-visibility' choices, 'no', 'yes', 'primary-only', and 'secondary-only'.
* player: add thd (TrueHD) to whitelist of audio extensionschelobaka2022-01-191-1/+1
|
* player: fix parentheses warning with &&LaserEyess2022-01-181-2/+2
| | | | | | Was tripping -Wparantheses as the && after the || was not explicitly wrapped. However, due to operator precedence the intended effect was still correct.
* sub: rename SUBBITMAP_RGBA to SUBBITMAP_BGRANiklas Haas2022-01-111-1/+1
| | | | | This was a misnomer, the actual channel order is IMGFMT_BGRA (as the comment explicitly point out). Rename the enum for consistency.
* js: events registration: clarify breakage/fixAvi Halachmi (:avih)2021-12-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This commit is mainly for correcting the previous commit message. The previous commit fixed an issue where [un]registering events above the first event ID "hole" is not requested from libmpv, and that's indeed true. However, this had nearly zero impact in practice, because libmpv enables all events by default anyway (except TICK). Therefore, above the first ID "hole" [un]register requests are not sent to libmpv, and the events just keep arriving. But the callback functions are still added/removed correctly (at defaults.js), and so the script is not called back even if unregister did not actually happen with libmpv. The only event which was affected is TICK - which is not enabled by default as it's deprecated, and before the previous commit could not be enabled. So the fix is more a general correctness fix now that the IDs array can have "holes", but with effctively no impact in practice.
* js: fix event registration (keys, script-message, more)Avi Halachmi (:avih)2021-12-261-3/+3
| | | | | | | | | | | | | | Commit 63205981 removed some events but left all other event IDs at their original values, which created "holes" at the events IDs array. The JS backend for mp.register_event maps a name to an ID by scanning all IDs and stopping when the name was found or a NULL name was returned. Lua does the same except that it doesn't stop on NULL name. Previously it was not possible to have a NULL name before the end of the array, but now it is possible due to the enumeration holes. Fix by skipping missing names, like lua does.
* player: make deprecated track/chapter/metadata events internalsfan52021-12-155-20/+16
| | | | | We still need these to track or notify of modifications to certain properties, but they're now gone from the libmpv ABI.
* lua: remove mp.suspend, resume and resume_allsfan52021-12-152-23/+0
| | | | | | These functions were deprecated in v0.21.0 and no-ops since v0.23.0. The matching client API functions were removed in the previous commit.
* libmpv: remove opengl_cb API and other deprecated symbolssfan52021-12-153-76/+1
| | | | | | 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.
* {player,video}: remove references to obsolete opengl-cb APIsfan52021-12-152