occivink / mpv-scripts

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

[encode] Doesn't seem to work but produces a valid command #39

Open UserNaem opened 4 years ago

UserNaem commented 4 years ago

I had to edit encode.lua to make it work at all (issue #38), but this issue looks like it shouldn't exist. I'm trying to use multiple complex filter graphs, and it fails, but the command that is (supposedly) used is valid and works if I copy-paste it to a regular console window.

My config file: https://pastebin.com/PV11Fpts

[vo/gpu/d3d11] shaderc: 1978us, SPIRV-Cross: 151us, D3DCompile: 1749us
[statusline] AV: 00:00:01 / 00:00:05 (23%) A-V:  0.000
[encode] Opened config file script-opts/encode_gif.conf.
[encode] ffmpeg -ss 00:00.701 -i "C:\Users\Ten\Desktop\mpv\ff.mkv" -to 0.5423416661745 -map 0 -sn -an -f gif -filter_complex "[0:v] fps=1,scale=2*trunc(iw/max(1\,sqrt((iw*ih)/(640*360)))/2):-2,split [a][b];[a] palettegen [p];[b][p] paletteuse" "C:\Users\Ten\Desktop\mpv\ff_2.gif"
[statusline] AV: 00:00:02 / 00:00:05 (38%) A-V:  0.000
[cplayer] Set property: pause -> 1
[statusline] (Paused) AV: 00:00:02 / 00:00:05 (38%) A-V:  0.000
occivink commented 4 years ago

I had to edit encode.lua to make it work at all

The quoting should only be a problem if you copy-paste the command, the line is only being printed for informative purposes. Let me see

occivink commented 4 years ago

Mh yes I think the problem is that the codec option is quite basic and the value is being split on whitespace, so your filter_complex ends up malformed. I need to think of a way to make this more robust

AeliusSaionji commented 3 years ago

I don't actually know lua, and thus don't know why this doesn't work. It again produces a valid command- but nothing happens.

I figured it's probably worthwhile to just explicitly have a filter complex setting.

--- encode.lua  2020-09-10 13:50:55.429526500 -0400
+++ AppData/Roaming/mpv/scripts/encode.lua      2020-09-10 13:49:05.761400800 -0400
@@ -179,6 +179,12 @@
     if #filters > 0 then
         append_args({ "-filter:v", table.concat(filters, ",") })
     end
+    -- attempt to add filter complex
+    local filterc = {}
+    if settings.append_filter_complex ~= "" then
+        filterc = settings.append_filter_complex
+        append_args({ "-filter_complex", filterc })
+    end

     -- split the user-passed settings on whitespace
     for token in string.gmatch(settings.codec, "[^%s]+") do
@@ -291,6 +297,7 @@
             only_active_tracks = false,
             preserve_filters = true,
             append_filter = "",
+            append_filter_complex = "",
             codec = "-an -sn -c:v libvpx -crf 10 -b:v 1000k",
             output_format = "$f_$n.webm",
             output_directory = "",