ffmpeg speed up a .mp4 video
- User
ffmpeg speed up a .mp4 video
- Assistant
To speed up a
.mp4video usingffmpeg, you can use thesetptsfilter for the video stream and theatempofilter for the audio stream (if the video has audio).Basic command to speed up video by 2x:
bashffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4Explanation:
setpts=0.5*PTS: speeds up the video by 2x (PTS = presentation timestamp).0.5means the video plays twice as fast.
- User
Only video feed. The video should not have audio
- Assistant
If you want to speed up only the video and completely remove the audio, you can do this with a simple command that applies the
setptsfilter to the video stream and disables audio with-an.Example: Speed up video by 2x, no audio
bashffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -an output.mp4Explanation:
-filter:v "setpts=0.5*PTS"speeds up video by 2x.-andisables audio (removes audio stream).
If you want a different speed-up factor, replace
0.5with1/(speed).For example, to speed up by 3x:
bashffmpeg -i input.mp4 -filter:v "setpts=0.3333*PTS" -an output.mp4Let me know if you'd like to speed it up by a different factor!
- User
How to scale the video down to x540 ?
- Assistant
To scale the video height to 540 pixels while maintaining the aspect ratio, you can use the
scalefilter with-1as the width to auto-calculate width preserving the aspect ratio.Example: scale video height to 540 pixels (width auto-calculated), speed up 2x, no audio:
bashffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS, scale=-1:540" -an output.mp4Explanation:
setpts=0.5*PTS: speeds up the video 2x.scale=-1:540: scales height to 540 pixels and sets width to preserve aspect ratio (-1means auto).-an: remove audio.
If you want to scale by width instead (say scale width to 960), you can do:
bash-filter:v "setpts=0.5*PTS, scale=960:-1"
Let me know if you want a different scaling or speed!