mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.31k stars 2.9k forks source link

Mysterious 'terminal'='no' when running mpv #3086

Closed phydano closed 7 years ago

phydano commented 8 years ago

Hi,

This is more of a question rather than an issue. Apologies if this is not a place to ask questions. In an input.conf I want to change a shortcut and I have looked here as an example: https://github.com/Argon-/mpv-config/blob/master/input.conf

I want to cycle an aspect ratio the same as shortcut 'A' but with little tweaks to it. Here is the line of code: cycle_values video-aspect "16:9" "16:10" "-1" ; show_text "Aspect Ratio: ${?video-aspect==1.778:16:9}${?video-aspect==1.600:16:10}"

But I stumbled when dealing with '-1' case. What can I put in show_text to make it show something like 'Aspect Ratio: sometext'?

Also how can I check to make sure my mpv.conf and input.conf file is correct?

maniak1349 commented 8 years ago

You probably want something like this:

A cycle_values video-aspect "16:9" "16:10" "-1" ; show_text "Aspect Ratio: ${?video-aspect==1.778:16:9}${?video-aspect==1.600:16:10}${!video-aspect==1.778:${!video-aspect==1.600:${video-aspect}}}"

But it's not really pretty and will get even worse if you add other aspects. Maybe a simple lua script will be better? Something like this:

function on_video_aspect_change(name, value)
    if math.abs( value - 1.6 ) < 0.001 then
        mp.osd_message( "Aspect Ratio: 16:10" )
    elseif math.abs( value - 1.778 ) < 0.001 then
        mp.osd_message( "Aspect Ratio: 16:9" )
    end
end
mp.observe_property("video-aspect", "number", on_video_aspect_change)

Configuration errors are reported in the terminal. You can also use --log-file=<path> and search for [e] lines in log file.

maniak1349 commented 8 years ago

Previous version will show aspect at the beginning of every file with new aspect. Here's a better version:

function show_aspect_handler( )
    local value = mp.get_property_osd( "video-aspect", "(unknown)" )
    if value == "1.600" then
        mp.osd_message( "Aspect Ratio: 16:10" )
    elseif value == "1.778" then
        mp.osd_message( "Aspect Ratio: 16:9" )
    else
        mp.osd_message( "Aspect Ratio: " .. value )
    end
end
mp.add_key_binding( "", "show_aspect", show_aspect_handler )

into the script file and

A no-osd cycle_values video-aspect "16:9" "16:10" "-1" ; script-binding show_aspect

into input.conf.

phydano commented 8 years ago

Thank you. I will give those a try. So if there is an error in my file, running mpv via terminal will report me the error?

maniak1349 commented 8 years ago

So if there is an error in my file, running mpv via terminal will report me the error?

Yes, something like this:

Error parsing option what-the-hell-is-that (option not found)
c:/programs/mpv/mpv/config:24: setting option what-the-hell-is-that='' failed.
[input] Unfinished key binding: thats_not_a_key! at c:/programs/mpv/mpv/input.conf:19
phydano commented 8 years ago

I tend to use the GUI...so what should I type in the terminal? I try 'mpv' and it seems to open the window and no error report (even though I try to write it wrong)....can you give me the command for it?

Hrxn commented 8 years ago

Just start it from the terminal, it should error out if the config file can't be parsed. Otherwise: Try it with mpv -v

phydano commented 8 years ago

For example in my config file, I write in 'volm = 50'...(the correct should be volume=50) but I don't see any error...it almost like that line is never written in the first place (I think mpv just skip that line).

maniak1349 commented 8 years ago

If you're on Windows you need to use mpv.com instead of mpv.exe to have terminal output. Either launch it directly from the terminal or drag file over on it in the explorer.

If you're on x64 system and want a shortcut for mpv.com you will need to make a shortcut to mpv.exe and replace the shortcut's command line with something like that: C:\Windows\System32\cmd.exe /c C:\programs\mpv\mpv.com because Windows believes that .com files are the old DOS executable ones and will not allow to make a shortcut to it directly.

Hrxn commented 8 years ago

Yes, that's true.

But on Windows, if you just type mpv into a cmd window, it will launch mpv.com, because it takes precedence in PATHEXT.

phydano commented 8 years ago

Sorry for providing too little info. I am on MAC OSX. I thought something wrong with my version of mpv...so I update but no still the same....when I try mpv -v I got the following:

https://www.dropbox.com/s/wuocaiygrifdcu8/when%20execute%20mpv%20-v%20in%20mac.png?dl=0

One more question, I use this code to update mpv on my mac to the latest version.

brew rm mpv && brew install --HEAD --with-bundle --with-bluray-support --with-libdvdread --with-little-cms2 --with-lua --with-bundle mpv

If I want to download a specific version (e.g. git-2b4123f), how do I change the --HEAD to that?

Hrxn commented 8 years ago

Tip, if you mark, copy and paste the text between three back-ticks, you'll get something like this:

if (isAwesome){
  return true
}

For example, my output of mpv -v looks like this:

C:\Users\Hrxn>mpv -v
[cplayer] Command line options: '-v'
[cplayer] mpv 0.17.0-git-190578b (C) 2000-2016 mpv/MPlayer/mplayer2 projects
[cplayer]  built on Mon Apr 11 19:16:14 CEST 2016
[cplayer] ffmpeg library versions:
[cplayer]    libavutil       55.20.100
[cplayer]    libavcodec      57.34.100
[cplayer]    libavformat     57.33.100
[cplayer]    libswscale      4.1.100
[cplayer]    libavfilter     6.41.100
[cplayer]    libswresample   2.0.101
[cplayer] ffmpeg version: N-79342-g95f8a9e
[cplayer]
[cplayer] Configuration: /home/lachs0r/mingw-w64-cmake/buildroot/build64/packages/mpv-prefix/src/mpv/waf configure --enable-static-build --enable-pdf-build --disable-manpage-build --enable-libmpv-shared --enable-gpl3 --enable-encoding --disable-egl-angle --enable-lua --enable-libarchive --enable-libass --enable-libbluray --enable-dvdread --enable-dvdnav --enable-uchardet --enable-rubberband --enable-lcms2 --prefix=/home/lachs0r/mingw-w64-cmake/buildroot/build64/prefix/mingw
[cplayer] List of enabled features: asm atomics av-avpacket-int64-duration av-new-pixdesc av-pix-fmt-mmal av-subtitle-nopict av-version-info avcodec-chroma-pos-api avcodec-has-codecpar avcodec-profile-name avframe-metadata avframe-skip-samples build-date c11-tls cplayer d3d-hwaccel d3d11va-hwaccel debug-build direct3d dlopen dos-paths dvdnav dvdread dxva2-hwaccel encoding gl gl-dxinterop gl-win32 glob-win32-replacement gpl3 iconv jpeg lcms2 libarchive libass libass-osd libav libavdevice libavfilter libbluray libm libmpv-shared libswresample lua mingw noexecstack optimize posix-or-mingw resampler rubberband sse4-intrinsics static-build stdatomic subprocess tv uchardet wasapi win32 win32-internal-pthreads zlib
[global] config path: '' -> 'C:\Users\Hrxn\AppData\Roaming/mpv'
[global] config path: 'mpv.conf' -> 'C:\Users\Hrxn\AppData\Roaming/mpv/mpv.conf'
[global] config path: 'config' -/-> 'C:\Users\Hrxn\AppData\Roaming/mpv/config'
[global] config path: 'mpv.conf' -/-> 'C:/Apps/mpv/mpv.conf'
[global] config path: 'config' -/-> 'C:/Apps/mpv/config'
[global] config path: 'mpv.conf' -/-> 'C:/Apps/mpv/mpv/mpv.conf'
[global] config path: 'config' -/-> 'C:/Apps/mpv/mpv/config'
[cplayer] Reading config file C:\Users\Hrxn\AppData\Roaming/mpv/mpv.conf
[cplayer] Setting option 'geometry' = '50%:10%' (flags = 4)
[cplayer] Setting option 'no-osc' = '' (flags = 4)
[cplayer] Setting option 'ontop' = '' (flags = 4)
[cplayer] Setting option 'no-ytdl' = '' (flags = 4)
[cplayer] Setting option 'loop-file' = 'inf' (flags = 4)
[cplayer] Setting option 'display-fps' = '120' (flags = 4)
[cplayer] Setting option 'hwdec' = 'no' (flags = 4)
[cplayer] Setting option 'vo' = 'opengl-hq:backend=dxinterop:scale=ewa_lanczossharp:cscale=ewa_lanczossharp:dscale=mitchell:dither-depth=auto:correct-downscaling:sigmoid-upscaling:deband:es=no:icc-profile-auto' (flags = 4)
[cplayer] Setting option 'osd-duration' = '2000' (flags = 4)
[cplayer] Setting option 'osd-font' = 'Consolas' (flags = 4)
[cplayer] Setting option 'osd-font-size' = '32' (flags = 4)
[cplayer] Setting option 'osd-scale' = '1' (flags = 4)
[cplayer] Setting option 'osd-color' = '0.0/1.0/0.0/1.0' (flags = 4)
[cplayer] Setting option 'osd-border-color' = '0.3/0.3/0.3/0.5' (flags = 4)
[cplayer] Setting option 'osd-border-size' = '2' (flags = 4)
[cplayer] Setting option 'osd-margin-x' = '10' (flags = 4)
[cplayer] Setting option 'osd-margin-y' = '10' (flags = 4)
[cplayer] Setting option 'osd-shadow-color' = '0.2/0.2/0.2/0.5' (flags = 4)
[cplayer] Setting option 'osd-shadow-offset' = '2' (flags = 4)
[cplayer] Setting option 'osd-spacing' = '0' (flags = 4)
[cplayer] Setting option 'osd-msg2' = '' (flags = 4)
[cplayer] Setting option 'osd-msg3' = '' (flags = 4)
[cplayer] Setting option 'v' = '' (flags = 8)
[cplayer] mpv 0.17.0-git-190578b (C) 2000-2016 mpv/MPlayer/mplayer2 projects
[cplayer]  built on Mon Apr 11 19:16:14 CEST 2016
[cplayer] ffmpeg library versions:
[cplayer]    libavutil       55.20.100
[cplayer]    libavcodec      57.34.100
[cplayer]    libavformat     57.33.100
[cplayer]    libswscale      4.1.100
[cplayer]    libavfilter     6.41.100
[cplayer]    libswresample   2.0.101
[cplayer] ffmpeg version: N-79342-g95f8a9e
[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]

C:\Users\Hrxn>
maniak1349 commented 8 years ago

Try it with --msg-level=all=status instead of -v.

phydano commented 8 years ago

mpv --msg-level=all=status doesn't do anything for me, it just open the app.

mpv -v give me some output, but it seem to stop after it says 'terminal' =' no' like in my picture (and the app opens).

@Hrxn

if you mark, copy and paste the text between three back-ticks

Sorry >.< I don't quite understand

Did I screw up something?

maniak1349 commented 8 years ago

mpv -v give me some output, but it seem to stop after it says 'terminal' =' no' like in my picture (and the app opens).

Oh, I've missed that. So that's the cause, just add terminal=yes to your user config, it will override the system wide terminal=no. Or just change it in the file it appears in. Or just use it with --terminal=yes in the terminal when you want to check for config errors.

phydano commented 8 years ago

It worked if I put terminal=yes in the config file (yay). But if I type:

mpv -v --terminal=yes it will still say 'terminal' = 'no' again in the terminal (skipping checking the configuration), but this time it doesn't stuck like the picture above. At least it's a progress. Did I write anything wrong? mpv -v --terminal=yes correct?

Also re-post from above: One more question, I use this code to update mpv on my mac to the latest version.

brew rm mpv && brew install --HEAD --with-bundle --with-bluray-support --with-libdvdread --with-little-cms2 --with-lua --with-bundle mpv

If I want to download a specific version (e.g. git-2b4123f), how do I change the --HEAD to that?

maniak1349 commented 8 years ago

Hmm, so it still disables terminal output for the duration of config reading even if there was a terminal=yes with higher priority. It probably should not be that way.

To the matter at hand though - your options are either remove/replace terminal=no line in config (but it's probably there for a reason, so it's probably not a good idea) or just use --log-file=<path-to-file-here> when you want to check for configuration errors.

Can't really help you with compiling/installation on OS X - never used it. Maybe this will be helpfull.

Argon- commented 8 years ago

If I want to download a specific version (e.g. git-2b4123f), how do I change the --HEAD to that?

Type brew edit mpv and go to the line starting with head "https://github.com/mpv-player/mpv.git". Add at the end of the same line: , :revision => "2b4123f07857425d2fd77b7f339f12812eceec29"

P.S. you exit vim with :q

phydano commented 8 years ago

To the matter at hand though - your options are either remove/replace terminal=no line in config (but it's probably there for a reason, so it's probably not a good idea) or just use --log-file= when you want to check for configuration errors.

In my config file, originally there is no terminal specify in the file. Even if I explicitly write terminal=no or not write any. That mpv -v --terminal=yes will not force the terminal to yes (so it doesn't check the configuration). At the current stage, I use your alternative option --log-file and export that as a text file. Unlike terminal, it doesn't show me red text where there is an error...so I have to search for [e] in the log for the error haha. At least I can now check for errors. Thank you so much.

Maybe a simple lua script will be better?

I'm not really familiar with lua script. So I create a file.lua and copy the code in and place it where my configuration file is?

Type brew edit mpv and go to the line starting with head "https://github.com/mpv-player/mpv.git". Add at the end of the same line: , :revision => "2b4123f07857425d2fd77b7f339f12812eceec29"

I can't seem to edit at all. Is there an alternative to the approach? Like pull specific commit through the command line?

maniak1349 commented 8 years ago

So I create a file.lua and copy the code in and place it where my configuration file is?

Yes, but only into the scripts subdirectory as explained here.

Hrxn commented 8 years ago

if you mark, copy and paste the text between three back-ticks

Sorry >.< I don't quite understand Did I screw up something?

Well, no..

It's just a lot easier to copy the output of mpv -v in the Terminal app and then paste it into the comment box here, instead of taking a screenshot.

That part here is a bit strange: 'terminal' = 'no' Where did that come from? This shouldn't be the default, is this something changed by Homebrew?

phydano commented 8 years ago

Yes, but only into the scripts subdirectory as explained here.

Cool thank you. I will read through that. Cheers

That part here is a bit strange: 'terminal' = 'no' Where did that come from? This shouldn't be the default, is this something changed by Homebrew?

I have no idea where that came from. In my config file, I don't write that line of code. I installed MPV by following this guide.

Argon- commented 8 years ago

I can't seem to edit at all.

Well, the default editor is vim. Try HOMEBREW_EDITOR='open -e' brew edit mpv, this will open TextEdit.

phydano commented 8 years ago

Thanks for the help everyone.

Maybe the problem with terminal=no worth the investigate...I'll just leave this case open...

Hmm, so it still disables terminal output for the duration of config reading even if there was a terminal=yes with higher priority. It probably should not be that way.

That part here is a bit strange: 'terminal' = 'no' Where did that come from? This shouldn't be the default, is this something changed by Homebrew?

maniak1349 commented 8 years ago

Maybe the problem with terminal=no worth the investigate...I'll just leave this case open...

You probably should post a pastebin of your /Users/danophy/.config/mpv/mpv.conf file which is responsible for that behavior according to the log to make the issue more obvious.

ghost commented 8 years ago

terminal=no could be caused by pseudo-gui mode.

Akemi commented 7 years ago

i just pushed some related changes to master. so i wonder does it still happen? does it still happen with the most recent version (git master)? if it still happens could you pls provide a log with --log-file?

Akemi commented 7 years ago

i will close this for now since it's not reproducible and not enough information is provided. if it still happens and there is an interested in getting it fixed just drop a message here with the requested info.