lisamelton/video_transcoding

Detect Crop Output and zsh

jjathman opened this issue · 6 comments

It looks like the new output from detect-crop outputs commands which need more escaping to work with the zsh shell.

Example:
mpv --no-audio --vf lavfi=[drawbox=0:140:1920:798:invert:1] Hell\ or\ High\ Water.mkv
fails with zsh: no matches found: lavfi=[drawbox=0:140:1920:798:invert:1]

I think the command should actually be:
mpv --no-audio --vf lavfi=\[drawbox=0:140:1920:798:invert:1\] Hell\ or\ High\ Water.mkv
for it to work correctly with zsh. I think this kind of escaping still works with bash as well. I'm not really an expert on shell scripting though so I'm not sure if this is the best solution or not.

@jjathman Thanks for reporting this!

Does it also work if you enclose the argument in single quotes like this?

mpv --no-audio --vf 'lavfi=[drawbox=0:140:1920:798:invert:1]' Hell\ or\ High\ Water.mkv

Yes! That works just fine as well. Not a huge issue, but took me a bit to figure out what was going wrong. Now that I know it's easy to work around.

@jjathman OK, good. I'll still probably come up with a fix in the next day or so. And I'll post the patch here first so you can try it before I release.

@jjathman OK, here's the patch for the fix:

diff --git a/bin/detect-crop b/bin/detect-crop
index efcd76d..892ab8b 100755
--- a/bin/detect-crop
+++ b/bin/detect-crop
@@ -104,7 +104,7 @@ HERE
         puts
 
         if @player == :mpv
-          puts "mpv --no-audio --vf lavfi=[drawbox=#{Crop.drawbox_string(crop, width, height)}:invert:1] #{shell_path}"
+          puts "mpv --no-audio --vf 'lavfi=[drawbox=#{Crop.drawbox_string(crop, width, height)}:invert:1]' #{shell_path}"
           puts "mpv --no-audio --vf crop=#{Crop.player_string(crop, width, height)} #{shell_path}"
         else
           str = Crop.player_string(crop, width, height)

I'll probably check it in shortly and release it today or tomorrow.

Thanks for the speedy assistance as always!

@jjathman OK, the fix is in version 0.17.2. Just gem update video_transcoding and you'll have it.

Thanks again!