mp4concat: improve script
This commit is contained in:
parent
69c7cea7aa
commit
3e4d7c198c
1 changed files with 13 additions and 6 deletions
|
@ -1,13 +1,20 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
tmpfile="_mp4-concat.tmp"
|
tmpext="_mp4-concat.tmp.ts"
|
||||||
printf '' >"$tmpfile"
|
TMP_FILES=()
|
||||||
|
|
||||||
for f in "$@"; do
|
for f in "$@"; do
|
||||||
echo "file '$f'" >>"$tmpfile"
|
TMP_FILES+=("$f$tmpext")
|
||||||
|
ffmpeg -i "$f" -c copy -bsf:v h264_mp4toannexb -f mpegts "$f$tmpext"
|
||||||
done
|
done
|
||||||
|
|
||||||
ffmpeg -f concat -safe 0 -i "$tmpfile" -c copy mp4concat_output.mp4
|
concat_files=$(printf "|%s" "${TMP_FILES[@]}")
|
||||||
rm -f "$tmpfile"
|
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
|
||||||
|
|
Loading…
Reference in a new issue