occivink / mpv-scripts

Various scripts for mpv
The Unlicense
420 stars 38 forks source link

lua-settings/ is deprecated, and warning message #14

Closed Dupond closed 6 years ago

Dupond commented 6 years ago

Hello, Thanx for your great scripts ! I've seen in several mpv scripts the indication that lua-settings is deprecated, and that we should use the script-opts directory instead. Furthermore, I find it always disturbing not to know when the encode script has ended : say I launch an encode work, how do I know when it's finished ? I think a warning message would be nice. Also, what happens if the video ends before the encode is finished ? Sorry for my poor english, I hope I'm understandable... Best regards, Dupond

occivink commented 6 years ago

Hi, Thanks for the notice, I didn't realize that lua-settings was deprecated (still on 0.27 over here...).

Furthermore, I find it always disturbing not to know when the encode script has ended

Yes that's one of the limitations of mp.subprocess. You can have a look at this option. Basically if it's set to yes, we can run multiple encoding at the same time, but we don't know when they end or whether they succeed. If it's set to no, then a message is shown to tell you about the outcome, but we can only run one encoding at a time, and mpv will block if you try to exit before the encoding is finished.

Dupond commented 6 years ago

Oh thanx for pointing this option. I had read the config files, but had forgotten this. yes seems a better setting for me, since you can't know how long the encode will take.

occivink commented 6 years ago

Generally it's pretty short, and mostly depends on the length of the clip.

Dupond commented 6 years ago

Pretty short... unless you reencode a full movie ;) Anyway, I haven't tested all your scripts, but at least encode.lua doesn't recognize the config files if they are in a script-opts/ directory.

occivink commented 6 years ago

Ah I see, I usually only generate short extracts. In that case I think it's better to keep detached=yes so that you can close mpv while it's encoding. I also think it might be simpler to just copy/paste the ffmpeg command in a terminal so that you can actually follow the encoding. Also I just tested with a recent build, and the config files in script-opts/ seem to be recognized properly.

Dupond commented 6 years ago

Mmmm... script-opts doesn't work here. Maybe it's due to the custom keybinds ? I have the following in input.conf :

y script-message-to encode set-timestamp reenc
Y script-message-to encode set-timestamp slice

So I have the reenc.conf and slice.conf files in .config/mpv/script-opts. The slice/reencode occurs (no error message), but with the default settings, not the ones defined in the .conf files. Also, I should probably open a new issue, but if the file is a streaming, the reencode fails (with the error message "wrong path"), since I have output_directory= so that the same directory as the input file is used... I think it should use a default directory (the home folder probably) if the directory doesn't exist, instead of simply failing, otherwise letting this option empty is simply not possible.

Dupond commented 6 years ago

I've just seen in your config dotfiles that you use some custom keybinds too... This is strange. So it would be nice if someone else could confirm (or not) that using the script-opts folder doesn't seem to work. Of course it works well for me with the lua-settings folder. The only change I do is moving lua-settings to script-opts. Maybe I'm missing something ?

occivink commented 6 years ago

It's a bit surprising because I'm not doing anything special with the read_options interface so I'm inclined to think there is some setup error somewhere.

Regarding the streaming issue, what kind of URL are you opening, is it through youtube-dl?

Dupond commented 6 years ago

By "setup error", you mean in my configuration files ? They do work perfectly when they are in the lua-settings folder. So, just in case, my .config/mpv/input.conf file is :

- add video-zoom -0.25
= add video-zoom 0.25
* no-osd set video-zoom 0; no-osd set video-pan-x 0; no-osd set video-pan-y 0; cycle-values video-unscaled "yes" "no"
L add video-rotate -90
R add video-rotate 90
Ctrl+b ab-loop
b cycle-values loop-file "inf" "no"
B cycle-values loop "inf" "no"
ENTER ignore
< ignore
> ignore
n playlist-next
p playlist-prev
h add video-pan-x 0.05
j add video-pan-y -0.05
k add video-pan-y 0.05
l add video-pan-x -0.05
P show-text ${playlist} 3000
x ignore
z ignore
Ctrl+D add sub-delay -0.1
Ctrl+d add sub-delay +0.1
r ignore
t ignore
Ctrl+H add sub-pos -1
Ctrl+h add sub-pos +1
Ctrl+T add sub-scale -0.1
Ctrl+t add sub-scale +0.1
c no-osd cycle-values saturation "-100" "0"
# Scripts crop.lua et encode.lua
# Fichier de configuration par défaut :
# https://github.com/occivink/mpv-scripts/blob/master/input.conf
g script-message-to crop start-crop
G vf del -1
y script-message-to encode set-timestamp reenc
Y script-message-to encode set-timestamp slice
# Script mpv_crop_script
Ctrl+Shift+s script-binding crop-screenshot

.config/mpv/script-opts/reenc.conf :

container=mkv
only_active_tracks=no
preserve_filters=yes
append_filter=scale=2*trunc(iw/max(1\,sqrt((iw*ih)/(960*540)))/2):-2
codec=-c:v libx264 -preset slow -c:a aac
output_format=$f_$n
output_directory=
detached=yes
print=yes

.config/mpv/script-opts/slice.conf :

container=mkv
only_active_tracks=no
preserve_filters=no
append_filter=
codec=-vcodec copy -acodec copy
output_format=$f_$n
output_directory=
detached=yes
print=yes

And it doesn't work. If I move them (mv script-opts/ lua-settings), it works just fine...

occivink commented 6 years ago

Which version of mpv are you using?

Dupond commented 6 years ago
$ mpv --version
mpv 0.28.2 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
 built on Mon May 14 09:49:30 CEST 2018
ffmpeg library versions:
   libavutil       56.14.100
   libavcodec      58.18.100
   libavformat     58.12.100
   libswscale      5.1.100
   libavfilter     7.16.100
   libswresample   3.1.100
ffmpeg version: 4.0
occivink commented 6 years ago

Ah then the script-opts changes are not in yet. You can try compiling mpv from git, in which case it should tell you that lua-settings is deprecated.

Dupond commented 6 years ago

But... isn't it the most recent version ? I assumed it is (since I use Arch, and it's often the case). I see no more recent version in the mpv github repo. So, in order to fix my problem without compiling mpv from git, I just have to wait for the next mpv release, is that it ?

occivink commented 6 years ago

Yes it's the most recent version. The script-opts changes are unreleased yet, where did you hear about them?

Dupond commented 6 years ago

In several scripts, including this one (a consol message saying lua-settings/ is deprecated, use directory script-opts/ is displayed each time mpv starts when you use this script). Thanx for your answer. As far as the streaming issue is concerned, reencoding fails for example with the following url : mpv https://www.youtube.com/watch?v=rgsgRVh3rCA (it says "invalid path etc.")

occivink commented 6 years ago

I'm not sure why he decided to print a warning from the script, mpv is already doing that. In any case you should keep using lua-settings until 0.29.

edit: mmh okay, it's because he ended up reimplementing the entire logic for read_options instead of using mpv's. So I guess you should use script-opts for AMM's scripts, and lua-settings for all others until 0.29.

Dupond commented 6 years ago

True. And thanx for the fastest fix ever ;) I'm closing this thread.