Skip to content

Instantly share code, notes, and snippets.

@2b3pro
Last active May 12, 2021 21:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2b3pro/39f473bc663fe49ce04530aded73cf0d to your computer and use it in GitHub Desktop.
Save 2b3pro/39f473bc663fe49ce04530aded73cf0d to your computer and use it in GitHub Desktop.
[Automator] Quick Action to Concatenate Videos in a Folder for YT-ready Upload

Q: How do I combine individual video clips into one movie file for upload to YouTube using ffmpeg?

The following assumes you have ffmpeg installed on your Mac. If you need to install it, please use Homebrew.

The settings for encoding for YouTube with ffmpeg can be found here and here.

There is no error checking here. It assumes that there are videos in the folder, and that they have mp4 extensions.


Automator Steps

  1. In Automator, start by creating a Quick Action to accept FOLDERS in FINDER.
  2. Set Value of a Variable to Path

Screenshot 2019-10-25 17 05 10

  1. Ask for Confirmation to confirm the path being used. (Ignore the mention of the Leader video. This was a later modification.)

Screenshot 2019-10-25 17 05 19

  1. Run Shell Script. The following is the /bin/bash script, passing input as arguments

Screenshot 2019-10-25 17 05 39

cd "$1"

for f in ./*.mp4; do echo "file '$f'" >> videos2bmerged.txt; done

file_name=Merged-FINAL.mp4
current_time=$(date "+%Y%m%d-%H%M")
final_filename=$current_time.$file_name

/usr/local/bin/ffmpeg -f concat -safe 0 -i videos2bmerged.txt -c:v libx264 -preset slow -profile:v high -crf 18 -coder 1 -pix_fmt yuv420p -movflags +faststart -g 30 -bf 2 -c:a aac -b:a 384k -profile:a aac_low "tmpVideo-PROCESSING.mp4"

rm videos2bmerged.txt

mv "tmpVideo-PROCESSING.mp4" "$final_filename"
  1. Display Notification Indicate that the processing is complete.

Screenshot 2019-10-25 17 05 33

#automator #ffmpeg #videos #concat #youtube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment