2

I have an Automator service which runs a shell script (ffmpeg command).
I'm looking for a way to see the output of the terminal while ffmpeg does it's thing.
Adding echo to the ffmpeg command doesn't work. I read this can be achieved using AppleScript but I wish to stay in bash if possible.
Further more, presenting a progress bar of the transcoding would be just awesome.
This is how my Automator action looks like:
enter image description here

  • The problem might be rather Automator-related (because running ffmpeg directly in the shell produces output). So is there a specific reason why you use Automator (instead of a shell script) in the first place? – nohillside Jul 2 '15 at 14:19
  • Also, can you please add a screenshot of your Automator workflow to the question (use the edit button at the bottom to do so)? – nohillside Jul 2 '15 at 14:20
  • Automator service allows me to right click a media file to start the encoding job. I also prompt the user for a target directory for the encoded file. – o_ren Jul 2 '15 at 14:22
1

To get your shell (bash) script to output to the screen continually so that you can see the progress, you need to launch it from AppleScript. Basically, this is a script that is launching another script. Use the script below to kick of the script that contains your ffmpeg command. You can even pass arguments to your script as you would normally.

For this example, I have a simple bash script that prints out the first command line argument.

#! /bin/bash
# test.sh
echo $1
exit

Next, is the AppleScript code that kicks off the bash script

tell application "Terminal"
   do script "<path>/test.sh 'Hello World'; exit"
   activate
end tell

Note, that if you have any strings with spaces that you need to pass, they MUST be enclosed in single quotes. Double quotes will cause an error in AppleScript.

When you run the script, it will open a Terminal window and anything that gets output will display on the screen.

  • In Console, I don't see any ffmpeg nor bash output. I see "Automator Runner" and "WindowServer"... Also, how would you "output the content of the variable"? View Results action? Maybe Display Notification action? – o_ren Jul 5 '15 at 7:11
  • Oops...I forgot to add the redirect to console. I edited by answer. – Allan Jul 5 '15 at 13:05
  • Your help is much appreciated. But, Console still doesn't show any ffmpeg related output during the run. Do I need to set a trap or something for the process beforehand? Also, your suggestion to set the command as a variable doesn't give me the desired output as it runs after the process has finished, thus not giving me realtime status of the conversion :( – o_ren Jul 5 '15 at 14:56
  • If you redirect the output to a file, just to test, does that work? Just add > test.txt to the end of the ffmpeg file. – Allan Jul 5 '15 at 15:47
  • I didn't relate the "progress bar" to wanting to see the output as real time. I revised my answer - this should display the output as requested. – Allan Jul 5 '15 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .