Log in

View Full Version : How to demux AC-3 audio stream from *.mkv video?


mike23
19th April 2017, 06:13
I have a big video file (>8 GB) with an MPEG-4p10/AVC/h.264 encoded video part and an AC-3 encoded audio part.
Both tracks are embedded in a *.mkv container.

Since I need not such a high resolution and prefer smaller video files on my hard disk I want to re-encode it with Avidemux to a lower bitarate and MP3 as audio codec.

Whenever I do this the resulting video is asynchronous.

So sometimes the audio part is approx 9 seconds ahead, other only 4 seconds.

Since I encoded with the same settings 50 other videos the used current Avidemux are correct.

So I am searching for another way to produce a smaller video file.

How can I achieve this?

How do I de-mux the audio part with mkvmerge GUI from mkvtoolnix package?

jpsdr
19th April 2017, 08:48
You have to use mkvextract, which is a command line program, and has no GUI as far as i know.
Maybe you can also uses eac3to (also a command line program), i think it also works on mkv files.

AMED
19th April 2017, 09:34
mkvcleaver is a gui for mkvextract. You'll need to use mkvtoolnix 9.9 for it to work. A new version will be released with mkvtoolnix v10 support.

stax76
19th April 2017, 10:08
There are several GUIs for mkvextract, staxrip has a built in used when it opens a file and a separate standalone for an manual workflow found at Tools > Demux

Also popular is gMKVExtractGUI: https://forum.doom9.org/showthread.php?t=170249

sneaker_ger
19th April 2017, 11:13
Maybe you can also uses eac3to (also a command line program), i think it also works on mkv files.
Yes. That can even be better if you run into sync problems as unlike mkvextract eac3to tries to fix such issues during demuxing. (audio frames are dropped/inserted)

ronny85
21st April 2017, 12:59
hello mike23

I will not bother you with the video conversion, but, as a general rule, you should verify and mantain the raw video fps (constant or variable, don't use constant fps in a video with raw variable fps)



but, as regard the audio issue:

the a-v desync problem is due to a delay of the audio relative to the video in the mkv container

It cound be that the raw video is 24fps, the mkv container is set at 25fps and the audio is so sync'd at 25fps

It could be that the both raw video and mkv are 24fps but there is a delay relatve to the video (in milliseconds)


you'd be better to use a tool to quantify the delay (mediainfo, ffprobe) or to check if there is a discrepancy between the container and the raw video fps



btw to demux the track, use the plain ffmpeg command line

to extract the first audio track (audio track 0)
ffmpeg -i source.mkv -map 0:a:0 -c copy audiotrack0.m4a




beware: you can always fix a mere delay (with sox or a manual edit), but you can fix the audio "speed" relative to the video (or the container) only if the raw video track has constant fps (using eac3to)