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

21 lines
408 B
Plaintext
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}
ffmpeg -i "concat:$concat_files" -c copy -bsf:a aac_adtstoasc "mp4concat_${RANDOM}.mp4"
for f in "${TMP_FILES[@]}"; do
rm "$f"
done