Monday, February 14, 2011

iPhone/iPod Touch video encoding by Mac OS

Have you ever had an idea to upload your video to iPhone/iPod Touch from your system in native iPhone/iPod Touch format? If yes, this article is for you.
In Mac OS SL system there is a QuickTime X player which can convert video to some formats. Just load it and Save as iPhone/iPod format or even AppleTV, or share it with iTunes and YouTube. But there is a problem - the QuickTime X player should accept the format you plan to convert. If not you have to use third party software. I always search the free solution at begin and as CLI geek prefer the CLI based UNIX software. HandBrake is a good remedy for such 'QuickTime unsupported' formats. Lets have a look.
First of all lets download HandBrakeCLI from HERE and install it. Depends on your Mac OS version chose 32bit or 64bit Intel version. Drop the HandBrakeCLI somewhere to /usr/local/bin/ (Password may be necessary). Open the Terminal and check if it works.
As the next step lets make the Automator Service based on AppleScript to control the encoding process from Terminal. I won't explain the step by step workflow for it. Just give the AppleScript code inside Automator. This code is not a 'state of art', but hopefully works for me. Some code improvements will be published here in UPDATEs section.
When you create this script, you will be able to fire up video encoding by Finder right mouse click on video file with Services menu choice. Good luck.
(* Transcode video to iPod Touch/iPhone format *)
# Author is DimiG

on run {input, parameters}
set aString to "nice HandBrakeCLI -Z \"Apple iPhone & iPod Touch\" -i " & the quoted form of the POSIX path of input & " -o output.mp4"
set aPath to (quoted form of POSIX path of (input as string))

tell application "Terminal"
activate
if (the (count of the window) = 0) or (the busy of window 1 = true) then
do script "cd " & "\"$(dirname " & aPath & ")\""
else
do script "cd " & "\"$(dirname " & aPath & ")\"" in window 1
end if

do script aString in front window

end tell

return input
end run
That is how it looks like inside Automator:

No comments: