Skip to content

Instantly share code, notes, and snippets.

@krisives
Created January 1, 2019 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisives/126a9d390a6b2f0dbb753f5d1160285a to your computer and use it in GitHub Desktop.
Save krisives/126a9d390a6b2f0dbb753f5d1160285a to your computer and use it in GitHub Desktop.
Helper script for joining (concatenating) multiple media files together using ffmpeg without using an intermediate text file
#!/usr/bin/env bash
if [ $# -lt 2 ]; then
echo "Usage: ffjoin <joined> <file>..."
exit 1
fi
output=$1
shift
if [ -f "$output" ]; then
echo "Output file '$output' already exists"
exit 1
fi
for path in "$@"; do
if [ ! -f "$path" ]; then
echo "Cannot find file '$path'"
exit 1
fi
done
(
for path in "$@"; do
echo "file '$path'"
done
) | ffmpeg -f concat -protocol_whitelist 'file,pipe' -i - -c copy "$output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment