Video speed adjustment (ffmpeg)

As we all know, a video is composed of a set of pictures and a piece of audio. If the video speed is adjusted, the picture speed can be adjusted by adjusting the picture. Of course, the audio must be adjusted while adjusting the picture, otherwise the picture and sound will not match , Isn't it laughable and generous.

Video speed

Double speed

ffmpeg -i test.mp4 -filter:v "setpts=0.5*PTS" test-0.5.mp4

The video speed adjustment depends on the value of the setpts video filter, the supported range is 0.25-4 , the larger the value, the faster the speed, double speed is 0.5, quadruple speed is 0.25, and so on

Audio double speed

Double speed

ffmpeg -i test.mp4 -filter:a  "atempo=2.0" -vn test-2.mp4

Since atempo only supports values ​​from 0.5 to 2.0, if you want to adjust to only four times the speed, you can fill in two sets of atempo

ffmpeg -i test.mp4 -filter:a  "atempo=2.0,atempo=2.0" -vn test-2.mp4

Simultaneous adjustment of video and audio

ffmpeg -i test.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" test-2.mp4

Guess you like

Origin blog.csdn.net/qq_38306425/article/details/102647937