Commit Graph

984 Commits

Author SHA1 Message Date
Guido Cella fe9e074752 various: remove trailing whitespace 2022-05-14 14:51:34 +00:00
Cœur bb5b4b1ba6 various: fix typos 2022-04-25 09:07:18 -04:00
Dudemanguy 94950b1b22 TOOLS/matroska.py: support outputting to file
Like the previous commit, it's better to just output it to a file for
meson.
2021-11-14 19:13:10 +00:00
Dudemanguy f7fab994eb TOOLS/file2string.py: support outputting to file
Another modification for the upcoming meson build. Meson can capture the
stdout and redirect it to a file. However, this is considered a hack.
It's better to just add a few lines to this script and write a file
directly.
2021-11-14 19:13:10 +00:00
Dudemanguy c698575c57 TOOLS: add macos-swift-lib-directory.py script
Apple is great and forces us to do a lot of weird checks because they
randomly move the location of the swift libraries around. Make a
specific python script for checking various locations and write the
output to stdout for meson.
2021-11-14 19:13:10 +00:00
Dudemanguy be536dd45a TOOLS: add macos-sdk-version.py script
Building for macos requires us to check the macos sdk path as well as
the sdk version that is on the system. To do this, let's steal the logic
that's in the compiler_swift.py check from the waf build. This returns a
comma-delinated string. The first entry is the absolute path to the sdk.
The second entry is the detected macos sdk version.
2021-11-14 19:13:10 +00:00
Guido Cella 6fe4fc4593 TOOLS/autocrop.lua: allow hiding OSD messages
Because having these on every video is annoying, and when you resume
from watch later files, the filters are applied immediately so they hide
your osd-playing-msg or equivalent show-text commands.
2021-07-27 20:32:05 +03:00
Kiracus 1e90ec647c osxbundle: use python3 2021-07-17 00:08:54 +02:00
Guido Cella 075154175d TOOLS/autocrop.lua: improve enable/disable condition
The previous code tried to disable autocrop for cover-art by testing
that track-list/$vid/albumart is false, however, $vid is completely
unrelated to the track-list index.

It only sometimes succeeded to disable for albumart, by accident,
e.g. with one audio track and one video track where $vid==1 and
track-list/1 happens to be the video (cover art) track.

The new code detects the currently-used video track by finding a track
with type=="video" and selected==true. Unlike the previous code, it
also works in scenarios with many audio/video/sub tracks.

Additionally, autocrop is now enabled also with lavfi-complex, which
should be considered an improvement. The previous code implicitly
disabled it with lavfi-complex because $vid is nil on such case.
2021-07-14 11:58:29 +03:00
LaserEyess ee27629244 TOOLS/lua/autoload: load files even if current file is hidden
When the current file is hidden and `ignore_hidden` is true,
autoload will skip loading other files in the current directory. Make
sure that the current file is always counted for autoloading even if it
is hidden.
2021-06-24 13:13:53 +00:00
LaserEyess 28c53dbfa0 TOOLS/lua/autoload: add ignore_hidden option
In 8a7614a0fb files that start with a '.'
were blacklisted from autoload.lua. Since then
35e8710b86 was introduced and explicitly
whitelisted file extensions. With this change, there is no longer a
reason to blacklist all files starting with '.', because it is valid to
have a file called '.hidden.mkv', and there is no chance of hidden files
such as '.bashrc', '.DS_STORE', '.gitignore', etc. being autoloaded by
mpv.

This commit tries to keep the same behavior as before, which is to by
default not load hidden files, but allows the user to optionally allow
hidden files to be autoloaded.
2021-06-24 13:13:53 +00:00
der richter 9fbe000451 osxbundle: fix slow and wasteful memory allocation
when using the bundle with activated big enough cache, very slow and
wasteful memory allocations lead to jittery playback and lot of dropped
frames. the cache had to have a certain size so it would constantly
allocate new memory to reproduce this. this never happens when started
from the terminal.

the source of the problem is a different malloc allocation policy,
MALLOC_NANO, that allocated a huge amount of virtual memory without
actually using it. the usage was between 0% to 25% of that virtual
memory. the binaries allocation policy on the other hand used >80% of
that allocated virtual memory and was a lot more efficient, it would use
MALLOC_TINY instead.

this is fixed by setting the MallocNanoZone environment variable to 0
to use the V1 of the allocation policy. when started from the bundle via
launchd this is forced to 1 and V2 policy which causes this problem.

some more info can be found in following file and its comments on the
Apple open source site:
https://opensource.apple.com/source/libmalloc/libmalloc-317.40.8/src/nano_malloc_common.c.auto.html

Fixes #7405
2021-05-16 13:50:40 +02:00
sfan5 10d68d06e6 build: move website rebuild into Linux/clang travis job
The mingw ones will be removed in the next commit.
2021-05-16 01:55:37 +03:00
jimman2003 aac1844179 umpv: Use generator expression for files
Instead of list. potential memory savings.
2021-03-03 21:35:33 +02:00
Biswapriyo Nath b95c7dd6cc appveyor: Use MSYS2's spirv-cross package instead of building it 2021-02-23 01:38:39 +02:00
Jim Manos 5edf22d2e9 umpv: remove unused imports
* fcntl usage was replaced by socket usage in
  518bd4c306
* stat usage was removed in 51a3f13705
  as the socket was created under the user's HOME.
2021-01-19 22:44:59 +02:00
James Ross-Gowan 2bc88a2936 appveyor: use MSYS2 shaderc package
There's a shaderc package in MSYS2 now. Using it should shave ten
minutes off the appveyor build.
2020-12-19 23:46:16 +11:00
LaserEyess 8886f017a1 matroska.py: remove python2 support
Since 0.33.0 mpv does not support python2. This commit removes
python2 support from the file completely with the following
changes:

 - __future__ import of print_function is python2 only
 - unicode literals are legacy in python3
 - 'sys.version_info.major < 3' check is redundant
2020-11-27 11:17:29 +01:00
sfan5 6bb73040dd file2string: remove question mark from safe chars
Trigraphs such as "??=" (which are enabled by default with -std=c11)
can mess up strings, so avoid them entirely by escaping question marks.

This also drops Python 2 compatibility from file2string, making the
change to the waf rule necessary. The input file is now opened in
binary mode which is also more correct versus the old text mode
which just happened to work even on binary files.
2020-11-22 17:16:57 +01:00
Alexandre Iooss 75acc04262 stream_lavf: enable SRT protocol support through FFmpeg
Additionally, announce support for the protocol in Mac and Linux
application metadata.
2020-10-15 23:53:33 +03:00
wm4 e27c523a10 command: extend subprocess command stdin, change behavior
Make it possible to feed a string to stdin of a subprocess. Out of
laziness, it can't be an arbitrary byte string. (Would require adding an
option type that takes in a Lua byte string.)

Do not set stdin of a subprocess to fd 0 (i.e. mpv's stdin) anymore,
because it makes things more consistent. Enabling stdin didn't make too
much sense in the first place, so this behavior change seems
justifiable.

win32 support missing.

Fixes: #8003
2020-08-16 02:54:44 +02:00
wm4 45cc47a68b TOOLS/file2string: change to python3
The same was done to matroska.py before, so at least it's consistent.
Doesn't matter for waf, because it imports this script (rather than
executing it).
2020-08-12 17:21:49 +02:00
ヒカリ 376aea36eb TOOLS/autocrop.lua: automatically crop at startup 2020-06-01 23:07:26 -07:00
wm4 eeb711f5f3 umpv: convert to python 3
Sigh.
2020-04-03 12:57:24 +02:00
wm4 518bd4c306 umpv: change from legacy FIFO to socket
--input-file is deprecated, and the JSON IPC is saner anyway.
2020-03-28 00:38:29 +01:00
Jan Ekström 038f2213e1 ci: remove libass enablement
This is no longer a configurable option.
2020-03-22 14:33:41 +02:00
wm4 ba70b150fb client API: provide ways to finish property changes on file changes
When the current file changes (or rather, when starting/finishing
playback of a playlist entry), clients tend to have the problem that
it's hard to tell whether a property change notification (via
mpv_observe_property() and mechanisms layered on top of it) is from the
previous or new playlist entry. The previous commit probably helps, but
all the asynchronity is still a bit unhelpful.

Try to make this better by adding new hooks, that are run before/after
playback init/deinit. This is similar to the existing hooks, except
they're outside of "initialized" playback, which excludes that you might
accidentally get an overlap between the current and the previous/next
playlist entry.

That still doesn't seem quite enough, since normally, property change
notifications come after the hook event. So basically a client would
have to explicitly "drain" the event queue within the hook, and make the
hook continue only after that is done. Knowing when property
notifications are done is another asynchronous nightmare (how exactly it
works keeps changing within client.c, and an API user probably can't
tell anymore when all pending properties are truly done). So introduce
another guarantee: properties that were changed before the hook happens
will be returned before the hook event is returned. That means the
client will have received all pending property notifications from the
previous playlist entry (or whatever) before the hook is entered.

As another minor complication, we shouldn't just keep the hook pending
until _all_ property notifications are done, since the client's hook
could produce new ones. (Or just consider things like the demuxer thread
hammering the client with cache update events, while the "on_preloaded"
hook is run.) So there is some extra untested, fragile logic in client.c
to handle this (the waiting_for_hook flag).

This probably works, but was barely tested. Not sure if this helps
anyone, but I think it's fine for my own purposes. (I really hated this
aspect of the API whenever I used it myself.)
2020-03-07 02:52:10 +01:00
wm4 7a76b577d8 command: extend osd-overlay command with bounds reporting
This is more or less a minimal hack to make _some_ text measurement
functionality available to scripts. Since libass does not support such a
thing, this simply uses the bounding box of the rendered text.

This is far from ideal. Problems include:
- using a bitmap bounding box
- additional memory waste and/or flushing caches
- dependency on window size
- odd small deviations with different window sizes (run osd-test.lua and
  resize the window after each timer update; the bounding boxes aren't
  adjusted in an overly useful way)
- inability to query the size _after_ actual rendering

But I guess it's a start. Since I'm aware that it's crap, add a threat
to the manpage that this may be changed/removed again. For now, I'm
interested whether anyone will have use for it in its current form, as
it's an often requested feature.
2020-03-06 18:20:11 +01:00
wm4 d45d4f86e1 skip-logo.lua: remove lua 5.2 warning message
(OK, I tested it.)
2020-02-29 21:49:14 +01:00
jnozsc 611c92ef1d *.py: cosmetic changes 2020-02-27 21:36:21 +01:00
Thomas Carmichael e162bcb5a0 TOOLS/lua/autoload.lua: update script comments
The example configuration uses values of true/false for the script
options. As per DOCS/man/lua.rst boolean values should be represented
with yes/no and using true/false will result in an error.

This updates the comments and changes the true/false values under the
example configuration to yes/no.
2020-02-15 20:41:07 +01:00
der richter 2607a2b892 mac: activate logging when started from the bundle
this creates a default log for the last mpv run when started from the
bundle. that way one can get a log of what happened even after an issue
occurred. also add a menu entry under Help to show the current log, but
only when the bundle is used.

Fixes #7396
Fixes #2547
2020-02-08 10:55:07 +01:00
Down Thomas 698a6a2747 osxbundle: simplify process_libraries() to eliminate leafs()
Instead of traversing across leafs() which can lead to an infinite
loop issue with cross-linked libraries, use the dictionary
(libs_dict) created by libraries() to create a set (libs_set) of
every unique library. Every value in libs_dict is also a key in
libs_dict, so every unique library linked to mpv will be a key in
libs_dict. Use set() on libs_dict to return a set of the keys from
libs_dict, and remove binary from the set so that a duplicate of
the binary is not added to the libs directory.

Iterate over libs_set to bundle dylibs while using the libs_dict
to determine which install_names to change.
2019-12-15 12:33:25 +01:00
Philip Langdale db3754d8d6 osc: use custom symbols for window controls
I was recently informed that unicode has official symbols for
window controls, and I put together a change to use them, which
worked, as long as a suitable font was installed. However, it's
not that hard to get a normal system that lacks an appropriate
font, and libass wants to print warnings if the symbols aren't
in the default font, which will almost always be true.

So, I gave up and added the symbols to the custom osd font that
we already have. This ensures they are always available, and
that they are aligned consistently on all platforms.

I took the symbols from the `symbola` font, as this has a suitable
licence and the symbols look nice enough.

Symbola Licence:

    Fonts are free for any use; they may be opened, edited,
    modified, regenerated, packaged and redistributed.

Finally, as we now have access to an un-maximize symbol, I added
logic to use it when the window is maximized.
2019-12-11 13:53:10 -08:00
wm4 77f309c94f vo_gpu, options: don't return NaN through API
Internally, vo_gpu uses NaN for some options to indicate a default value
that is different depending on the context (e.g. different scalers).
There are 2 problems with this:

1. you couldn't reset the options to their defaults
2. NaN is a damn mess and shouldn't be part of the API

The option parser already rejected NaN explicitly, which is why 1.
didn't work. Regarding 2., JSON might be a good example, and actually
caused a bug report.

Fix this by mapping NaN to the special value "default". I think I'd
prefer other mechanisms (maybe just having every scaler expose separate
options?), but for now this will do. See you in a future commit, which
painfully deprecates this and replaces it with something else.

I refrained from using "no" (my favorite magic value for "unset" etc.)
because then I'd have e.g. make --no-scale-param1 work, which in
addition to a lot of effort looks dumb and nobody will use it.

Here's also an apology for the shitty added test script.

Fixes: #6691
2019-10-25 00:25:05 +02:00
wm4 68bbc55eda skip-logo.lua: fix skipping in the first two frames
mpv typically decodes and filters at least 2 frames before starting
playback. This happens during seeks, as well as when playback starts
from the beginning of the file.

skip-logo.lua receives notifications for all filtered frames, even
during seeking. It should interrupt during seeking, so as a crude
heuristic, it ignored all frames while the player was seeking. This does
not mean all these frames are skipped due to seeking (thus it's a "crude
hueristic"). In particular, it means that the first 2 frames of a video
cannot be skipped, since they're filtered within the playback restart
phase (equivalent to "seeking").

Fix this by making the heuristic slightly less crude. Since we observe
the property as "none", the property is not actually read until we do it
explicitly. By not reading it during seeking, we can let the frames
internally queue up (vf_fingerprint discards them in a ringbuffer-like
fashion if they're too many). Then, if seeking ends, we get the current
playback timestamp, and check queued up frames that are at or after that
timestamp. (In some ways, this duplicates what the player's seeking
logic does.)

A disadvantage is that this is racy. While playback-time is guaranteed
to be set when seeking changes from false to true, playback could
already have progressed to the next frame (or more) before the script
gets time to react. In theory, we could add a seek restart hook or so,
but I don't want to. A property that returns the last playback restart
time would also do it, but feels to special. Not an important problem
in practice anyway.
2019-10-08 21:26:43 +02:00
wm4 6064720011 player: "subprocess" command should stop immediately in idle mode
The description of the "playback_only" field in the "subprocess" command
says "you can't start it outside of playback". This did not work
correctly: if the player was started in idle mode in the first place,
the subprocess was allowed to run even with playback_only=yes.

This is a bug, and this change fixes it. Add a test for this to
command-test.lua.

For #7025.
2019-10-04 16:30:48 +02:00
Marek Sebera 35e8710b86 autoload.lua: Configurable autoload types
Autoload script now suppports loading of not only video, but also
image and audio files, in a manner, where one can configure which
of the groups (audio, videos, images) is currently enabled.

Use file script-opts/autoload.conf with key=value configuration keys
disabled,images,videos,audio to configure autoload script.

See documentation on top of the script
2019-10-02 12:48:56 +02:00
Philip Sequeira 2712db8238 zsh completion: move generation to runtime and improve
The completion function itself now parses --list-options on the first
tab press and caches the results. This does mean a slight delay on that
first tab press, but it will only do this if the argument being
completed looks like an option (i.e. starts with "-"), so there is never
a delay when just completing a file name. I've also put some effort into
making it reasonably fast; on my machine it's consistently under 100 ms,
more than half of which is mpv itself.

Installation of zsh completion is now done unconditionally because it's
nothing more than copying a file. If you really don't want it installed,
set zshdir to empty: `./waf configure --zshdir= ...`

Improvements in functionality compared to the old script:

 * Produces the right results for mpv binaries other than the one it was
   installed with (like a dev build for testing changes).

 * Does not require running mpv at build time, so it won't cause
   problems with cross compilation.

 * Handles aliases.

 * Slightly nicer handling of options that take comma-separated values
   and/or sub-options: A space is now inserted at the end instead of a
   comma, allowing you to immediately start typing the next argument,
   but typing a comma will still remove the automatically added space,
   and = and : will now do that too, so you can immediately add a
   sub-option.

 * More general/flexible handling of values for options that print their
   possible values with --option=help. The code as is could handle quite
   a few more options (*scale, demuxers, decoders, ...), but nobody
   wants to maintain that list here so we'll just stick with what the
   old completion script already did.
2019-09-27 13:19:29 +02:00
der richter e3972746dc osxbundle: remove rpath definitions towards dev tools
since the loading order of rpaths is system wide lib path, dev tool path
and then bundle lib path it's possible for the xcode swift libs to be
incompatible with the libs the bundle was build with. this leads to
possible segfaults. if we distribute the bundle we don't want to load
the libs from the dev tools anyway.
2019-09-22 17:07:51 +03:00
der richter f64c0115ae build: fix swift linking with upcoming xcode 11
in xcode 11 the dynamic swift libraries were moved to a separated
versioned swift folder, which can't be used for linking and only for
distribution. additional to the std dynamic swift lib folder the system
wide folder is needed for linking too.
2019-09-22 17:07:51 +03:00
wm4 9cfeafa89e video: add vf_fingerprint and a skip-logo script
skip-logo.lua is just what I wanted to have. Explanations are on the top
of that file. As usual, all documentation threatens to remove this stuff
all the time, since this stuff is just for me, and unlike a normal user
I can afford the luxuary of hacking the shit directly into the player.

vf_fingerprint is needed to support this script. It needs to scale down
video frames as part of its operation. For that, it uses zimg. zimg is
much faster than libswscale and generates more correct output. (The
filter includes a runtime fallback, but it doesn't even work because
libswscale fucks up and can't do YUV->Gray with range adjustment.)

Note on the algorithm: seems almost too simple, but was suggested to me.
It seems to be pretty effective, although long time experience with
false positives is missing. At first I wanted to use dHash [1][2], which
is also pretty simple and effective, but might actually be worse than
the implemented mechanism. dHash has the advantage that the fingerprint
is smaller. But exact matching is too unreliable, and you'd still need
to determine the number of different bits for fuzzier comparison. So
there wasn't really a reason to use it.

[1] https://pypi.org/project/dhash/
[2] http://www.hackerfactor.com/blog/index.php?/archives/529-Kind-of-Like-That.html
2019-09-19 20:37:05 +02:00
Ricardo Constantino 82ba31c636
TOOLS/travis-rebuild-website: update condition after docker transition
Closes #6822
2019-07-30 20:12:33 +01:00
der richter 9a2c760614 osxbundle: bundle the dynamic swift std library when needed 2019-07-21 18:13:07 +03:00
der richter efde2d8644 osxbundle: print the output of the dylib-unhell call 2019-07-21 18:13:07 +03:00
James Ross-Gowan ea91162802 appveyor: remove broken packages, install libplacebo
Support for Ada and Objective-C was removed from MSYS2, which made
pacman refuse to update GCC while the gcc-ada and gcc-objc packages were
installed. Remove those packages before updating the others. Also remove
ANGLE, which has been removed from MSYS2, and add libplacebo, which is
now needed for the Vulkan VO.
2019-07-03 17:30:50 +03:00
James Ross-Gowan cc38035841 vo_gpu: d3d11: use the SPIRV-Cross C API directly
When the D3D11 backend was first written, SPIRV-Cross only had a C++ API
and no guarantee of API or ABI stability, so instead of using
SPIRV-Cross directly, mpv used an unofficial C wrapper called crossc.

Now that KhronosGroup/SPIRV-Cross#611 is resolved, SPIRV-Cross has an
official C API that can be used instead, so remove crossc and use
SPIRV-Cross directly.
2019-06-12 23:03:55 +03:00
James Ross-Gowan 4e9dc60d9e appveyor: fix shaderc dependencies
Shaderc comes with a Python script that automatically fetches
"known-good" versions of its dependencies. Use that instead of manually
cloning dependencies to third-party.
2019-04-16 21:35:00 +03:00
Anton Kindestam 8b83c89966 Merge commit '559a400ac36e75a8d73ba263fd7fa6736df1c2da' into wm4-commits--merge-edition
This bumps libmpv version to 1.103
2018-12-05 19:19:24 +01:00
Andreas Wennerberg 4a0fcdfbd8 TOOLS/autoload: Fixed broken "disabled" option
`--script-opts=autoload-disabled=yes` now
properly stops the script from running.
2018-06-23 13:23:07 +01:00