Batch Convert Videoclips on Mac OSX CLI using Quicktime
by Losty on Montag, 7. Mai 2012 20:51
While compressing the videos of my Pentax K-5 I searched for some scriptable solution because I have some 100 files lying around. Unfortunately the - via Google commonly advised - Handbreak-(GUI-) Solution uses ffmpeg to decode input sound, which puts you strange thump sounds to the output (even when set to "pass-thru"). I don't know who to blame, but this problem is also described in a post at pentaxforums.
I also tried DV Kitchen (another GUI-Solution) which had thump-free sound output but keept crashing randomly.
While working on a Cocoa- (meaning "programming-") solution (the first steps are actually pretty easy with Quick Time Framework "QTKit". Google for "qtmovie". The method "writeToFile:withAttributes" lets you specify QTMovieExportSettings, but this will only work with predefined export settings e.g. for playback on iPhone, iPad and some more. No custom encoding settings) I came across these handy qt_tools (the .dmg comes including C sources *nice*). IHMO their authors definitely have a SEO problem with their site ;-).
After installing (which actually means that you just have to find a way to get the bin/qt_export shellskript or the binary inside qt_tools.app) you can use this as follows:
qt_export --dodialog --savesettings=myExportSettings.stA dialog will pop up with a lot of encoding configuration detail settings. Select your desired output codec and encoding settings and klick "OK". Your decision will be saved to the specified "myExportSettings.st", which you can now use for encoding:
qt_export IN.AVI OUT.MOV --loadsettings=myExportSettings.stA simple shellscript which does this job for some 100 files in a certain directory could now look like this:
#!/bin/bash QT_EXPORT="/Applications/qt_tools.app/Contents/MacOS/qt_export" EXPORTSETTINGS="myExportSettings.st" BASENAME="/usr/bin/basename" TOUCH="/usr/bin/touch" STAT="/usr/bin/stat" if [ "$1x" = "x" ]; then PATH="." else PATH=$1 fi for filename in $PATH/*.AVI do IN=$filename OUT=`$BASENAME -s .AVI $filename`.MOV $QT_EXPORT $IN $OUT --loadsettings=$EXPORTSETTINGS $TOUCH -t `$STAT -f "%Sm" -t "%Y%m%d%H%M.%S" $IN` $OUT done;[EDIT: added re-date for easier handling in iMovie]
comments. 0