Eu uso o MP4Box como base de trabalho.
O script que eu sugiro lê todos os arquivos, um por um, verificando cada um (o tempo é um arquivo comum), pede ao usuário o nome do arquivo de entrada para criar.
#!/bin/bash
printf "### Concatenate Media files ###\n"
fInputCount=0
# Reading input files
IFS=''
while (true)
do
let currentNumber=$fInputCount+1
printf "File n°%s (\"ok\" to finish): " $currentNumber
read inputFile
[ "$inputFile" == "ok" ] && break
[ ! -e "$inputFile" ] || [ ! -f "$inputFile" ] && printf "\"%s\" : Invalid filename. Skipped !\n" "$inputFile" && continue
((fInputCount++))
inputFileList[$fInputCount]=$inputFile
printf "\"%s\" : Added to queue !\n" "$inputFile"
done
[ "$fInputCount" == "0" ] || [ "$fInputCount" == "1" ] && echo "No enough input data. BYE ! " && exit
# Listing the input file list
for ((i=1;i<=$fInputCount;i++))
do
printf "%2d : %s\n" $i ${inputFileList[$i]}
done
# Reading the output filename
while (true)
do
printf "Output file without extention (\"none\" to dismiss) : "
read outputRead
[ "$outputRead" == "none" ] && echo "Dismissed. BYE ! " && exit
[ "$outputRead" == "" ] && echo "Try again ! " && continue
[ -e "$outputRead" ] && echo "\"$outputRead\" exists. Try again !" && continue
outputFile=$outputRead.mp4
echo "Output to \"$outputFile\". Go !" && break
done
# Creating a random temporary filename
tmpOutFile="/tmp/concatMedia"'date +"%s%N"| sha1sum | awk '{print $1}''".mp4"
# Joining the two first input files
MP4Box -cat "${inputFileList[1]}" -cat "${inputFileList[2]}" $tmpOutFile
# Adding all other files
for ((i=3;i<=$fInputCount;i++))
do
tmpIntermediateFile=$tmpOutFile
tmpOutFile="/tmp/concatMedia"'date +"%s%N"| sha1sum | awk '{print $1}''".mp4"
MP4Box -cat $tmpIntermediateFile -cat "${inputFileList[$i]}" $tmpOutFile
rm $tmpIntermediateFile
done
mv $tmpOutFile "$outputFile"
# Finished
echo "\"$outputFile\" Saved !"