ffmpeg视频压缩速度
I watch a lot of sports and recently I've become fascinated with some of the methodologies they use to illustrate events within the game. I don't have their advanced TV software or hardware, of course, but I do have a love for ffmpeg, which allows me to do everything from to change , , and more.
我看了很多体育比赛,最近我对他们用来说明比赛中事件的一些方法很着迷。 我当然没有他们先进的电视软件或硬件,但是我确实喜欢ffmpeg,这使我能够做所有事情,从到更改 , ,以及更多。
One of my favorite TV sports illustration techniques is speeding video up (time-lapse) or slowing it way down (slo-mo replay); naturally I wanted to know how to manipulate video speed with ffmpeg. It turns out all you need to do is pass in filter with a PTS () value:
我最喜欢的电视体育插画技术之一是提高视频播放速度(延时)或降低视频播放速度(慢动作回放)。 自然,我想知道如何使用ffmpeg操纵视频速度。 事实证明,您需要做的只是传递带有PTS( )值的过滤器:
更快的视频速度 (Faster Video Speed)
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" output.mp4
较慢的视频速度 (Slower Video Speed)
ffmpeg -i input.mp4 -filter:v "setpts=2*PTS" output.mp4
The lower the PTS
value, the faster the time-lapse video is generated. If you use a larger value, the video will display in slower motion.
PTS
值越低,延时视频生成越快。 如果使用较大的值,视频将以慢动作显示。
调整视频和音频 (Adjust video and audio)
If you care to sync the audio speed with the video speed, things get a bit more complicated:
如果您想将音频速度与视频速度同步,事情会变得更加复杂:
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4
More confusing is that the atempo
setting seems to require reverse logic to setpts
; i.e. doubling speed seems to require a different multiple.
更令人困惑的是, atempo
设置似乎需要对setpts
进行逆向逻辑; 即倍增速度似乎需要不同的倍数。
I recently used this slow-mo technique on a highlights video downloaded from YouTube to draw my own conclusions about a specific play. The ability to manipulate video so easily, without a UI, also makes for easy automation of media, especially when you combine this technique with -- you get just the frames you want at the speed you want. ffmpeg FTW!
最近,我在从YouTube下载的精彩视频中使用了这种慢动作技术,得出了自己对特定游戏的结论。 在没有UI的情况下如此轻松地操作视频的能力也使媒体的自动化变得容易,尤其是当您将此技术与结合使用时-您可以以所需的速度获得所需的帧。 ffmpeg FTW!
翻译自:
ffmpeg视频压缩速度