2015年08月30日 ffmpeg and mencoder [長年日記]
_ ffmpeg and mencoder
convert to 2X speed movie with keeping audio pitch
SPEED=2.0 START=00:00:00 ELAPS=00:01:00 INPUT=input.mp4 OUTPUT=output.mp4 ffmpeg -ss ${START} -i "${INPUT}" -t ${ELAPS} -vcodec copy -acodec copy tmp.1.$$.mp4 ffmpeg -i tmp.1.$$.mp4 -y -an -vcodec copy tmp.2.$$.mp4 ffmpeg -i tmp.1.$$.mp4 -y -vn -acodec copy tmp.3.$$.m4a mencoder -speed ${SPEED} -ovc x264 -of lavf -o tmp.4.$$.mp4 tmp.2.$$.mp4 ffmpeg -i tmp.3.$$.m4a -vn -af "atempo=${SPEED}" tmp.5.$$.m4a ffmpeg -i tmp.4.$$.mp4 -i tmp.5.$$.m4a "${OUTPUT}" rm -f tmp.*.$$.*
play 2X speed movie with keeping audio pitch
mplayer -speed 2.0 -af scaletempo input.mp4
convert movie to pictures, edit pictures, convert pictures to movie
mkdir tmp.0.$$.dir mkdir tmp.5.$$.dir START=00:00:00 ELAPS=00:01:00 FRAMESTEP=2 INPUT=input.mp4 OUTPUT=output.mp4 IFPS=`ffmpeg -i "${INPUT}" 2>&1 | egrep fps | sed -e 's/^.* \([0-9\.]*\) fps.*$/\1/'` OFPS=`echo "scale=2;${IFPS}/${FRAMESTEP}" | bc` ffmpeg -ss ${START} -i "${INPUT}" -t ${ELAPS} -vcodec copy -acodec copy tmp.1.$$.mp4 ffmpeg -i tmp.1.$$.mp4 -y -an -vcodec copy tmp.2.$$.mp4 ffmpeg -i tmp.1.$$.mp4 -y -vn -acodec copy tmp.3.$$.m4a mplayer -vo jpeg:outdir=tmp.5.$$.dir -vf "framestep=${FRAMESTEP}" tmp.2.$$.mp4 pushd tmp.5.$$.dir for i in *jpg; do jpegtopnm <$i | pamedge | pnminvert | pnmtojpeg >../tmp.0.$$.dir/$i; done popd mencoder "mf://tmp.0.$$.dir/*.jpg" -mf type=jpg:fps=${OFPS} -ovc x264 -of lavf -o tmp.4.$$.mp4 ffmpeg -i tmp.4.$$.mp4 -i tmp.3.$$.m4a "${OUTPUT}" rm -fr tmp.*.$$.*
[ツッコミを入れる]