summaryrefslogtreecommitdiffstats
path: root/player
Commit message (Collapse)AuthorAgeFilesLines
* player/command: optimize duplicated property search in command_initKacper Michajłow2024-03-251-1/+12
| | | | | | | Would be better to search the other way around, because options list is bigger than property list, but with minimal changes this is good enough. Both are relatively small tho and the only reason for this micro optimization is to increase the fuzzing throughput.
* mac/apphub: migrate remaining events functionality to new AppHubder richter2024-03-241-1/+1
| | | | | | | | add new app_bridge objc file for bridging between mpv core and app functionality. replace old EventsResponder singleton with AppHub. another step to clean up all App functionality and have one central place for it.
* player/command: fix udata talloc parentShuanglei Tao2024-03-231-2/+2
|
* options: add --input-commands optionDudemanguy2024-03-213-0/+30
| | | | | | | Basically a simple way to perform any command/property action from the command line. This takes the exact same syntax as input.conf but not including the key naturally. Potentially useful for weird properties that don't map well to options (like ao-volume). Fixes #12353.
* console.lua: complete fixed precision propertiesGuido Cella2024-03-211-1/+1
| | | | | Add support for the syntax introduced by 8708f4dc91 in the completion system.
* m_property: add `>` for fixed precision floating-point expansionKacper Michajłow2024-03-211-13/+11
| | | | | | | | | | | | | | This enhancement makes it easier to create constant width property expansions, useful for the `--term-status-msg`. Additionally, it changes to `%f` printing with manual zero trimming, which is easier to control than `%g`. With this method, we can directly specify precision, not just significant numbers. This approach also avoids overly high precision for values less than 1, which is not necessary for a generic floating-point print function. A new print helper function is added, which can be used with adjusted precision for specific cases where a different default is needed. This also unifies the code slightly.
* osc.lua: escape textGuido Cella2024-03-211-10/+5
| | | | | | | | | | | | | | | | | | | | Escape all messages in osc.lua, because other than the title they weren't being escaped at all. If for example you did mpv foo.mp4 '{\fs50}bar.mp4' and script-message osc-playlist, it would just render the second entry as bar.mp4 in big text. The title was escaped partially, now the escaping is complete because: - It escapes \. Backslashes at the end of the title are escaped instead of being stripped, and \n, \N and \h are now printed verbatim. In particular, "\\n" is no longer converted to space and is printed verbatim instead which is more correct. - Newlines ("\n", not the "\\n" escape sequence) are converted to spaces instead of rendering them and messing up the text positioning within the OSC. - Spaces at the start are preserved. Fixes #11209, fixes #11275.
* command: add escape-assGuido Cella2024-03-213-26/+17
| | | | | | | | | | | | | | | | | This adds a command to escape ASS tags to remove code duplication between sub/osd_libass.c, console.lua, osc.lua, stats.lua and any user script that calls mp.create_osd_overlay(). A command is used instead of scripting functions so that all clients can use this and not just use Lua and JS ones. osd_mangle_ass() also interprets osd-sym-cc and osd-ass-cc/{0,1}, but since they use invalid UTF-8 characters there is no risk of escape-ass users using them by accident, like with any OSD message. Always replacing \n with \\N in mangle_ass() even when it is not called by escape-ass doesn't seem to cause any issue, but I made it conditional anyway to avoid changing how all OSD messages are treated unnecessarily.
* stats.lua: use term-size as terminal output sizeChristoph Heinrich2024-03-211-3/+4
| | | | | | | The terminal output was static in size with no way of automatically adjusting it to the current terminal size. The new term-size property makes truly automatic adjustment possible.
* player/command: add term-size/[w,h] propertyChristoph Heinrich2024-03-211-0/+19
| | | | | | There was no way for scripts to know the current size of the terminal, which is essintial if they want to provide a good user experience even without a window.
* stats.lua: fix and unify scroll hintChristoph Heinrich2024-03-211-10/+11
| | | | | | | | The scroll hint on page 4 had baked in ass tags, which shouldn't be there in the terminal. Also the scroll hint on page 0 was missing. Refactor scroll hint generation into a function and use that for pages 2, 4 and 0.
* stats.lua: use term_ellipsis for page 4Christoph Heinrich2024-03-211-16/+7
| | | | | Page 4 might as well use the same line shortening function as the other pages instead of rolling it's own.
* stats.lua: truncate long lines for the terminalChristoph Heinrich2024-03-211-30/+101
| | | | | | | | | | | | | | | The terminal is assumed to be 80x24 in size, the new options `term_width_limit` and `term_height_limit` can be used to overwrite that. Lines longer then the terminal width cause problems with scrolling pages and need to be shortened. The algorithm used for shortening can deal with tabs and escape sequences, has rudimentary support for UTF-8 and runs in O(n). avih helped in the creation of the term_ellipsis() function and split() is also from him.
* stats.lua: use scroll function for page 2 and 0Christoph Heinrich2024-03-211-52/+30
| | | | | | | | | | | | | | Pages 2 and 0 had their own scroll implementations, which worked fine for ass, but didn't work well in the terminal. Now they both use the same scroll function as page 4. That scroll function requires each output line to be one entry in the table. Page 0 did not adhere to that new requirement, instead it generated two table entries for a single output line when a graph is shown. To fulfill that requirement the generated graph now gets directly appended to the same table entry that's used for the rest of the line.
* stats.lua: refactor page 4 scrolling into functionChristoph Heinrich2024-03-211-10/+24
| | | | | | | | This scrolling implementation will be used for other pages in future commits. The comment said it takes up 20 lines of the terminal, but in reality it was 22 lines.
* stats.lua: add more information in audio sectionKacper Michajłow2024-03-211-6/+21
| | | | | | | | - current AO - AO device - AO volume - audio delay - output format
* player/main: move terminal_uninit to the endKacper Michajłow2024-03-191-5/+6
| | | | | It is strange to do terminal_uninit() and still use terminal after. Even tho it has no side-effects.
* image_writer: fix TOCTOU in screenshot filename generationnanahi2024-03-191-4/+5
| | | | | | | | | | | | | | | | The screenshot command is documented to not overwrite existing files. However, there is a race window between the filename is generated with gen_fname and when the file is open to write. Specifically, the convert_image function in this window can be very time consuming depending on video and screenshot image format and size. This results in existing file being overwritten because the file writing functions don't check for the existance of file. Fix this be opening the file in exclusive mode. Add overwrite parameter to write_image for other operations that are documented to overwrite existing files, like screenshot-to-file. Note that for write_avif, checking existance is used instead because avio_open does not support exclusive open mode.
* various: fix -Wold-style-declaration warningnanahi2024-03-191-1/+1
| | | | warning: `static' is not at beginning of declaration
* osc: add missing window controls for --title-bar=noKacper Michajłow2024-03-181-1/+7
|
* demux: add a format-name propertyDudemanguy2024-03-171-0/+1
| | | | | It can be useful to know the underlying format of any entry in the track list. Only applicable to the lavf demuxer.
* stats.lua: display video parameters after filteringKacper Michajłow2024-03-091-0/+1
|
* mp_image: add mp_image_params_static_equal for finer comparisionKacper Michajłow2024-03-091-9/+1
| | | | In case of dynamic HDR metadata is present.
* vo: add video-target-params propertyKacper Michajłow2024-03-071-1/+18
|
* player/command: fix video-params/[average-bpp, alpha] when hw decodingKacper Michajłow2024-03-071-2/+3
| | | | Need to check hw_subfmt for real values.
* mp_image: add imgfmt_name to mp_image_paramsKacper Michajłow2024-03-071-10/+14
| | | | | | | | Convenience to override name if imgfmt is not set. Allows to create mp_image_params without setting imgfmt. Will be useful for the next change where mp_imgfmt is not available. This is workaround that will be remved once all codebase switches to pl_fmt.
* Revert "player: reset av state on speed changes"Dudemanguy2024-03-033-22/+2
| | | | | | | | | Ended up being too flawed and caused trouble in other areas. There's other approaches to trying to solve the issue this meant to address in the works that should be better, so let's wait on that. Fixes #13613 and fixes #13622. This reverts commit e3af545421322e357eb9355395923710ea93f83b.
* player/video: subtract frame_time from delay when ao_chain starts audioDudemanguy2024-03-033-1/+5
| | | | | | | This seems more robust than relying on the audio status to actually be playing. For files where there is no audio or the audio start is delayed, this guards against that but it allows the subtraction to always occur otherwise on normal files with audio.
* player/audio: also adjust apts by audio speed in audio_start_aoDudemanguy2024-03-031-1/+2
| | | | Fixes 7051e94e4bacd00e53e88835d28e9d9082de3bb3
* command: add begin-vo-dragging commandnanahi2024-03-011-0/+12
| | | | | | This command initializes a vo dragging request for VOs that implement the new VOCTRL_BEGIN_DRAGGING voctrl. This allows scripts to begin vo dragging for any button press event.
* Revert "player: add ao-volume option, to set the system volume at startup"Dudemanguy2024-03-013-24/+10
| | | | | | | | Ended up being a bad idea. As a property, this inherently has more functionality and the tradeoff of being able to do --ao-volume wasn't worth it. This reverts commit 58ed620c064971535e60778612777750aa5e2f4d.
* osdep/mac: make mac naming of files, folders and function consistentder richter2024-02-281-2/+2
| | | | | rename all macOS namings (osx, macosx, macOS, macos, apple) to mac, to make naming consistent.
* console.lua: fix blurry cursor when --osd-blur is setnanahi2024-02-271-1/+1
| | | | | This is drawn with the same method as the stats.lua graphs so it's also blurry. Fix this by using the "Default" style for cursor drawing.
* stats.lua: fix blurry graphs when --osd-blur is setnanahi2024-02-271-1/+1
| | | | | | | | When --osd-blur is set to a nonzero value, the graphs also become blurry. This is because they are rendered by the osd-overlay command with the "OSD" style which has OSD blur applied, and are treated no differently from texts. Fix this by using the "Default" style for these graphs which uses the default OSD options.
* player/audio: remove misleading comment about delayDudemanguy2024-02-261-1/+1
| | | | | | | | | | | This came up in #13571. playing_audio_pts does not include mpctx->delay contray to what that implies. The function is meant to only offset the written audio pts by whatever the internal AO buffer may be. mpctx->delay is a combination from both the audio and video code, so it should not be used here. What is wanted is purely the audio pts. b74c09efbf7c6969fc053265f72cc0501b840ce1, a very controversial commit to say the least, was what introduced this comment, so removing is probably OK.
* player: reset av state on speed changesDudemanguy2024-02-263-2/+22
| | | | | | | | | | | | | | | Playback speed changes should be treated as a discontinuity just like seeking. Previously, this was being treated internally as just plain normal playback, but that can't really work. The frame timings from before the speed change and after the speed change are completely different and shouldn't be compared to each other. This lead to frames being adjusted to weird places and possibly even being skipped (as if mpv was seeking) on speed changes. What we should do is clear out and reset all av related fields like what happens when you seek, but it is not quite as aggressive. No need to do a full video state reset or such. We also wait an arbitrary amount of frames before adjusting for av sync again. compute_audio_drift already used a magic number of 10 which sounds reasonable enough so define that and use it here. Fixes #13513.
* player: remove speed adjustment from playing_audio_ptsDudemanguy2024-02-262-2/+3
| | | | | | | | | | | | When calculating the audio pts, mpv multiplies the ao delay by the current audio speed and subtracts it from the written audio pts. This doesn't really make sense though. mpctx->video_pts is never affected by the playback speed, and this leads to weird behavior like the audio-pts property changing values while paused merely because the playback speed changes. Remove the multiplication and simply subtract the delay by a factor of 1 instead. When updating the av_diff in player/video, this does actually need to take in account the audio speed so we do the calculation there.
* player/main: don't set the main thread nameDudemanguy2024-02-261-1/+0
| | | | | | | 98a27b3cd1e6af743af67699318df1946ce5bf8f changed this to mpv but that's kind of pointless since the binary is already named mpv so that will be the default thread name. Evidently, people rename/symlink the binary to something else so might as well make them happier. Fixes #13469.
* input/player: add loadfile/loadlist insert-at commandDavid Vaughan2024-02-261-22/+78
|
* player: change insert_next to insert_atDavid Vaughan2024-02-262-6/+5
| | | | | | | | | | Change the `playlist_insert_next` function to `playlist_insert_at` (ie, insert at the location of an entry, rather than after it, and rename to be clearer that it doesn't have anything to do with the currently-playing entry). Also, replace calls to `playlist_add` with calls to `playlist_insert_at`, since the former has become redundant.
* player: add loadlist insert-next commandsDavid Vaughan2024-02-261-5/+15
| | | | | | | | Analogous changes to the previous commit ("add loadfile insert-next commands"), but for the `loadlist` command. This allows us to insert a new playlist next in the current playlist, rather than just appending it to the end.
* player: add loadfile insert-next commandsDavid Vaughan2024-02-261-5/+16
| | | | | | | | | | | | | This commit adds two new commands (`insert-next` and `insert-next-play`) which mirror the existing commands, `append` and `append-play` in functionality, with the difference that they insert directly after the current playlist entry, rather than at the end of the playlist. This change gives MPV a piece of functionality already found in (for example) Spotify's media player: "play next". Additionally, using the new `insert-next` command, users can trivially write a script to play a new piece of media immediately without otherwise clearing or altering the remainder of the playlist.
* player: add ao-volume option, to set the system volume at startupLeonardo Boss2024-02-253-10/+24
| | | | closes #12353
* player/command: handle runtime toggling of hidpi-window-scaleDudemanguy2024-02-241-0/+23
| | | | | | | Wayland was the only backend that attempted this, but it can be done in a centralized place for anything that supports this. hidpi-window-scale is just the same as a normal window scale but with the OS DPI as the factor.
* player: fix watch later config comments when ignoring pathGuido Cella2024-02-241-2/+5
| | | | | | | | | | | | | With --ignore-path-in-watch-later-config, --write-filename-in-watch-later-config still writes the absolute path of files in the comment, even though the hash is calculated from the basename. Make it write the basename to avoid confusion. Also stop writing redirect entries for parent directories with --ignore-path-in-watch-later-config, both because it's redundant, and because with this patch it would write the basename of directories in the comment, which would be wrong because their hashes are calculated from the absolute paths.
* player/loadfile: rewrite sub autoselection logicDudemanguy2024-02-242-51/+29
| | | | | | | | | There's too many dumb options related to subtitles which have annoying edge cases. Try to rewrite this completely so it hopefully behaves normally in every expected scenario. A key goal here is be smarter while looping through the tracks and avoid selecting the subtitle if it doesn't meet user's passed options as opposed to clearing the pick after the fact. Fixes #13280 and fixes #13263.
* command: fix sub-seek while paused without a videoGuido Cella2024-02-231-0/+8
| | | | | | | When using sub-seek without a video track while paused, adding the 0.01 SUB_SEEK_OFFSET to the new timestamp is not enough to show the new subtitle line. Add 0.1 instead to fix it. 0.01 is already enough for sub-step.
* command: don't add SUB_SEEK_OFFSET twice with sub-seekGuido Cella2024-02-231-4/+0
| | | | | The name SD_CTRL_SUB_STEP is misleading, but it is also used for sub-seek, and sub/sd_ass.c already adds SUB_SEEK_OFFSET with it.
* vo: remove VOCTRL_SET_EQUALIZER and simplify into UPDATE_VIDEODudemanguy2024-02-171-1/+1
| | | | | | | | | | | | | | | Since 03cf150ff3516789d581214177f291d46310aaf4, the only purpose of this VOCTRL was to signal a redraw to the vo. It actualy could have been removed in 531868fe0d2a35fbbff78d9a9ff8f96df73e69fd, but this was missed. The UPDATE_VIDEO flag is better anyway because it allows us to handle a wide variety of options scattered around that require the VO to update itself and redraw. We can remove both of the custom callbacks in vo.c and only leave the VOCTRL_VO_OPTS_CHANGED one. Additionally, that commit also introduced vo_set_want_redraw, but this is redundant and not needed. The VOs that use VOCTRL_UPDATE_RENDER_OPTS already set vo->want_redraw, and those are the only VOs where these options are relevant in the first place. So we can remove this as well and just let the big callback in player/command do everything.
* command: add window-id to MPV_EVENT_VIDEO_RECONFIG property changeDudemanguy2024-02-171-2/+2
| | | | | | | | | 25b66256d7ff48254b2055a066e29f260414112f originally added this property, but it did not add it to the property notification. This is possibly because the window id doesn't appear to change on x11 even when toggling VOs at runtime. However, windows uses this property and apparently the id changes there so we should signal updates when appropriate. Fixes #13495.
* player/sub: avoid wasteful subtitle redrawsDudemanguy2024-02-153-22/+53
| | | | | | | | | | | | | | | | | This only affects two special cases: printing subtitles to the terminal and printing subtitles on a still picture. Previously, mpv was very dumb here and spammed this logic on every single loop. For terminal subtitles, this isn't as big of a deal, but for the image case this is pretty bad. The entire VO constantly redrew even when there was no need to which can be very expensive depending on user settings. Instead, let's rework sub_read_packets so that it also tells us whether or not the subtitle packets update in some way in addition to telling us whether or not to read more. Since we cache all packets thanks to the previous commit, we can leverage this information to make a guess whether or not the current subtitle packet is supposed to be visible on the screen. Because the redraw now only happens when it is needed, the mp_set_timeout_hack can be removed.
* Reapply "video: remove another redundant wakeup"Kacper Michajłow2024-02-151-1/+3
| | | | This reverts commit 44c398c3e133379e01f06c89fd78b6692694849c.
* js: complex key-binding: send also key_textAvi Halachmi (:avih)2024-02-091-4/+5
| | | | | | | This is doumented and has been part of the table in lua, but until now not in the JS object. Fixes #13448
* console.lua: move functions to strip common charactersGuido Cella2024-02-081-34/+34
| | | | | | Move common_prefix_length() and related functions before the first call to common_prefix_length(). It works now because it's global but if we ever make all functions local for consistency it will stop working.
* stats.lua: use deinterlace-active property insteadDudemanguy2024-02-071-1/+1
| | | | | But still read the deinterlacing option to distinguish between yes and auto.
* player/command: add deinterlace-active propertyDudemanguy2024-02-071-1/+15
|
* player: ensure runtime updates of certain rendering optionsDudemanguy2024-02-051-0/+7
| | | | | | | | | | When adding things like brightness or gamma, the video obviously needs a redraw if paused. This happened to work in the normal case because the OSD notification triggered a redraw, but if you use no-osd the picture won't change. Fix this by adding another option flag, UPDATE_VIDEO, and simply signalling we want a redraw. This gets handled along with the normal osd redrawing check in the playloop so something like "no-osd add gamma 1" actually works.
* command: add load-input-confGuido Cella2024-02-041-0/+11
| | | | | | | | | | | | | | | | This can be used to auto reload the input configuration file, e.g. in vim: autocmd BufWritePost ~/.config/mpv/input.conf silent !echo load-input-conf %:p | socat - /tmp/mpvsocket Partially fixes #6362. Additionally this can be used as a replacement for deprecated input sections if they are ever actually removed. For example, if you want to define different bindings for images, you can load-input-conf an input.conf for images, and load the original again when switching to a video. Though currently you would have to redefine builtin bindings that were overwritten with image ones in the default input.conf.
* command: add load-config-fileGuido Cella2024-02-042-10/+38
| | | | | | | | Unlike set include mpv.conf, this works after playback has started. It can be used to auto reload the configuration, e.g. in vim: autocmd BufWritePost ~/.config/mpv/mpv.conf silent !echo load-config-file %:p | socat - /tmp/mpvsocket Partially fixes #6362.