1

I have this bash script that works perfectly on terminal

#!/bin/bash

for f in "$@"; do

  DIRNAME="$(dirname "$f")"

  filename=$(basename "$f")
  name="${filename%.*}"
  extension="${filename##*.}"

  /usr/local/bin/ffmpeg -i "$f" -filter_complex 'scale=1920:1080, pad=2134:1200:107:60' "$DIRNAME"/OUTPUT_"$name"."$extension"
  /usr/local/bin/ffmpeg -i OUTPUT_"$name"."$extension" -vf 'scale=1920:1080' FINAL_"$name"."$extension"

 done

I am trying to create a service for finder that accept movie files and process them using this script. The service is setup to pass input to stdin. When I select movies on finder and run that service, nothing happens. Like I said, the script works perfectly from terminal.

enter image description here

Any clues?


This question appears to similar to ffmpeg working from command line in Terminal but not in an Automator shell script! but applying the answer (full path to ffmpeg) did not solve my problem.

1

In addition to specifying the full path to ffmpeg two additional problems needed to be solved:

  1. The path to the output files are also needed.

  2. The pass input option of the shell script action has to be set as arguments.

enter image description here

The final script is then this:

#!/bin/bash

for f in "$@"; do

  DIRNAME="$(dirname "$f")"

  filename=$(basename "$f")
  name="${filename%.*}"
  extension="${filename##*.}"

  /usr/local/bin/ffmpeg -i "$f" -filter_complex 'scale=1920:1080, pad=2134:1200:107:60' "$DIRNAME"/OUTPUT_"$name"."$extension"
  /usr/local/bin/ffmpeg -i "$DIRNAME"/OUTPUT_"$name"."$extension" -vf 'scale=1920:1080' "$DIRNAME"/FINAL_"$name"."$extension"


done

Notice how the path was added to ffmpeg and also that $DIRNAME was added to the output files, that was not mentioned by the other question.

You must log in to answer this question.

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