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
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.
Here is the original question:
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
But I get the error:
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
is a video container andH.264
is an encoding format. You cannot convert a container to an endoding. – Pierrelibvo-aacenc
like this--enable-libvo-aacenc
. Why don't you uselibfaac
orlibfdk_aac
. They are free. – Goodtempered