PDA

View Full Version : Automator Service - convert with Handbrake - Help?



Tiprya
20th June 2010, 01:26 PM
Hey Guys,
So I'm trying to set up an automator service to convert a movie via HandBrakeCLI so I can just right click and convert a movie.

Problem is my service doesn't work - just doesn't do anything.

I'm a fairly big bash noob so any help would be appreciated. Here's what I have so far:

I've made a service that 'Run Shell Script'
Service receives selected: 'files or folders' in 'any application'
Shell: /bin/bash
Pass input: as arguments



for if in "$@"
do
of="~/Desktop/`basename "$if"`.mp4"
echo "Encoding: $if ---> $of"
/Applications/HandBrakeCLI -i "$if" -o "$of" -e x264 -q 0.589999973773956 -a 1 -E faac -B 128 -R 48 -6 dpl2 -f mp4 -X 480 -m -x cabac=0:ref=2:me=umh:bframes=0:subq=6:8x8dct=0
echo "Encoding Complete."
done


Running 10.6.4

Any help scripting gurus?

Most likely my script is just wrong but I'm not sure where?

Tiprya
20th June 2010, 02:30 PM
Solution found:

Third line should be:

of=~/Desktop/`basename "$if" .avi`.mp4

Always a simple error...

I'll probably write this all up as a tutorial as I figure others would find this useful.

n2glox
22nd June 2010, 01:36 PM
I am using a similar script and it is not working.


for if in "$@"
do
of=~/Desktop/Converted/`basename "$if"`.mp4

echo "Encoding started: $if ---> $of"

~/Handbrake_CLI/HandBrakeCLI -v -z "iPhone & iPod Touch" -i "$if" -o "$of"

echo "Encoding Finished."

done 2>&1 | tr '\r' '\n' > /Users/jeffkline/Desktop/Converted/video.txt


All I get is the video.txt file. How can I tell if the handbrake CLI is even working?

BTW my files are AVI files.

Thanks for any help

n2glox
23rd June 2010, 11:28 AM
Ok, I modified the Script, and this one works like a charm on AVI files. I am going to create other versions of this for straight conversion (keeping same size), and one for iPad.


for if in "$@"
do
of=~/Desktop/Converted/`basename "$if"`.mp4

echo "Encoding started: $if ---> $of"

~/Handbrake_CLI/HandBrakeCLI -i "$if" -o "$of" --preset="iPhone & iPod Touch"

echo "Encoding Finished."

done 2>&1 | tr '\r' '\n' > /Users/username/Desktop/Converted/video.txt

Thanks for the tips.

Jeff

gtrusler
29th June 2010, 03:06 AM
Nice script. Thanks.

Any idea how to strip the extension off of the original filename so that you don't end up with filename.mp4.mp4?

Thanks,
Graydon