Montag, 7. Mai 2012

Batch Convert Videoclips on Mac OSX CLI using Quicktime

by 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 you can use this as follows:

qt_export --dodialog
A 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 "", which you can now use for encoding:
qt_export IN.AVI OUT.MOV
A simple shellscript which does this job for some 100 files in a certain directory could now look like this:




if [ "$1x" = "x" ]; then

for filename in $PATH/*.AVI
  OUT=`$BASENAME -s .AVI $filename`.MOV
  $TOUCH -t `$STAT -f "%Sm" -t "%Y%m%d%H%M.%S" $IN` $OUT
[EDIT: added re-date for easier handling in iMovie]

comments. 0 tags. ,