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

查看:567
本文介绍了使用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天全站免登陆