我想用一张图片创建 5 秒的 mp4 视频。
当我使用以下代码时,视频很流畅。默认方向是放大到左上角。
ffmpeg -loop 1 -i prop1.jpeg -vf "zoompan=z='min(zoom+0.0015,1.5)':d=125" -c:v libx264 -t 5 -s "800x450" fade.mp4
因此,要放大到右上角,我想使用下面的代码
ffmpeg -loop 1 -i prop1.jpeg -vf "zoompan=z='min(zoom+0.0015,1.5)':x='if(gte(zoom,1.5),x,x+1)':y='y':d=125" -c:v libx264 -t 5 -s "800x450" fade.mp4
它正在向正确的方向放大,但视频变得抖动。
转换时也出现一些错误:
[swscaler @ 0x429bda0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x429bac0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x429bac0] Warning: data is not aligned! This can lead to a speedloss
[swscaler @ 0x429bac0] deprecated pixel format used, make sure you did set range correctly
Last message repeated 97 times
[output stream 0:0 @ 0x37af200] 100 buffers queued in output stream 0:0, something may be wrong.
[swscaler @ 0x429bac0] deprecated pixel format used, make sure you did set range correctly
Last message repeated 24 times
[swscaler @ 0x42b7040] deprecated pixel format used, make sure you did set range correctly
Last message repeated 1 times
代码有什么问题?
答案1
在 zoompan 之前使用 upscale:
ffmpeg -loop 1 -i prop1.jpeg -vf "scale=8000:-1,zoompan=z='min(zoom+0.0015,1.5)':x='if(gte(zoom,1.5),x,x+1)':y='y':d=125" -c:v libx264 -t 5 -s "800x450" fade.mp4
正如上面的评论所述:这似乎是一个 ffmpeg 错误:https://trac.ffmpeg.org/ticket/4298
在这里找到了解决方法:ffmpeg:平滑缩放,无抖动