How to make an Automator service run a shell script and display the output

automatorcommand lineterminal

I'm using Automator to run a shell script (ffmpeg transcode to h264) as a 'Service', so that I can just right click the high res .mov file and select the service. It works fine, but as it's ffmpeg it would be good to see the output in a Terminal window. Is there a way to see the output in real time?

Shouldn't make a difference, but here's the script just in case:

for f in "$@"
do
/usr/local/bin/ffmpeg -i "$f" -c:v libx264 -vf yadif -pix_fmt yuv420p -crf 21 -preset slow -movflags faststart -c:a copy ${f%.*}_h264_yadif.mov
done

Best Answer

This AppleScript will launch a Terminal window with the command you specified:

on run {input, parameters}
    tell application "Terminal"
        activate
        set filesString to ""
        repeat with file_ in input
            set filesString to filesString & " " & quoted form of (POSIX path of file_)
        end repeat
        do script "for f in" & filesString & "; do
/usr/local/bin/ffmpeg -i \"$f\" -c:v libx264 -vf yadif -pix_fmt yuv420p -crf 21 -preset slow -movflags faststart -c:a copy ${f%.*}_h264_yadif.mov
done"
    end tell
    return input
end run

Create a “Run AppleScript” action in Automator and paste it in there.