Skip to content

Instantly share code, notes, and snippets.

@borgand
Created November 11, 2010 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borgand/672422 to your computer and use it in GitHub Desktop.
Save borgand/672422 to your computer and use it in GitHub Desktop.
Part of AutomatorFFmpeg.action
#!/usr/bin/env sh
# main.command
# AutomatorFFmpeg
# Created by Laas Toom on 17.03.10.
# Copyright (c) 2010 Laas Toom, All Rights Reserved.
mypath=$(dirname $0)
if [[ -z "$ffmpeg_bin" ]]; then ffmpeg_bin=$(which ffmpeg); fi
if [[ -z "$growl" ]]; then growl=$(which growlnotify); fi
if [[ -z "$vcodec" ]]; then vcodec="copy"; fi
if [[ -z "$acodec" ]]; then acodec="copy"; fi
if [[ -z "$ofmt" ]]; then ofmt="mov"; fi
if [[ -z "$output_dir" ]]; then output_dir=~/Desktop; fi
while read movie
do
if [[ -f "$movie" ]]
then
(
base=$(basename "$movie")
base="${base%.*}"
ofile="$output_dir/$base".$ofmt
$growl -H localhost --image "$mypath/ffmpeg.png" -s -d "$base" -m "AutomatorFFmpeg: Transcoding: $movie to $ofmt ..."
ls -la "$movie"
# somehow ffmpeg steals the input of this shell and so we have to fake input to ffmpeg
echo "" | $ffmpeg_bin -i "$movie" -vcodec $vcodec -acodec $acodec "$ofile"
# Touch the new file to preserve dates
touch -r "$movie" "$ofile"
test -f $growl && $growl -H localhost --image "$mypath/ffmpeg.png" -d "$base" -m "AutomatorFFmpeg: Transcoding: $movie ... Done"
echo "$ofile"
) > /dev/null 2>&1
fi
done
test -f $growl && $growl -H localhost --image "$mypath/ffmpeg.png" -m "AutomatorFFmpeg: All Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment