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}
|
2024-03-18 19:10:59 +00:00
|
|
|
out_file="mp4concat_${RANDOM}.mp4"
|
2023-11-07 11:35:54 +00:00
|
|
|
|
2024-03-18 19:10:59 +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
|
2024-03-18 19:10:59 +00:00
|
|
|
|
|
|
|
strip-metadata "$out_file"
|