Created
November 11, 2010 12:36
-
-
Save borgand/672422 to your computer and use it in GitHub Desktop.
Part of AutomatorFFmpeg.action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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