1
0
Fork 0
dotfiles/home/programs/scripts/mp4concat

24 lines
457 B
Text
Raw Normal View History

2023-11-07 11:35:54 +00:00
#!/usr/bin/env bash
2023-09-11 22:05:25 +00:00
set -eu
2023-11-07 11:35:54 +00:00
tmpext="_mp4-concat.tmp.ts"
TMP_FILES=()
2023-09-11 22:05:25 +00:00
for f in "$@"; do
2023-11-07 11:35:54 +00:00
TMP_FILES+=("$f$tmpext")
ffmpeg -i "$f" -c copy -bsf:v h264_mp4toannexb -f mpegts "$f$tmpext"
2023-09-11 22:05:25 +00:00
done
2023-11-07 11:35:54 +00:00
concat_files=$(printf "|%s" "${TMP_FILES[@]}")
concat_files=${concat_files:1}
out_file="mp4concat_${RANDOM}.mp4"
2023-11-07 11:35:54 +00:00
ffmpeg -i "concat:$concat_files" -c copy -bsf:a aac_adtstoasc "$out_file"
2023-11-07 11:35:54 +00:00
for f in "${TMP_FILES[@]}"; do
rm "$f"
done
strip-metadata "$out_file"