I am trying to convert an MKV file to MP4 to be compatible with my PS3. I am using:
avconv -i file.mkv -c copy file.mp4
It fails and I get the following error:
[mp4 @ 0x8a17c00] pts < dts in stream 0
av_interleaved_write_frame(): Invalid argument
The file is h264 video and ac3 audio.
Get needed software
Extract video and audio from matroska file
First you need to check what tracks the matroska file contains with
mkvmerge --identify video.mkv
Then extract video and audio according to their tracks with:
mkvextract tracks video.mkv 1:video.h264 2:audio.ac3
Mux audio and video into mp4 containter
MP4Box -fps 24 -add video.h264 -add audio.ac3 video.mp4
I had to add
-fps 24
option becauseMP4Box
didn't detect video fps correctly. Depending on usageAC3
audio track should be re-encoded into something else before muxing.Now you have remuxed streams from matroska container into mp4 container without losing any quality.
EDIT: MP4 doesn't officially support AC3 audio so the audio track should be converted into a supported format (eg. AAC, MP3) if you want the file to be playable with something else than VLC.
I believe that
is the correct command. You need to specify the codec copy property for the streams you want to copy separately.
I was looking for muxing mp4 along with m4a. The usual ffmpeg commands for encoding didn't worked.Tried MP4Box & it worked like a charm. :-)
You can use winff-gtk2 it solved my the problem! To install:
.