Skip to content

Instantly share code, notes, and snippets.

@zackad
Last active August 23, 2022 00:46
Show Gist options
  • Save zackad/b009e3642426ba8789450bd8de2f5f74 to your computer and use it in GitHub Desktop.
Save zackad/b009e3642426ba8789450bd8de2f5f74 to your computer and use it in GitHub Desktop.
Concat video file by directory
#!/usr/bin/env sh
# Usage: ffmpeg-concat your-output-prefix output-directory
#
# Note: make sure that output directory is exists and writeable
#
# TODO: add output directory option
# TODO: add filename prefix
prefix=$1
output_directory=$2
# Get avalaible directory
for dir in $(ls -D);
do for file in $(ls $dir);
# Generate temporary file list
do echo "file '$dir/$file'" >> list.txt;
done;
ffmpeg -f concat -safe 0 -i list.txt -c copy -y "$output_directory/${prefix}_${PWD##*/}_$dir.mp4";
# Remove temporary file list
rm list.txt;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment