【发布时间】:2018-02-01 08:19:31
【问题描述】:
我写了一个小的 bash 文件,它读取一个文件夹、生成一个播放列表、连接、添加一个徽标并对大视频结果进行编码以便准备好破折号,我想通过在所有视频一致性之前检查来实现它:如果它们有相同的fps,相同的分辨率,相同的时基等。 下面是我的情况:
#!/bin/bash
# CONCAT DEMUXER
#This demuxer reads a list of #files and other directives from a text file and demuxes them one after the other, as if #all their packets had been muxed together. All files must have the same streams (same #codecs, same time base, etc.) but can be wrapped in different container formats.
times=()
for f in *.mp4; do
_t=$(ffmpeg -i "$f" 2>&1 | grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }')
times+=("$_t")
done
TOTALDURATION=$( echo "${times[@]}" | sed 's/ /+/g' | bc )
printf "file '%s'\n" *.mp4 > playlist.txt
ffmpeg -auto_convert 1 -f concat -safe 0 -i playlist.txt -c:a aac -b:a 384k -ar 48000 -ac 2 -async 1 -c:v libx264 -x264opts 'keyint=50:min-keyint=50:no-scenecut' -r 25 -b:v 2400k -maxrate 2400k -bufsize 1200k -vf "scale=-1:432" -vf "movie=stable.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" -t $TOTALDURATION out.mp4
#clear
echo “VIDEO CONCAT COMPLETED”
例如下面我发现这个 bash 计算文件夹的视频的总持续时间(以秒为单位)
times=()
for f in *.mp4; do
_t=$(ffmpeg -i "$f" 2>&1 | grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }')
times+=("$_t")
done
TOTALDURATION=$( echo "${times[@]}" | sed 's/ /+/g' | bc )
我希望在处理之前检查视频是否具有相同的 fps 和相同的分辨率 谢谢 马西莫
【问题讨论】:
标签: bash video ffmpeg mpeg-dash