[Bash shell] 纯文本查看 复制代码
video_dir="mp4"
count_source=0
count_merge=0
fname=""
for i in $(ls $video_dir|sort -n);do
let count_source+=1
if [ $(( count_source % 3)) -eq 0 ];then
let count_merge+=1
fname="$fname -i $i"
echo ffmpeg -f concat -safe 0 $fname -c copy merged_video_${count_merge}.mp4
fname=""
else
fname="$fname -i $i"
fi
done
for i in merged_video_*.mp4; do
ffmpeg -i "$i" -t 00:45:00 -c copy "${i%.*}_part1.mp4"
ffmpeg -i "$i" -ss 00:45:00 -t 00:45:00 -c copy "${i%.*}_part2.mp4"
ffmpeg -i "$i" -ss 00:90:00 -t 00:45:00 -c copy "${i%.*}_part3.mp4"
ffmpeg -i "$i" -ss 00:135:00 -c copy "${i%.*}_part4.mp4"
done |