When converting mkv to mp4, the audio is lost

5.1k views Asked by At

I have converted my .mkv file into an .mp4 by using the command:

sudo avconv -i input.mkv -codec copy output.mp4

I am trying to play the mp4 file in the browser, but the audio is not playing. The video player shows that it is on mute, but the button is disabled so you cannot turn it off of mute.

Other mp4s are working, but they were not converted from .mkv. Any help would be much appreciated.

1

There are 1 answers

4
mark4o On BEST ANSWER

In an MP4 container, browsers usually support only H.264 video and either AAC or MP3 audio. The output from your avconv command should show the format of your video and audio; look under "Input #0" for the lines that start with "Stream #". If you audio is not already AAC or MP3 you will want to convert it instead of just copying it to the MP4 container. You can copy the video and convert only the audio with a command like this:

avconv -i input.mkv -c:v copy -c:a libmp3lame -q:a 2 output.mp4

The -c:v copy will copy the video, and -c:a libmp3lame will convert the audio to MP3 using the libmp3lame encoder. -q:a 2 sets the audio quality; use a lower number for better quality (and a larger file). You could instead convert to AAC audio if your avconv was configured with non-free codecs enabled and a good quality AAC encoder.