将MKV转换为H264 FFmpeg [英] Converting mkv to h264 FFmpeg

查看:118
本文介绍了将MKV转换为H264 FFmpeg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:这个问题已经变得非常流行,并且是搜索将mkv转换为h264 ffmpeg"的最佳结果之一.因此,我觉得应该添加这个选项,以便对这个问题绊脚石的任何人都可以使用

EDIT: This question has become very popular and is one of the top results for searching "convert mkv to h264 ffmpeg" and thus I feel it is appropriate to add that for anyone stumbling upon this question to rather use

ffmpeg -i input.mkv -c:v libx264 -c:a aac output.mp4

as libvo_aacenc 在最新版本的FFmpeg中已被删除,它现在具有本机aac编码器.有关更多信息,请访问 FFmpeg Wiki页面以对AAC进行编码.

as libvo_aacenc has been removed in recent versions of FFmpeg and it now has a native aac encoder. For more information visit the FFmpeg wiki page for encoding AAC.

这是原始问题:

我想使用FFmpeg将.mkv文件转换为.mp4.我尝试了以下代码:

I would like to convert my .mkv files to .mp4 using FFmpeg. I have tried the following code:

ffmpeg -i input.mkv -c:v libx264 -c:a libvo_aacenc output.mp4

但是我得到了错误:

打开输出流#0:1的编码器时出错-可能是不正确的参数,例如bit_rate,rate,width或height.

Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height.

有什么办法可以解决这个问题?我尝试设置音频的比特率,但问题似乎仍然存在.

Is there any way to get around this? I have tried setting the bitrate of the audio but the problem seems to persist.

推荐答案

我建议您首先检查.mkv文件是否首先已经具有H.264/AAC流.因为这样做,您要做的就是复制流并更改容器:

I suggest you first check whether your .mkv file already has H.264/AAC streams in the first place. Because if it does, all you have to do is copy the streams and change the container:

ffmpeg -i input.mkv -c copy output.mp4

否则,您可能会被拒绝,因为您的格式与.mp4不兼容.尝试以下操作以输出H.264/AAC:

If it doesn't, you probably got rejected because your formats are not compatible with .mp4. Try the following to output H.264/AAC:

ffmpeg -i input.mkv -c:v libx264 -c:a aac output.mp4

但同样,如果您的.mkv已经包含H.264/AAC,请使用第一个解决方案.这样会更快,并且质量会更好.

But again, if your .mkv already contains H.264/AAC, USE THE FIRST SOLUTION. It'll be faster and will have a better quality.

这篇关于将MKV转换为H264 FFmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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