使用 ffmpeg 编码高质量视频 [英] Using ffmpeg to encode a high quality video

查看:104
本文介绍了使用 ffmpeg 编码高质量视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在目录中保存了一组作为图像的视频帧,我正在尝试将它们编码为高质量的视频,但是我尝试的每种设置和每种格式都会产生非常明显的伪影.

I have a set of video frames saved as images in a directory, and I'm trying to encode these to a good quality video, however every setting and every format I try produces very noticeable artifacts.

基本命令是这样的:

ffmpeg -r 25 -i %4d.png myvideo.mpg

我已经尝试了 minrate 和 maxrate 标志.任何 {mpg、avi、mov、flv} 格式都可以.

and I've tried the minrate and maxrate flags. Any of {mpg, avi, mov, flv} formats will do.

对设置有什么建议吗?最终文件大小不是问题.

Any suggestions for settings? Final file size is not an issue.

推荐答案

一些事情:

  • 您需要设置视频比特率.我从未使用过 minrate 和 maxrate,所以我不知道它们究竟是如何工作的,但是通过使用 -b 开关设置比特率,我可以获得高质量的视频.您需要提出一个比特率,在压缩和视频质量之间提供良好的权衡.您可能必须对此进行试验,因为这完全取决于视频内容中的帧大小、帧速率和运动量.请记住,对于 720x480,DVD 的平均速度往往在 4-5 Mbit/s 左右,所以我通常从那里开始,决定是否需要更多或更少,然后进行试验.例如,您可以在命令行中添加 -b 5000k 以获得更多或更少的 DVD 视频比特率.

  • You need to set the video bitrate. I have never used minrate and maxrate so I don't know how exactly they work, but by setting the bitrate using the -b switch, I am able to get high quality video. You need to come up with a bitrate that offers a good tradeoff between compression and video quality. You may have to experiment with this because it all depends on the frame size, frame rate and the amount of motion in the content of your video. Keep in mind that DVD tends to be around 4-5 Mbit/s on average for 720x480, so I usually start from there and decide whether I need more or less and then just experiment. For example, you could add -b 5000k to the command line to get more or less DVD video bitrate.

您需要指定视频编解码器.如果你不这样做,ffmpeg 将默认为 MPEG-1,它已经很老了,并且不能提供接近 MPEG-4 或 H.264 的压缩量.如果您的 ffmpeg 版本支持 libx264,您可以指定 -vcodec libx264 作为命令行的一部分.否则 -vcodec mpeg4 也会比 MPEG-1 做得更好,但不如 x264.

You need to specify a video codec. If you don't, ffmpeg will default to MPEG-1 which is quite old and does not provide near the amount of compression as MPEG-4 or H.264. If your ffmpeg version is built with libx264 support, you can specify -vcodec libx264 as part of the command line. Otherwise -vcodec mpeg4 will also do a better job than MPEG-1, but not as well as x264.

还有许多其他高级选项可以帮助您以最低比特率获得最佳质量.看看这里的一些例子.

There are a lot of other advanced options that will help you squeeze out the best quality at the lowest bitrates. Take a look here for some examples.

这篇关于使用 ffmpeg 编码高质量视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆