Trying to create a rule to have ffmpeg convert mp4 to mkv

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I am trying to create a rule that will monitor a folder and if a new file arrives convert it to mkv

In terminal I use
Code: Select all
/usr/local/bin/ffmpeg -i * -codec copy "${i%.*}.mkv"


but using the embedded script option in hazel does not seem to work

the logs states
[Error] Shell script failed: Error processing shell script on file /Users/deadman36g/Movies/Downie/video.mp4.
2018-09-19 21:25:08.206 hazelworker[42035] Shellscript exited with non-successful status code: 1
deadman36g
 
Posts: 8
Joined: Sun Jul 31, 2016 2:08 am

I don't know ffmpeg arguments but if you are using * for the input file, that isn't the correct way to do it. Hazel passes in the first argument as $1 so you should be referring to that.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:I don't know ffmpeg arguments but if you are using * for the input file, that isn't the correct way to do it. Hazel passes in the first argument as $1 so you should be referring to that.


I have now tried

Code: Select all
/usr/local/bin/ffmpeg -i $1 -codec copy "${i%.*}.mkv"


and

Code: Select all
/usr/local/bin/ffmpeg -i "$1" -codec copy "${i%.*}.mkv"


But neither of these work either
deadman36g
 
Posts: 8
Joined: Sun Jul 31, 2016 2:08 am

Have you tried the script outside of Hazel? Does it work there?

Also, turn on debug mode as described here: https://www.noodlesoft.com/kb/hazel-debug-mode/

That will show your script's output in the log which may help.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

After more trial and error I was able to get it to do what I was wanting

Here is the code that worked for me, perhaps someone else may find it useful

Code: Select all
/usr/local/bin/ffmpeg -i "$1" -codec copy -y "${1%.mp4}.mkv"
deadman36g
 
Posts: 8
Joined: Sun Jul 31, 2016 2:08 am


Return to Support