Log in

View Full Version : MKV(h264+AAC) to AVI(xvid+mp3), asynch.


alcio85
21st October 2008, 01:36
I'm trying to convert some anime from mkv (h264+aac) to avi (xvid+mp3)

The video convertion goes fine, insead the audio conversion piss me off.
I load the mkv in avisynth with directshowsourse, if i play the .avs with mpclassic all goes well, but as soon as i try to convert it in mp3 it goes out of synch (both static and dinamic... at beggining i got about 0.5s dealy, and at the end i got abou 3,5s of delay...)

I think directshowsource do not works very well in theese situation, so i try to extract the acc from the mkv, but at the end besweet do not recognize it and if forced it do not convert it in mp3...

1) Is there any way to converto mkv(acc) to avi(mp3) passing through avisynth?
2) How shoul i do to convert properly an acc in a mp3 ?

Guest
21st October 2008, 01:38
Where did you get the MKV files?

hoboX10
21st October 2008, 04:55
If you are legally doing this, try using Avidemux (http://forum.doom9.org/showthread.php?p=1006659#post1006659)

alcio85
21st October 2008, 07:57
yeap, it is all legal !!
The mkv comes from a freetv-rip so it is perfecly legal.

i'll try avidemux, i'll let you know if it works. Thanks for the advice.

tebasuna51
21st October 2008, 10:21
Remember A/V asynch after a conversion never is due to audio conversion (if there aren't corrupt data).

1) When there are a fix asynch along the movie is due to an A/V delay in source container. You need insert the delay when convert the audio or when mux the A/V in new container.

2) When there are a progressive asynch along the movie is due to a bad video conversion involving a fps change. If you change the video fps, preserving the number of frames, the duration is also changed. You need preserve the video duration or change the audio duration.


This forum is to talk about audio conversion and we can provide help about tools to manage audio streams demuxed from A/V containers. Use mkvextract to obtain the aac audio and now to convert aac audio to mp3 you can use:

1) Command line tools like faad2 (aac decoder) and lame (mp3 encoder)

2) GUI tools like Foobar2000. (BeSweet can't decode aac streams)

3) AviSynth methods like BeHappy with the BassAudio.dll plugin (aac decoder, also bass.dll and bass_aac.dll needed). If you use the DirectShowSource method we can't support your request because each machine can have a very different DirectShow configuration.

sneaker_ger
21st October 2008, 16:58
The mkv probably has a video with a variable framerate (VFR). Try to open it with this line in AviSynth for a simple conversion:
DirectShowSource("anime.mkv", fps=23.976, convertfps=true)

alcio85
21st October 2008, 20:02
Well the strange is that if i play the .avs with mpclassic the video goes perfectly.
But if i decode it, i'll have this async problem.

Avidemux, do not work. I mean on this file... it says: H.264 detected
If the file is using B-frames as reference it can lead to a crash or stuttering.
Avidemux can use another mode which is safe but YOU WILL LOSE FRAME ACCURACY.
Do you want to use that mode?

Then:
Index is not up to date
You should use Tool->Rebuild frame. Do it now ?

Both i say yes or no, anyways the file loads, then i setup avidemux as i need and start the conversion, the file it gives isn't readable by any player (wmp, mpc, vlc...) but if i open it in virtualdub i can see the video frames correctly, the audio stream is in mp3 but it is mute...
Anyway with avidemux i can't obtain a playable file...so i just think i'll left avidemux.




The async i got with directshowsource is both fixed and progressive... Quite boring to fix, mainly becuase i need to convert about 20 file like this...

I've already tryed with DirectShowSource("anime.mkv", fps=29.97) , now i added convertfps=true...
Wishing it could fix it...

Meanwhile i was writing i was testing convertfps=true, and i must say that seems to work.
In the first 5 min the audio is perfectly synched.
(i did just only a quick partial conversion to see how it goes.)








Remember A/V asynch after a conversion never is due to audio conversion (if there aren't corrupt data).

1) When there are a fix asynch along the movie is due to an A/V delay in source container. You need insert the delay when convert the audio or when mux the A/V in new container.
How to find it in mkv or mp4 container ?


2) When there are a progressive asynch along the movie is due to a bad video conversion involving a fps change. If you change the video fps, preserving the number of frames, the duration is also changed. You need preserve the video duration or change the audio duration.

Maybe one of my problems...


This forum is to talk about audio conversion and we can provide help about tools to manage audio streams demuxed from A/V containers. Use mkvextract to obtain the aac audio and now to convert aac audio to mp3 you can use:

The reason why i posted here , as beacuse aac audio always gives problem in converting in mp3, and i thought it was a virtualdub-avisynth-mp3/acc codec issue.


2) GUI tools like Foobar2000. (BeSweet can't decode aac streams)

Thank i was really seraching a tool like besweet but with acc support.

3) If you use the DirectShowSource method we can't support your request because each machine can have a very different DirectShow configuration.
Got it, so directshow depends on how and on wich codec the directshow il setted in that particular pc..

Thank you all for the advice. I'll use foobat next time.
And the convertfps trick runs well.

alcio85
22nd October 2008, 12:47
Well, i got another problem, i got one audio corrupted, the avisynth script (in directshow) works greatly in playback, but when i try to save the audio in wav or any other format, i got some problems .

The audio seems to be corrupted (as foobar says when converting), i can convert about 3/4 of the entire audio, but the rest do not work (and after a squeeze i got mute the rest final quarter of the audio)

Can i fix the original audio file? It is in aac and if i play it i can see clearly all the track. But converting it gives problems...

tebasuna51
22nd October 2008, 13:33
If you can play the file with DirectShow filters use GraphEdit to play the file.

If work, replace the audio Renderer by 'Wav Dest' and 'File Writer'.

alcio85
22nd October 2008, 13:39
i'm quite a noob in theese stuffs...
I can say that the file loaded in virtualdub (passing thru avisynth) works fine in playback.The problem is on converting the audio.

What is graphedit, where i set it?

roozhou
22nd October 2008, 13:51
Forget avisynth and virtualdub when encoding mkv. Lots of animes are variable-frame-rate, so try avidemux or mencoder-based GUIs which support such files.

alcio85
22nd October 2008, 18:47
as i said the problem is that avidemux gives me not readable files...
Avisynth+vdmod worked great , exept for only one file that had an aac corrupted... also foobar isn't able to convert the extract (with mkvextract) audio in mp3...

poisondeathray
22nd October 2008, 18:51
as i said the problem is that avidemux gives me not readable files...
Avisynth+vdmod worked great , exept for only one file that had an aac corrupted... also foobar isn't able to convert the extract (with mkvextract) audio in mp3...

Did you forget to manually enter the extension in avidemux when saving?

If your aac is LATM/LAOS variety (featured in some types of transport streams TV recordings) , you have to convert with winamp to a .wav intermediate first - there is no directshow decoder for this type of aac audio

alcio85
22nd October 2008, 19:59
Did you forget to manually enter the extension in avidemux when saving?

If your aac is LATM/LAOS variety (featured in some types of transport streams TV recordings) , you have to convert with winamp to a .wav intermediate first - there is no directshow decoder for this type of aac audio

No no, i type the correct extension manually, but both mcplayer, wmp and vlc, opens the file, gives the right duration near the slidebar, but the video is always stopped, even clciking on play it do not start. Instead moving the slidebar cursor ahead make the applications to crash.

The audio comes from a japaneese anime, so it is maybe as you said. The strange is that on 20 files only this has that problem...
I already tryed a intermadiate conversion aac->wav , but the wav has already this problem...

I'll try winamp

EDIT: winamp work perfectly, thank you, now i need some times to resynch it, do you know if there is a way to know the dealy settewd in a mkv container ? (with avinaptic i can see it, and with mkvinfo i can't find it ... there are too many entries...)

poisondeathray
22nd October 2008, 20:19
you can try mediainfo (view=>text) it sometimes gives the delay for the audio

or use eac3to to detect the delay

These might now work if it is truly LATM/LAOS aac audio

You can also manually do it in a player, and note the delay (e..g +/- 10ms at a time)

This assumes that the lengths are correct (ie. not a progressive sync issue), and that you fixed any VFR issues

alcio85
22nd October 2008, 20:27
you can try mediainfo (view=>text) it sometimes gives the delay for the audio

or use eac3to to detect the delay

These might now work if it is truly LATM/LAOS aac audio

You can also manually do it in a player, and note the delay (e..g +/- 10ms at a time)

This assumes that the lengths are correct (ie. not a progressive sync issue), and that you fixed any VFR issues

Yeap VFR "fixed", the duration is equal and got no progressive desynch.
Setted the dealy manually.

Next time i need to do a similar job i'll try to search for mediainfo (view=>text)

Is eac3to a programm? Well next time i'll try this too...


Job fully completed thank you all very much for all advices. Really thank you all. Bye! :thanks: