0

Hi so I have this ffmpeg command to run in Mac's Automator app:

for f in *.mp4; do ffmpeg -i "$f" -map_metadata -1 -c:v copy -c:a copy "${f%.mp4}"-new.mp4; done

I created a new workflow in automator receives movie files, get folder contents, and then "Run Shell script"

In the shell script window I added the following:

for f in *.mp4; do /usr/local/bin/ffmpeg -i "$f" -map_metadata -1 -c:v copy -c:a copy "${f%.mp4}"-new.mp4; done

But an error message shows up "*.mp4" no such file or directory.

What am I doing wrong here? Please advise. Thanks!

  • I fixed this probem but it's giving another error: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file.mp4': Metadata: major_brand : mp42 minor_version : 512 compatible_brands: mp42 creation_time : 2019-02-09T13:5 – sd100 Feb 11 '19 at 16:55
  • Ok these are ffmpeg output messages. Is there anyway automator can be set to not display these messages? Thanks! – sd100 Feb 11 '19 at 17:28
1

It's hard to say without seeing the whole workflow. The error seems to indicate that the script may be at fault though.

You need to have the shell to /bin/bash, and pass input to "as arguments." Your for line may need to be for f in "$@" or something similar as "$@" should be the passed argument.

  • That should be for f in "$@" to make it operate on all passed files (and the double-quotes are needed in case file paths/names contain spaces). Compare with the original: for f in *.mp4 will try to operate on all .mp4 files in the "current working directory", which by default is your home folder -- probably not what you wanted at all. – Gordon Davisson Feb 11 '19 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.