Page 1 of 1

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

PostPosted: Wed Sep 19, 2018 10:25 pm
by deadman36g
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

Re: Trying to create a rule to have ffmpeg convert mp4 to mk

PostPosted: Thu Sep 20, 2018 12:36 pm
by Mr_Noodle
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.

Re: Trying to create a rule to have ffmpeg convert mp4 to mk

PostPosted: Thu Sep 20, 2018 1:59 pm
by deadman36g
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

Re: Trying to create a rule to have ffmpeg convert mp4 to mk

PostPosted: Fri Sep 21, 2018 11:03 am
by Mr_Noodle
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.

Re: Trying to create a rule to have ffmpeg convert mp4 to mk

PostPosted: Fri Sep 21, 2018 1:38 pm
by deadman36g
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"