Log in

View Full Version : How to decimate video and audio keeping it in sync


Mentalmummy
6th March 2005, 18:06
I am trying to rip some dvd`s to play on my ngage but all my avisynth scripts result in the audio being too long for some reason.

My dvd`s are all pal retail discs, I can always get the video playing fine but for some reason the audio is always much longer than the video (for instance on a short test clip it says in VirtualDubMod I would have to change the frame rate from 15fps to 73 to make them match).

I know the audio mp3 file is ripped correctly, I have checked this, and I have tried various approaches but they all fail. Does anyone have any ideas how to rectify the prolem, please?

I tried using the selecteven() function and dubbing the audio in outside of avisynth using avimux or VirtualDubMod but in that case audio duration matched but was way out of sync.

I also tried using Besweet to change the audio to suit 15 fps video but that was just as bad.

My latest attempt, if it helps, is

LoadPlugin("C:\AVI\plugins\MPEGdecoder.dll")
LoadPlugin("C:\AVI\plugins\mpeg2dec3.dll")
LoadPlugin("C:\AVI\plugins\UnDot.dll")
LoadPlugin("C:\AVI\plugins\decomb510.dll")
LoadPlugin("C:\AVI\smoothdeinterlacer.dll")
LoadPlugin("C:\AVI\plugins\fdecimate.dll")
LoadPlugin("C:\AVI\plugins\evilmpasource.dll")
video=mpegsource("C:\AVI\dvdrip\VTS_01_1.VOB")
audio=evilmpasource("C:\AVI\dvdrip\audio.mp3")
EnsureVBRmp3sync(audio)
film=audiodub(video,audio)
film=ConvertToYUY2(film)
film=LumaFilter(film, -2)
film=UnDot(film)
film=lanczos4resize(film,208, 176)
film=FDecimate(film,rate=15.000,threshold=0)
return(film)

I`m puzzled as to why it is not working and any advice would be appreciated, I walk to and from work and it would be nice to watch a film enroute (it`s a long walk) :)

Guest
6th March 2005, 19:30
You call video playing at 15fps "fine"?

Mentalmummy
6th March 2005, 19:40
Yes, it is okay for a mobile phone. Most mobile videos are 12 to 15 frames per second.

Obviously it looks awful on a big screen but on a mobile looks okay :)

If I use standard mpasource and not wav or evilmpa source then I can get the audio almost right length (14.689 fps) but even then is way out of sync and I cannot seem to get it right.

I tried using besweet to add make a wav-mp3 and use wavsource on that but that was much more out of sync.

Guest
6th March 2005, 20:48
You need to get the playing time of your audio and video the same. It makes no sense to talk about 15fps audio. The video should have the same playing time regardless of the frame rate (because you decimated). Have you tried DGMPGDec? Try that. You should get a D2V that when served into VirtualDub has the same playing time as the demuxed audio. Then it's just a matter of setting the audio delay as given in the filename of the demuxed audio.

Mentalmummy
7th March 2005, 12:31
I have tried that, it doesn`t make sense why the audio is out so much as I have adjusted the delay. I shall have to figure something out, thankyou for your help as you have given me some ideas.

I may see if I can use the ngages preroll audio setting to compensate if all else fails.

kingmob
7th March 2005, 16:33
I'd concentrate on besweet. I think something goes wrong in the process before you mux it in.
Also, i'm not quite sure why you have your audio in the script? I always process audio seperately (and NEVER use vbr ;)).

Mentalmummy
7th March 2005, 22:23
I use Besweet to extract audio from vob and avs2wav to get the correct audio length after decimation. I have managed to convert avi`s I already have into mobile phone avi`s with perfect sync so will have another try at dvd to avi again probably as I`m sure it`s something to do with the handling of the audio as with avi`s it is fine.

Thanks :)

manono
7th March 2005, 23:06
Hi-

...avs2wav to get the correct audio length after decimation.

The video stays the same length after decimation, as should the audio. What's the sample rate of the audio? Mono 22,050 Hz, or something like that?

As kingmob said, you should probably be handling the audio outside of AviSynth, and then muxing it in afterwards.

Mentalmummy
8th March 2005, 12:40
Originally posted by manono
Hi-

...avs2wav to get the correct audio length after decimation.

The video stays the same length after decimation, as should the audio. What's the sample rate of the audio? Mono 22,050 Hz, or something like that?

As kingmob said, you should probably be handling the audio outside of AviSynth, and then muxing it in afterwards.

I am currently extracting the audio using avs2wav and converting to mp3 using besweet as I found that if I took the original source audio before decimation it was slightly off but spot on this way so I perhaps wrongly (?) assumed that parts of the audio were being trimmed.

It is easier for me this way because the original audio is surround compatible mp3 audio at 44.1 Khz 112 Kb bitrate and for my phone needs to be much lower. As a result I still need to extract the audio and convert it at some stage, via avisynth I know it will be in sync even if I were to add anything later such as ivtc.

I was going to ask about besweet but will post that question in correct forum :)