View Full Version : Problem extracting sound from an MKV / AVI file
Dustin013
11th May 2008, 00:16
I am having some issues with exacting audio out of one of my video files. Originally it was in AVI but I have converted the AVI into an MKV and tried that way as well. Video 1 is the problem, however video 2 works. I have used VideoInfo Tool 3.1 to get the information below.
It is obvious that Video1 was encoded differently than Video2, I just can't figure out how to extract the MP3. I convert the AVI into an MKV and use MKVExtract and I get a mp3 file that doesn't play.
I also did the following with mplayer:
mplayer.exe test.avi -dumpaudio -dumpfile test.mp3
MPlayer 1.0rc2-4.2.1 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Duo CPU T7250 @ 2.00GHz (Family: 6, Model: 15, Step
ping: 13)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
Playing test.avi.
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
VIDEO: [DIV3] 640x360 24bpp 25.000 fps 925.3 kbps (113.0 kbyte/s)
Core dumped ;)
Exiting... (End of file)
Still left with an MP3 with no audio :(
STATS ON VIDEO 1
Container=AVI
FileSize=351 MiB
VideoCodec=DIV3
VideoPlayTime=00:42:26.280
VideoBitrate=914 Kbps
VideoWidth=640
VideoHeight=360
VideoAspectRatio=1.778
VideoFrameRate=25.000
VideoFrameCount=63657
AudioCodec=AC3
AudioBitrate=224 Kbps
AudioMode=CBR
AudioChannels=4
AudioSamplingRate=48000
AVIdwRate=25000
AVIdwScale=1000
STATS ON VIDEO 2 (an AVI I can correctly extract audio and remux into an MP4)
Container=AVI
FileSize=226 MiB
VideoCodec=XVID
VideoPlayTime=00:21:34.640
VideoBitrate=1262 Kbps
VideoWidth=640
VideoHeight=480
VideoAspectRatio=1.333
VideoFrameRate=25.000
VideoFrameCount=32366
AudioCodec=MPA1L3
AudioBitrate=190 Kbps
AudioMode=CBR
AudioChannels=2
AudioSamplingRate=44100
AVIdwRate=25
AVIdwScale=1
Video 2 will work both ways when I try to exact the audio.
Any suggestions?
Dustin013
11th May 2008, 00:38
Ok, I just used MP4Box to exact a RAW file from the AVI file. Then I used BePipe to convert the RAW file to an MP4 file.
C:\>bepipe --script "DirectShowSource(^C:\test_audio.raw^).Normalize().DelayAudio(0)" | "C:\Documents and Settings\Dustin\Desktop\Nero\win32\neroAacEnc.exe"
-ignorelength -cbr 92000 -he -if - -of "C:\test_aud1_und.mp4"
Basically, it would all seem fine, however when I use MP4 box to layer it together using the following command:
(Using the following command because I am creating MP4 files for use with my Iphone)
C:\>MP4Box -ipod -brand M4VP -add test_video.mp4 -add test_aud1_und.mp4 final.m4v
The files merge but it sounds like chipmunks and the sound is so far out of sync.
VideoInfo says the following about the mp4 audio file I am trying to merge.
AudioCodec=A_AAC/MPEG4/LC/SBR
AudioBitrate=92 Kbps
AudioMode=VBR
AudioChannels=6
AudioSamplingRate=48000
setarip_old
11th May 2008, 02:27
Hi!
Your initial post to this thread is confusing (at least it is to me). If you simply desire to extract your .MP3 audiostream from the (DivX-compressed or XviD-compressed) .AVI that you've created, simply:
1) Load the .AVI into VirtualDubMOD
2) Click on the "Streams" dropdown menu, click on "Stream List"
3) Select/Highlight the.MP3 audiostream
4) click on the "Demux" radiobutton to save with a "filename.mp3" name.
If you mean something else, please clarify...
Dustin013
11th May 2008, 02:51
Ok, I will try to re-explain the situation a little better. So please ignore the first post and read this one.
I am trying to take an AVI file and convert to MKV file so I can then convert into an MP4 for use on my Iphone. The reason I am converting to MKV file is because I would like to use x264farm eventually. Once I have the MKV file I am trying to extract the audio from the file. Once that is done I encode the MKV video file into an MP4 file and then convert the MP3 I extracted into an MP4. Finally I try to layer them together.
Here is exactly what I am typing each step of the way.
STEP 1
C:\>mkvmerge.exe -o "test.mkv" --engage allow_avc_in_vfw_mode "C:\test.avi"
This creates Test.MKV from Test.AVI
STEP 2
C:\>mkvextract.exe tracks "test.mkv" 2:"C:\test_aud1_und.mp3"
This will exact the audio file from the MKV file and give me an MP3 file.
STEP 3
C:\>x264.exe --bitrate 308 --level 3 --no-cabac --subme 6 --partitions none --vb
v-bufsize 2000 --vbv-maxrate 400 --threads auto --thread-input --progress --no-p
snr --no-ssim --output "c:\test_vid.mp4" "C:\test.avs"
This step takes the video layer from test.mkv and converts it into x264 and places it in a file called test_vid.mp4
Here is my test.AVS file
LoadPlugin("C:\Program Files\Ani-x264\filters\Undot.dll")
LoadPlugin("C:\Program Files\Ani-x264\filters\FluxSmooth.dll")
LoadPlugin("C:\Program Files\Ani-x264\filters\Convolution3DYV12.dll")
LoadPlugin("C:\Program Files\Ani-x264\filters\TDeint.dll")
LoadPlugin("C:\Program Files\Ani-x264\filters\TIVTC.dll")
DirectShowSource("C:\battlestar.mkv",audio=false)
TFM() #Inverse Telecine
TDecimate(mode = 1) #Inverse Telecine
FadeIO2(25) #FadeIn/FadeOut Frames
ConvertToYV12()
To be honest, I am not sure thats completely correct, so if you have any suggestions for my AVS file please let me know. Again, I am converting my AVIs into MP4 files for use with my IPhone.
Step 4
C:\>bepipe --script "DirectShowSource(^C:\test_aud1_und.mp3^).Normalize().
DelayAudio(0)" | "C:\Documents and Settings\Dustin\Desktop\Nero\win32\neroAacEnc
.exe" -ignorelength -hinttrack -cbr 92000 -he -if - -of "C:\test_aud1_und.
mp4"
This step takes my mp3 file and converts it into an MP4 file. Here is my first error however. While the file converts and will play the file length between the mp3 and the mp4 is now different. The original length of the Video I am converting is 43min and 03 seconds. The new Video only MP4 (test_vid.mp4) is 43:03. The converted MKV file is also 43:03 as well as is the MP3 file extracted from the MKV file. When the mp3 gets converted in this step it is now over 1 hour and 3 seconds long. The last 20 min or so of the audio file has no sound. So why is my file not 43:03?
Step 5
NicMP4Box.exe -add "C:\test_vid.mp4#video:name=:lang=und" -add "C:\test_aud1_und.mp4#audio:name=:lang=und" -new "C:\test.mp4"
OR
MP4Box.exe -ipod -brand M4VP -add test_vid.mp4 -add test_aud1_und.mp4 test.mp4
Both work, both will give me a MP4 named test.mp4 that is 1hr03 seconds long (the length of the mp4 audio file after it was converted) and all sound is out of sync.
Here is a readout of the original AVI file before anything has been converted to show original framerates etc...
Container=AVI
FileSize=349 MiB
VideoCodec=XVID
VideoPlayTime=00:43:03.456
VideoBitrate=931 Kbps
VideoWidth=624
VideoHeight=352
VideoAspectRatio=1.773
VideoFrameRate=23.979
VideoFrameCount=61941
AudioCodec=MPA1L3
AudioBitrate=180 Kbps
AudioMode=VBR
AudioChannels=2
AudioSamplingRate=48000
AVIdwRate=23976024
AVIdwScale=1000000
setarip_old
11th May 2008, 04:15
If "AudioCodec=MPA1L3" is, in fact, .MP3 then I see no reason why you can't follow my suggestion.
What do you want to accomplish that requires you to extract the .MP3 audiostream?
Dustin013
11th May 2008, 09:21
Well, I was able to extract the mp3. I can't seem to convert it from MP3 to mp4 without the file length going all screwy
tebasuna51
11th May 2008, 09:57
@Dustin013
Try don't use DirectShowSource() in your avs scripts because the DirectShow configuration can be different in each machine.
At least to done support is very difficult.
1) Extract the mp3 like setarip_old say you. You also can use AviMuxGUI.
2) Convert the audio using:
C:\>bepipe --script "NicMPG123Source(^C:\test_aud1_und.mp3^).Normalize()" | "C:\Documents and Settings\Dustin\Desktop\Nero\win32\neroAacEnc..exe" -ignorelength -hinttrack -cbr 92000 -he -if - -of "C:\test_aud1_und.mp4"
3) Convert the video using:
AviSource("C:\test.avi")
Dustin013
11th May 2008, 10:37
Alright, by changing the information in bepipe I was able to get an mp4 audio file that was the exact same length as the video. I muxed the new audio file with the mp4 video layer and the sound was a second or two off. I thought maybe the conversion had gone wrong so I muxed the mp3 with the AVI and that had sound that was off.
Here is what I was thinking. How about I extract the sound from the AVI before I do anything else into RAW format. Then I encode that RAW format into MP3, then use the method you gave me above to then convert that mp3 into an MP4? This should maybe help me sync issues?
If you think that would help, how could I go about doing it? I am trying to use a command line programs for everything so I could try to automate the process in a batch file or simple VB application, so no GUIs please. (I use windows xp)
tebasuna51
11th May 2008, 11:43
Please confirm:
Alright, by changing the information in bepipe I was able to get an mp4 audio file that was the exact same length as the video. I muxed the new audio file with the mp4 video layer and the sound was a second or two off.
The audio begin before the video?
I thought maybe the conversion had gone wrong so I muxed the mp3 with the AVI and that had sound that was off.
Remuxing the extracted mp3 again with the avi video, now the audio begin before the video?
If your answer is yes to both questions maybe you have a pseudo delay (padding bytes in audio track to emulate initial silence).
If you load the original avi in AviMuxGUI and select the audio track maybe you can see the delay needed.
Here is what I was thinking. How about I extract the sound from the AVI before I do anything else into RAW format. Then I encode that RAW format into MP3, then use the method you gave me above to then convert that mp3 into an MP4? This should maybe help me sync issues?
What is RAW format?
If you think that would help, how could I go about doing it? I am trying to use a command line programs for everything so I could try to automate the process in a batch file or simple VB application, so no GUIs please. (I use windows xp)
I don't know a command line to extract audio from avi with a delay info.
mdoubledragon
11th May 2008, 14:07
I think by RAW he means uncompressed PCM
setarip_old
11th May 2008, 18:43
@Dustin013
1) Altering your initial post to this thread after several people have responded to its original content creates confusion
2) What software and procedures did you use to create "Video 2" (Contains the line "AudioCodec=MPA1L3")?
3) Is the .MP3 audio of "Video 2" CBR or VBR?
Dustin013
11th May 2008, 20:11
Both of the audio tracks for both files are CBR. I used the same process as listed above for the audio. I was referring to uncompressed PCM when I said RAW. When I remux the mp3 with the AVI... (split the avi into video and mp3 then remux) but I guess that isn't helping me :(
Sorry about the confusion, kind of a work in progress here.
I think if I can find a command line application to extract uncompressed audio then re-encode to MP3 then MP4 for just to MP4 then mux with the video layer it might work, I just can't figure out how to do this.
It would seem if I encode the files using Videora it works. However, Videora uses FFMPEG to encode the videos and I don't like the way FFMPEG encodes as much because the video isn't nearly as clear for some reason.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.