1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-11 08:37:59 +00:00
Commit Graph

53914 Commits

Author SHA1 Message Date
Dudemanguy
58f46e7f0b test/libmpv_test_track_selection: add another multilang selection test
Because you can never have too many tests. This covers some scenarios
that the other multilang one doesn't (multiple tracks with the same
language).
2025-02-13 23:22:28 +00:00
Dudemanguy
9e38208951 test/libmpv_test_track_selection: eliminate reloading redundancy
Loading the file and then waiting it for it to be loaded again doesn't
need to be two separate functions. Combine it into a simple
"reload_file" so it's more readable.
2025-02-13 23:22:28 +00:00
Dudemanguy
dba53e1b5b test/libmpv_test_track_selection: remove unneeded option resetting
This got refactored so it only loads one file at a time and not
everything in a loop. The option resetting at the end of conditional
branches is pointless.
2025-02-13 23:22:28 +00:00
Dudemanguy
f7a681b362 test: add default track selection testing
The amount of options we have that are related track selection is insane
and touching any of this stuff is scary. Add some track selection
testing to the CI to hopefully make it slightly less scary to touch any
of that. Since trying to work in media files from some outside source
would be a pain and need to live in some repo somewhere, it's nicer to
just generate dummy files on the fly with ffmpeg during the ci runs and
use that. Obviously, the actual tests themselves could be even more
thorough (external tracks were not even considered), but this is more
than a good enough start for now.
2025-02-12 15:29:07 +00:00
Dudemanguy
25067e845c test: split libmpv_test into separate files
The big libmpv test file is really actually three different tests shoved
together into one. They do all use fairly similar underlying structures,
so put the shared stuff into an inline header. There's a little bit of
duplication with regards to the main function, but it's cleaner to
separate out the tests.
2025-02-12 15:29:07 +00:00
Dudemanguy
d980e950c6 test: group together all the libmpv tests under the libmpv suite 2025-02-12 15:29:07 +00:00
Dudemanguy
2e1f89a0df github/workflows: drop mingw32
Upstream dropped libplacebo* so we're pretty much out of luck here. It's
not worth it to bother building a subproject for just this one.

*: c3a79e8ae9
2025-02-12 11:15:04 +01:00
sfan5
bfa3e90867 video/out/android: don't assert-fail if WinID is not set
This matches the behavior of every other GPU context and is the only
behavior that makes sense.
2025-02-11 19:19:36 +01:00
Kacper Michajłow
f385a6b253 demux_lavf: fix demuxer-lavf-format usage
mpv internally treats all string options/properties with NULL or an empty string the same way. client.h explicitly forbids MPV_FORMAT_STRING from being NULL, but in the C API, it has been working accidentally due to how strings are copied. Nevertheless, none of the APIs allow this; JavaScript, Lua, IPC, and CLI all require strings to be at least empty. We cannot pass NULL.

Furthermore, currently passing NULL causes an assertion failure in the JSON formatter, so it is clearly not intended to be used that way.

Internally, all string options default to NULL, but in this case, they should behave exactly the same as an empty string. Hence, this change is applied to the `demuxer-lavf-format` option.

Note that get_property will never return a NULL value, regardless of the internal value.

Fixes: #15840
2025-02-10 04:29:55 +01:00
Guido Cella
73b84595a8 select.lua: change the --save-watch-history warning text
The current warning was fine when you select history directly, but
giving more information can be useful when you happen to see it by right
clicking the title without prior information.

Fixes https://github.com/mpv-player/mpv/pull/15655#discussion_r1948053973
2025-02-09 23:30:54 +01:00
Kamikadze
e4b64fba9c DOCS/man/options: Clarify what --tone-mapping=auto does 2025-02-08 06:16:38 +01:00
Kacper Michajłow
f14660b446 Revert "vo_gpu_next: set --target-colorspace-hint to yes by default"
HDR or any color-space pass-through should be opt-in, as we cannot
control the user's compositor or display. Allowing HDR signals to be
pushed by default may lead to surprising results for some users.
Additionally, for an optimal experience, this option should be paired
with the target-peak of the display.

Make the pass-through opt-in and let the user decide if they want or
need it. By default, mpv should render a safe and consistent sRGB
output. mpv's tone mapping is generally of higher quality than any
external solution.

This reverts commit 23843b4aa5.
2025-02-08 06:15:32 +01:00
Kacper Michajłow
bc430fdbb8 player/command: don't synthesize property names with a trailing /
This is not only cosmetic, but also avoids dummy get key action with
empty key. While this was allowed previously, I'm bit concerned about
Hyrum's law. But let's be strict about it.

This commit fixes current-tracks property.

Fixes: 95019fc256
2025-02-08 05:45:57 +01:00
Dudemanguy
f9b95cb83d command: disallow trailing / in track-list/N/metadata
To have consistency with 95019fc256
2025-02-08 05:44:06 +01:00
Kacper Michajłow
50f3c1c243 player/command: disable input-commands for fuzzing
Updating input-commands string list causes all commands to be rerun.
This happens during load-config-file command, so even with few commands
it is easy to amplify single command to run hundreds of times instead of
one. This causes timeouts and OOMs when specific command for example
reopens current playlist appending an item.

Also avoid even single input-commands, we want to test load-config-file
parsing and input-commands can do loadfile and trigger heavy code
paths. We don't want to mix this. Unfortunately parsing of
input-commands will not be tested.
2025-02-08 05:41:22 +01:00
Kacper Michajłow
95019fc256 m_property: fix playlist property parsing
Disallow silly things like ${playlist//} and trailing slashes
${playlist/0/}.
2025-02-08 02:01:52 +00:00
Guido Cella
3c1ddc411c console.lua: fix completion after command prefixes
I'm not sure when this broke but completions after command prefixes were
not being updated.
2025-02-08 02:01:40 +00:00
Guido Cella
a62c559d82 command: show Loop playlist when changing --loop-playlist at runtime
Just "Loop" is a leftover from when --loop-playlist was called --loop.
2025-02-08 02:01:25 +00:00
Dudemanguy
18257375e4 m_option: deprecate setting -1 to --video-aspect-override
It's unfortunate that it is implemented this way since changing it will
take time. This option should *really* be like OPT_CHOICE but with
doubles and not integers. We don't have that though and implementing it
is something for the future. Even if that was done today, this still
couldn't be switched to since setting -1 has been the effective way for
years to undo video-aspect stuff. So the approach is to just add another
special keyword for this and tell people to use that instead. Note that
setting 0 isn't deprecated since M_RANGE(0, 10) is totally fine and
would work in the future if this option type ever gets redone.
2025-02-08 02:01:13 +00:00
Dudemanguy
cb91de2a34 m_option: forbid non -1 negative values for video-aspect-override
Setting this to M_RANGE(-1, 10) meant that you could pass fractional
negative values without it being an error. This is, of course, nonsense.
-1 is the only special negative value with a meaning. Error out if we
get anything else by doing some additional parsing before we send it off
to parse_double which will then restrict the range to 0, 10 with these
changes. Note that this approach requires defval to be there which is
not the most extensible thing in the world. But there's literally only
two OPT_ASPECT type options out of the hundreds we have so not a big
deal. Ideally, this type should be OPT_CHOICE but with underlying
doubles but that's too much effort to implement cleanly.
2025-02-08 02:01:13 +00:00
Dudemanguy
16828aa952 command: convert aspect, par, and sar sub-properties to double
These were still set to float. For some common aspect ratios (e.g. like
4:3), the loss of precision is significant. The underlying calculations
are already done with doubles so all that needs to be done is to change
the type of the sub-property.
2025-02-08 02:01:13 +00:00
Kacper Michajłow
17db9bdc50 build: add early exit if git is not found
Also fallback to `--always` only if first `git describe` returned
errors, but were called successfully.
2025-02-06 02:16:51 +01:00
Kacper Michajłow
2596c4d930 github/workflows/lint: show ruff suggested changes 2025-02-06 01:33:09 +01:00
Kacper Michajłow
cd439acce2 github/workflows/lint: update astral-sh/ruff-action to v3
This enables GitHub style output, along with other improvements.
2025-02-06 01:33:09 +01:00
Dudemanguy
d19bb08bef ci/lint: disable isort checks
The error message is completely incomprehensible and also inconsistent
about whether it wants two newlines or just one after an import.

Consider this python script:

import sys

sys.stdout.write("garbage")

That passes the ruff isort check just fine. But this does not:

import sys

def fake_function():
    sys.stdout.write("garbage")

fake_function()

This will fail. Why? Because there should be two newlines after imports
but only for functions. This is because of PEP8 rules about blank lines,
but this is not explained or referenced anywhere in output from the
lint. You only get a cryptic "Import block is un-sorted or un-formatted"
with some visual that isn't clear in what it's trying to communicate.
Additionally, it seems to go a bit beyond PEP8 and also will fail if you
have too many blank lines (i.e. more than 1) in certain cases if the
succeeding line isn't a function or class definition.

Furthermore consider this example:

import os
import sys
from subprocess import check_output, DEVNULL

This also fails the lint. Why? Because DEVNULL should come before
check_output. Again, the lint doesn't explain this and you're left
guessing what horrible formatting sin you committed.

Considering the amount of time I wasted trying to even understand this
and I still don't, just delete it. How are contributors supposed to
understand what this lint wants when the project's own developers were
confused by it. Please just alphabetically sort your python imports and
don't do "from foo import *".
2025-02-05 23:46:30 +00:00
Kacper Michajłow
05ff82e153 build: use a more user-friendly version string for shallow clones
If the cloned repo is shallow (e.g. like the default github actions
settings), the git describe command won't actually be able to fetch any
tags and will instead just get a hash. The resulting binary version
string will end up being that git hash. While it does tell you the exact
commit, it's not exactly helpful when wanting to know the general
version at a glance. For the case where we do have a git directory but
no available tags, build a version string using the mpv version + the
commit hash.

Fixes #15789.
2025-02-05 23:17:06 +00:00
Dudemanguy
8e97f41849 build: prepend version strings with 'v' for release tarball builds
This was an inconsistency with the git tagging since the meson project
version is just a number.
2025-02-05 23:17:06 +00:00
Kacper Michajłow
28ab3aec6a github/workflows/lint: add umpv to Python linting
It doesn't have extension.
2025-02-05 20:22:01 +01:00
Kacper Michajłow
48f944d21b TOOLS/umpv: add Windows support
While there are native ways to implement this in mpv itself on Windows.
We can also support this script without any problem.
2025-02-05 20:22:01 +01:00
Kacper Michajłow
f9a7179f37 TOOLS/umpv: use append-play
It makes more sense to star playback if nothing is playing.
2025-02-05 20:22:01 +01:00
Kacper Michajłow
dfbd60f9bb TOOLS/umpv: don't wait for mpv after it is run
We just want to start mpv, there is no need to keep umpv script alive.
2025-02-05 20:22:01 +01:00
Kacper Michajłow
b870d1933a TOOLS/umpv: use builtin profile for pseudo gui options 2025-02-05 20:22:01 +01:00
Kacper Michajłow
62847c9f39 TOOLS/umpv: handle the case when mpv disappears during adding files 2025-02-05 20:22:01 +01:00
Kacper Michajłow
7372bc5f12 TOOLS/umpv: minor fixes to style and typing
Add UMPV_SOCKET_DIR for socket base dir selection and fallback to TMPDIR
as last resort.
2025-02-05 20:22:01 +01:00
Dudemanguy
493cc877cf m_option: fix parsing of OP_APPEND for string lists
While parsing through the separators, the OP_APPEND also needs to use 0
for the separator since it is supposed to be unescaped. This was missed
in the code reorganization of d2c409c56b.
Keyvalue lists were unaffected because only OP_DELETE and OP_REMOVE use
this code.
2025-02-05 18:38:46 +00:00
Kacper Michajłow
3717a530ca player/loadfile: we shouldn't unescape inplace
I got mesmerized by the simplicity of the original commit, but in fact
it was not a correct thing to do.

Fixes: c0366cfa42
2025-02-05 18:04:11 +01:00
Kacper Michajłow
de4004c61d meson: add disable-packet-pool option
For debugging without a pool, maybe.
2025-02-05 05:09:33 +01:00
Kacper Michajłow
038d66549d demux: reclaim demux_packets to reduce memory allocator pressure
This update introduces a demux_packet_pool, allowing for the reuse of
previously allocated packets when needed.

sizeof(AVPacket) is not a part of the lavc public ABI, which prevents us
to allocate memory in larger blocks. However, we can substantially
decrease the amount of alloc/free operations during playback by reusing
both mpv's demux_packet and AVPacket.

This adjustment addresses the root cause of issue #12076, which,
although resolved upstream, did not fully tackle the persistent problem
of allocating small blocks of aligned memory. This issue largely stems
from the FFmpeg design of the AVPacket API. After this change memory
will no longer be allocated once cache limits is reached.

The demux_packet_pool is shared as a global pool of packets for a given
MPContext.

This change significantly speeds up the demuxer deinitialization,
benefiting file switching scenarios, especially when a large demuxer
cache is used.

See: #12294
See: #12563
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-02-05 05:09:33 +01:00
Nikolai Vavilov
c0366cfa42 loadfile: unescape display filenames
This makes OSD more usable when the filename contains non-ASCII characters.
2025-02-05 05:04:33 +01:00
Guido Cella
6f0a077d9b DOCS/man/options: document that --d3d11-flip=no enables transparency 2025-02-05 04:56:01 +01:00
Guido Cella
b0364f8761 osc.lua: bind right clicking the title to show history
And move show-text ${path} to middle click. This is more useful than the
replaced show-text ${filename} binding since the left click stats
binding already shows the filename, and it matches how right clicking
other buttons shows menus. Alternatively middle click could also be
bound to select-watch-later.
2025-02-05 04:55:37 +01:00
Leo Izen
a7357c221e TOOLS/mpv_identify.sh: handle forward slash in property names
Property names contain '-' characters, which are translated into
underscores because POSIX shell variables cannot contain hyphens.

We should do the same thing for forward slash characters (i.e. '/')
because these also cannot be present in the names of shell variables.

Fixes: #15782
2025-02-05 04:54:04 +01:00
Sami Farin
fa9c2a35dd video/out/kitty: make kitty vo ten times faster by avoiding strlen
When playing a video, 55% of CPU used in strlen, callgraph flip_page: ta_talloc_strdup_append ,
ta_talloc_asprintf_append and ta_talloc_strndup_append .

Before the fix: 2 fps when playing 1080p 24 fps video (--vo-kitty-use-shm=no),
24 fps after the fix.

video/out/kitty: move bstr cmd to priv
2025-02-05 04:53:42 +01:00
Dudemanguy
38ad1ed03b command: normalize paths for path and track-list/N/external-filename
It's better for API users to actually get predictable results.
2025-02-01 16:12:03 +00:00
Dudemanguy
02c0b346eb command: simplify find_track_with_url handling
Now that mp_normalize_path can accept NULL and we have a shorthand for
expand + normalize, now is a good chance to simplify this to make it
less awkward.
2025-02-01 16:12:03 +00:00
Dudemanguy
6472e45e8b options/path: add mp_normalize_user_path shorthand
Expanding a path and then normalizing it is probably a common shorthand.
The reason to not incorporate this directly into mp_normalize_path is
because it requires the global struct which is out of scope for
path_utils so use this wrapper instead.
2025-02-01 16:12:03 +00:00
Dudemanguy
956cb2c49f various: simplify mp_normalize_path usage
If a talloc_ctx was being made solely for a onetime usage of getting a
normalized string, we can now just pass NULL instead and free the string
directly to make things easier.
2025-02-01 16:12:03 +00:00
Dudemanguy
0755edb327 misc/path_utils: allow passing NULL to mp_normalize_path
Instead of requiring the caller to pass an appropriate talloc_ctx,
mp_normalize_path will make its own internal allocations and cleanup as
needed.
2025-02-01 16:12:03 +00:00
Guido Cella
b2404e16dd console.lua: stop expanding ~/ in file completion
It is not needed to expand ~ in file completion as you type after
62c3aeb9c made commands themselves interpret it. We only need to call
expand-path on the directory before passing it to utils.readdir in order
to find files in it when it contains ~ placeholders. As a bonus this
will now also complete files in directories like ~~/ and ~state/.

This simplifies command completion, and was also the blocker for
splitting running commands out of console.lua, since I didn't know how
to replicate it through mp.input.
2025-02-01 16:11:30 +00:00
Guido Cella
6fb3ac1bc7 Revert "DOCS/man/input: document that shutdown is sent when scripts terminate"
This reverts commit 86383aef95.

shutdown isn't actually sent on exit() but only with internal options,
e.g. set osc no, which isn't relevant for users.
2025-02-01 16:11:18 +00:00