I want to convert an mp4 file to mkv with the video format as x264 and audio as libmp3lame

  1. Mediainfo for the file gives:

    Complete name                            : file_in.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media
    Codec ID                                 : isom
    File size                                : 404 MiB
    Duration                                 : 41mn 4s
    Overall bit rate                         : 1 375 Kbps
    Writing application                      : Lavf56.1.0
    ID                                       : 1
    Format                                   : MPEG-4 Visual
    Format profile                           : Advanced Simple@L5
    Format settings, BVOP                    : Yes
    Format settings, QPel                    : No
    Format settings, GMC                     : No warppoints
    Format settings, Matrix                  : Default (H.263)
    Codec ID                                 : 20
    Duration                                 : 40mn 55s
    Bit rate                                 : 1 185 Kbps
    Width                                    : 576 pixels
    Height                                   : 432 pixels
    Display aspect ratio                     : 4:3
    Frame rate mode                          : Constant
    Frame rate                               : 29.970 fps
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Compression mode                         : Lossy
    Bits/(Pixel*Frame)                       : 0.159
    Stream size                              : 347 MiB (86%)
    Writing library                          : XviD 1.3.0.dev55
    ID                                       : 2
    Format                                   : AC-3
    Format/Info                              : Audio Coding 3
    Mode extension                           : CM (complete main)
    Format settings, Endianness              : Big
    Codec ID                                 : ac-3
    Duration                                 : 41mn 4s
    Bit rate mode                            : Constant
    Bit rate                                 : 192 Kbps
    Channel(s)                               : 2 channels
    Channel positions                        : Front: L R
    Sampling rate                            : 48.0 KHz
    Bit depth                                : 16 bits
    Compression mode                         : Lossy
    Stream size                              : 56.4 MiB (14%)
  2. libx264-dev and libav-tools are the latest versions.

  3. I tried converting with the following command

    avconv -i file_in.mp4 -c:v libx264 -acodec libmp3lame file_out.mkv
  4. Output of the avconv command was

    avconv version 11.2-6:11.2-1, Copyright (c) 2000-2014 the Libav developers
      built on Jan 18 2015 05:12:33 with gcc 4.9.2 (Ubuntu 4.9.2-10ubuntu2)
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0xa1d4c0] multiple edit list entries, a/v desync might occur, patch welcome
        Last message repeated 1 times
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0xa1d4c0] max_analyze_duration 5000000 reached
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file_in.mp4':
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2mp41
        encoder         : Lavf56.1.0
      Duration: 00:41:04.99, start: 0.016000, bitrate: 1375 kb/s
        Stream #0.0(und): Video: mpeg4, yuv420p, 1184 kb/s, 30k tbn (default)
        Stream #0.1(und): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
    Output #0, matroska, to 'file_out.mkv':
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2mp41
        encoder         : Lavf56.1.0
        Stream #0.0(und): Audio: libmp3lame, 48000 Hz, stereo, fltp (default)
          encoder         : Lavc56.1.0 libmp3lame
    Stream mapping:
      Stream #0:1 -> #0:0 (ac3 (native) -> mp3 (libmp3lame))
    size=     315kB time=19.75 bitrate= 130.8kbits/s
    size=   39227kB time=2464.97 bitrate= 130.4kbits/s    
    video:0kB audio:38516kB other streams:0kB global headers:0kB muxing overhead: 1.845972%

Essentially only the audio is copied. How do I get the video+audio in mkv format?

  • You tagged this with ffmpeg, but it appears you did not test it (avconv is not equivalent to ffmpeg).
    – llogan
    Commented Sep 3, 2015 at 16:40
  • apologies - removed tag
    – 3l4ng
    Commented Sep 3, 2015 at 18:58

1 Answer 1


Your video is encoded as "MPEG4 Visual", this is another name for mp42. Unfortunately, this video was encoded using software that was developed in a time where the MPEG4-2 standard was no yet implemented.

By the time it was ready for general use, other codecs had taken its place (namely x264 etc).

This means that support for this codec is rudimentary, and struggles at best.

That said, you can fix the file somewhat, into a format that ffmpeg will read properly.

The part that ffmpeg has difficulty with, is the major_brand : isom part of the metadata.

To get around this, we use another tool: MP4Box

Then, once you have MP4Box installed, you run a command like this:

MP4Box -brand mp42 input.mp4

This should change the metadata to read major_brand : mp42

Once this has been completed, ffmpeg should recognize it, and be able to convert it properly.

Good luck! :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .