Closed jrejaud closed 3 years ago
This is surprisingly trick because the properties that let you differentiate between videos and images (assuming you want to consider audio with cover art) before playback are container-fps and estimated-frame-count, but they are unavailable resp. 0 for some videos and images, like wmv. This works for most files though:
[video] profile-cond=container_fps > 1
[audio] profile-cond=audio_codec and (container_fps == nil or container_fps == 1)
A more reliable way would be using estimated-vf-fps, but that would evaluate the conditions every 10 frames.
Thanks @guidocella, that makes a lot of sense.
I tried it however and got the following error:
[cplayer] Error parsing option profile-cond (option not found)
[cplayer] /Users/jrejaud/.config/mpv/mpv.conf:48: setting option profile-cond='width >= 280' failed.
This error occurred when I tried the profile-cond example specified in the manual.
Is it possible my binary is missing the option to allow profile-cond?
I installed the binary using Brew (on Mac) btw
[cplayer] Command line options: '-v'
[cplayer] mpv 0.32.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
[cplayer] built on Fri Jan 31 11:28:05 CET 2020
[cplayer] ffmpeg library versions:
[cplayer] libavutil 56.31.100
[cplayer] libavcodec 58.54.100
[cplayer] libavformat 58.29.100
[cplayer] libswscale 5.5.100
[cplayer] libavfilter 7.57.100
[cplayer] libswresample 3.5.100
[cplayer] ffmpeg version: 4.2.2
[cplayer]
[cplayer] Configuration: waf configure --prefix=/Users/djinn/bajzkorw/build-0.32.0 --enable-manpage-build --disable-android --disable-tvos --disable-egl-android --disable-macos-media-player --disable-macos-10-12-2-features
[cplayer] List of enabled features: 51deb asm atomics bsd-fstatfs build-date cocoa coreaudio cplayer cplugins debug-build drmprime fchmod ffmpeg gl gl-cocoa glob glob-posix gnuc gpl iconv javascript lcms2 libarchive libass libass-osd libav-any libavcodec libavdevice libavutil libdl libm lua macos-10-11-features macos-cocoa-cb macos-touchbar optimize osx-thread-name posix posix-or-mingw posix-spawn posix-spawn-native pthreads rubberband stdatomic uchardet videotoolbox-gl videotoolbox-hwaccel zlib
[cplayer] Reading config file /Users/jrejaud/.config/mpv/mpv.conf
[cplayer] Error parsing option profile-cond (option not found)
[cplayer] /Users/jrejaud/.config/mpv/mpv.conf:48: setting option profile-cond='width >= 280' failed.
[cplayer] Applying profile 'default'...
[cplayer] Setting option 'macos-title-bar-material' = 'dark' (flags = 4)
[cplayer] Setting option 'geometry' = '50%:50%' (flags = 4)
[cplayer] Setting option 'autofit-larger' = '90%x90%' (flags = 4)
[cplayer] Setting option 'v' = '' (flags = 8)
[file] Opening /Users/jrejaud/.config/mpv/input.conf
[input] Parsing input config file /Users/jrejaud/.config/mpv/input.conf
[input] Input config file /Users/jrejaud/.config/mpv/input.conf parsed: 7 binds
[cplayer] mpv 0.32.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
[cplayer] built on Fri Jan 31 11:28:05 CET 2020
[cplayer] ffmpeg library versions:
[cplayer] libavutil 56.31.100
[cplayer] libavcodec 58.54.100
[cplayer] libavformat 58.29.100
[cplayer] libswscale 5.5.100
[cplayer] libavfilter 7.57.100
[cplayer] libswresample 3.5.100
[cplayer] ffmpeg version: 4.2.2
[cplayer]
[cplayer] Usage: mpv [options] [url|path/]filename
[cplayer]
[cplayer] Basic options:
[cplayer] --start=<time> seek to given (percent, seconds, or hh:mm:ss) position
[cplayer] --no-audio do not play sound
[cplayer] --no-video do not play video
[cplayer] --fs fullscreen playback
[cplayer] --sub-file=<file> specify subtitle file to use
[cplayer] --playlist=<file> specify playlist file
[cplayer]
[cplayer] --list-options list all mpv options
[cplayer] --h=<string> print options which contain the given string in their name
[cplayer]
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Set property: shared-script-properties -> 1
Yes, your binary was built in January but auto profiles were added in August: https://github.com/mpv-player/mpv/commit/13d354e46d27fd0c433880839abcf9096dbcbc2f
This is surprisingly trick because the properties that let you differentiate between videos and images (assuming you want to consider audio with cover art) before playback are container-fps and estimated-frame-count, but they are unavailable resp. 0 for some videos and images, like wmv. This works for most files though:
@guidocella Is there any way to check MIME-Type of the current running file? Even if with LUA. It would make customizing such options for different file types so much easier.
If video-file or video-stream then
do this
elseif image-file then
do this
elseif audio-file or audio-stream then
do this
end
Is there any way to check MIME-Type of the current running file? Even if with LUA. It would make customizing such options for different file types so much easier.
I don't believe there is, you would have to use something like
local r = mp.command_native({
name = 'subprocess',
playback_only = false,
capture_stdout = true,
args = {'file', '-b', '--mime-type', mp.get_property('path')}
})
if r.stdout:match('video') then
print('this is a video')
elseif r.stdout:match('audio') then
print('this is audio')
elseif r.stdout:match('image') then
print('this is an image')
end
But that doesn't work for URLs.
Very interesting approach there, thank you very much.
@guidocella
Hi guido,
Good catch, I removed my old 0.32 binary (which wasn't from brew, actually, I must have installed it manually a while ago) and got the 0.33 one from brew, however I am now getting a new error if I include auto profiles in my config:
Adding:
[something]
profile-desc=HD video sucks
hprofile-cond=width >= 280
hhue=-50
causes:
[auto_profiles]
[auto_profiles] stack traceback:
[auto_profiles] [C]: in function 'load'
[auto_profiles] @auto_profiles.lua:140: in function 'compile_cond'
[auto_profiles] @auto_profiles.lua:158: in function 'load_profiles'
[auto_profiles] @auto_profiles.lua:170: in main chunk
[auto_profiles] [C]: ?
[auto_profiles] [C]: in function 'require'
[auto_profiles] [string "require '@auto_profiles.lua'"]:1: in main chunk
[auto_profiles] [C]: ?
[auto_profiles] [C]: ?
[auto_profiles] Lua error: @auto_profiles.lua:140: bad argument #1 to 'load' (function expected, got string)
If it matters, I have Lua 5.3.5:
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
Can you advise on how to resolve this issue?
I assume you copied the profile incorrectly only in this comment since the 'h' before profile-cond and hue causes a different error. I am not sure, try removing everything but the auto profile from your config and see if you still get the error. If you don't, restore other parts of the config until it errors again. And even if you have Lua 5.3 installed, that isn't supported by mpv so it must have been linked against Lua 5.1, 5.2 o LuaJIT.
@guidocella
Sorry, I copied it wrong into GH. There's no h in front of my profile snippet.
I've removed this part:
[something]
profile-desc=HD video sucks
profile-cond=width >= 280
hue=-50
from my config and the error is gone, so it's definitely that causing it.
Here is the output of my mpv -v
:
[cplayer] Command line options: '-v'
[cplayer] mpv 0.33.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
[cplayer] built on Sun Nov 22 19:54:23 GMT 2020
[cplayer] FFmpeg library versions:
[cplayer] libavutil 56.51.100
[cplayer] libavcodec 58.91.100
[cplayer] libavformat 58.45.100
[cplayer] libswscale 5.7.100
[cplayer] libavfilter 7.85.100
[cplayer] libswresample 3.7.100
[cplayer] FFmpeg version: 4.3.1
[cplayer]
[cplayer] Configuration: waf configure --prefix=/usr/local/Cellar/mpv/0.33.0 --enable-html-build --enable-javascript --enable-libmpv-shared --enable-lua --enable-libarchive --enable-uchardet --confdir=/usr/local/etc/mpv --datadir=/usr/local/Cellar/mpv/0.33.0/share/mpv --mandir=/usr/local/Cellar/mpv/0.33.0/share/man --docdir=/usr/local/Cellar/mpv/0.33.0/share/doc/mpv --zshdir=/usr/local/Cellar/mpv/0.33.0/share/zsh/site-functions --lua=51deb
[cplayer] List of enabled features: 51deb asm bsd-fstatfs build-date cocoa coreaudio cplayer cplugins debug-build ffmpeg gl gl-cocoa glob glob-posix gpl iconv javascript jpeg lcms2 libarchive libass libavdevice libbluray libdl libm libmpv-shared lua macos-10-11-features macos-10-12-2-features macos-10-14-features macos-cocoa-cb macos-media-player macos-touchbar optimize osx-thread-name plain-gl posix posix-or-mingw pthreads rubberband stdatomic swift uchardet vapoursynth videotoolbox-gl videotoolbox-hwaccel zimg zlib
[cplayer] Reading config file /Users/jrejaud/.config/mpv/mpv.conf
[cplayer] Applying profile 'default'...
[cplayer] Setting option 'macos-title-bar-material' = 'dark' (flags = 4)
[cplayer] Setting option 'geometry' = '50%:50%' (flags = 4)
[cplayer] Setting option 'autofit-larger' = '90%x90%' (flags = 4)
[cplayer] Setting option 'save-position-on-quit' = '' (flags = 4)
[cplayer] Setting option 'v' = '' (flags = 8)
[bdmv/bluray] Opening /Users/jrejaud/.config/mpv/input.conf
[file] Opening /Users/jrejaud/.config/mpv/input.conf
[input] Parsing input config file /Users/jrejaud/.config/mpv/input.conf
[input] Input config file /Users/jrejaud/.config/mpv/input.conf parsed: 7 binds
[cplayer] mpv 0.33.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
[cplayer] built on Sun Nov 22 19:54:23 GMT 2020
[cplayer] FFmpeg library versions:
[cplayer] libavutil 56.51.100
[cplayer] libavcodec 58.91.100
[cplayer] libavformat 58.45.100
[cplayer] libswscale 5.7.100
[cplayer] libavfilter 7.85.100
[cplayer] libswresample 3.7.100
[cplayer] FFmpeg version: 4.3.1
[cplayer]
[cplayer] Usage: mpv [options] [url|path/]filename
[cplayer]
[cplayer] Basic options:
[cplayer] --start=<time> seek to given (percent, seconds, or hh:mm:ss) position
[cplayer] --no-audio do not play sound
[cplayer] --no-video do not play video
[cplayer] --fs fullscreen playback
[cplayer] --sub-file=<file> specify subtitle file to use
[cplayer] --playlist=<file> specify playlist file
[cplayer]
[cplayer] --list-options list all mpv options
[cplayer] --h=<string> print options which contain the given string in their name
[cplayer]
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Set property: shared-script-properties -> 1
And here is the output with a profile added to mpv.conf
:
[cplayer] Command line options: '-v'
[cplayer] mpv 0.33.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
[cplayer] built on Sun Nov 22 19:54:23 GMT 2020
[cplayer] FFmpeg library versions:
[cplayer] libavutil 56.51.100
[cplayer] libavcodec 58.91.100
[cplayer] libavformat 58.45.100
[cplayer] libswscale 5.7.100
[cplayer] libavfilter 7.85.100
[cplayer] libswresample 3.7.100
[cplayer] FFmpeg version: 4.3.1
[cplayer]
[cplayer] Configuration: waf configure --prefix=/usr/local/Cellar/mpv/0.33.0 --enable-html-build --enable-javascript --enable-libmpv-shared --enable-lua --enable-libarchive --enable-uchardet --confdir=/usr/local/etc/mpv --datadir=/usr/local/Cellar/mpv/0.33.0/share/mpv --mandir=/usr/local/Cellar/mpv/0.33.0/share/man --docdir=/usr/local/Cellar/mpv/0.33.0/share/doc/mpv --zshdir=/usr/local/Cellar/mpv/0.33.0/share/zsh/site-functions --lua=51deb
[cplayer] List of enabled features: 51deb asm bsd-fstatfs build-date cocoa coreaudio cplayer cplugins debug-build ffmpeg gl gl-cocoa glob glob-posix gpl iconv javascript jpeg lcms2 libarchive libass libavdevice libbluray libdl libm libmpv-shared lua macos-10-11-features macos-10-12-2-features macos-10-14-features macos-cocoa-cb macos-media-player macos-touchbar optimize osx-thread-name plain-gl posix posix-or-mingw pthreads rubberband stdatomic swift uchardet vapoursynth videotoolbox-gl videotoolbox-hwaccel zimg zlib
[cplayer] Reading config file /Users/jrejaud/.config/mpv/mpv.conf
[cplayer] Applying profile 'default'...
[cplayer] Setting option 'macos-title-bar-material' = 'dark' (flags = 4)
[cplayer] Setting option 'geometry' = '50%:50%' (flags = 4)
[cplayer] Setting option 'autofit-larger' = '90%x90%' (flags = 4)
[cplayer] Setting option 'hue' = '-50' (flags = 4)
[cplayer] Setting option 'v' = '' (flags = 8)
[bdmv/bluray] Opening /Users/jrejaud/.config/mpv/input.conf
[file] Opening /Users/jrejaud/.config/mpv/input.conf
[input] Parsing input config file /Users/jrejaud/.config/mpv/input.conf
[input] Input config file /Users/jrejaud/.config/mpv/input.conf parsed: 7 binds
[cplayer] mpv 0.33.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
[cplayer] built on Sun Nov 22 19:54:23 GMT 2020
[cplayer] FFmpeg library versions:
[cplayer] libavutil 56.51.100
[cplayer] libavcodec 58.91.100
[cplayer] libavformat 58.45.100
[cplayer] libswscale 5.7.100
[cplayer] libavfilter 7.85.100
[cplayer] libswresample 3.7.100
[cplayer] FFmpeg version: 4.3.1
[cplayer]
[cplayer] Usage: mpv [options] [url|path/]filename
[cplayer]
[cplayer] Basic options:
[cplayer] --start=<time> seek to given (percent, seconds, or hh:mm:ss) position
[cplayer] --no-audio do not play sound
[cplayer] --no-video do not play video
[cplayer] --fs fullscreen playback
[cplayer] --sub-file=<file> specify subtitle file to use
[cplayer] --playlist=<file> specify playlist file
[cplayer]
[cplayer] --list-options list all mpv options
[cplayer] --h=<string> print options which contain the given string in their name
[cplayer]
[auto_profiles]
[auto_profiles] stack traceback:
[auto_profiles] [C]: in function 'load'
[auto_profiles] @auto_profiles.lua:140: in function 'compile_cond'
[auto_profiles] @auto_profiles.lua:158: in function 'load_profiles'
[auto_profiles] @auto_profiles.lua:170: in main chunk
[auto_profiles] [C]: ?
[auto_profiles] [C]: in function 'require'
[auto_profiles] [string "require '@auto_profiles.lua'"]:1: in main chunk
[auto_profiles] [C]: ?
[auto_profiles] [C]: ?
[auto_profiles] Lua error: @auto_profiles.lua:140: bad argument #1 to 'load' (function expected, got string)
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Set property: shared-script-properties -> 1
No idea, do you still get the error by leaving only the profile in mpv.conf? Or by changing the condition?
@jrejaud Your mpv is using Lua 5.1 and it seems that bit of code in the auto_profiles script just isn't valid in 5.1. I think we could fix that.
Edit: See #8355
Hi there,
It is possible to create an auto profile that will apply settings to all video files?
I would like to have a set of settings apply to only videos and another set that only applies to all audio files.
Wizard program btw, I am new to using mpv but I love it so far. 👍