我想從 1 張圖像創建 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:平滑縮放,無抖動