FFMPEG(libx264)“高度不能被2整除” [英] FFMPEG (libx264) "height not divisible by 2"
问题描述
这是我正在运行的命令:
我正在尝试使用FFMPEG使用libx264编解码器从一组帧编码一个.mp4视频。 > / usr / local / bin / ffmpeg -r 24 -i frame_%05d.jpg -vcodec libx264 -y -an video.mp4
我有时会收到以下错误:
[libx264 @ 0xa3b85a0]高度不能被2整除(520x369)
在搜索一下之后,似乎问题与缩放算法有关,可以通过添加-vf参数来修复。
然而,在我的情况下,我不想做任何缩放。理想情况下,我想保持与框架完全相同的尺寸。任何建议?有没有h264执行的某种长宽比?
在玩了一下之后,我想我已经回答我自己的问题以下是解决方案,以防其他任何人遇到类似的问题...我不得不在命令中添加以下参数:
-vfscale = trunc(iw / 2)* 2:trunc(ih / 2)* 2
命令:
ffmpeg -r 24 -i frame_%05d.jpg -vcodec libx264 -y -an video.mp4 -vfscale = trunc(iw / 2)* 2:trunc(ih / 2)* 2
基本上,.h264需要均匀尺寸,所以这个过滤器将:
- 将原始高度和宽度除以2
- 将其舍入到最接近的像素
- 再次乘以2,从而使其成为偶数
I am trying to encode a .mp4 video from a set of frames using FFMPEG using the libx264 codec.
This is the command I am running:
/usr/local/bin/ffmpeg -r 24 -i frame_%05d.jpg -vcodec libx264 -y -an video.mp4
I sometimes get the following error:
[libx264 @ 0xa3b85a0] height not divisible by 2 (520x369)
After searching around a bit it seems that the issue has something to do with the scaling algorithm and can be fixed by adding a -vf argument.
However, in my case I don't want to do any scaling. Ideally, I want to keep the dimensions exactly the same as the frames. Any advice? Is there some sort of aspect ratio that h264 enforces?
After playing around with this a bit, I think I've answered my own question. Here is the solution in case anyone else runs into a similar issue... I had to add the below argument to the command:
-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"
Command:
ffmpeg -r 24 -i frame_%05d.jpg -vcodec libx264 -y -an video.mp4 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"
Basically, .h264 needs even dimensions so this filter will:
- Divide the original height and width by 2
- Round it down to the nearest pixel
- Multiply it by 2 again, thus making it an even number
这篇关于FFMPEG(libx264)“高度不能被2整除”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!