Skip to content

Instantly share code, notes, and snippets.

@CrashLaker
Last active April 30, 2018 15:52
Show Gist options
  • Save CrashLaker/2a38b6f5e7d1fff215b97f4a6c1410d0 to your computer and use it in GitHub Desktop.
Save CrashLaker/2a38b6f5e7d1fff215b97f4a6c1410d0 to your computer and use it in GitHub Desktop.
Merge mp4 video files using bash + ffmpeg
#!/bin/bash
# $1 = filename
rm -f ${1}.mp4
a=1;for file in `ls ${1}*.mp4`; do ffmpeg -i $file -c copy -bsf:v h264_mp4toannexb -f mpegts tmpfile${a}.ts; a=$((a+1)); done
ffmpeg -i "concat:`ls tmpfile*.ts | paste -s -d\"|\"`" -c copy -bsf:a aac_adtstoasc ${1}.mp4
rm -f tmpfile*.ts
rm -f ${1}?.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment