PDA

View Full Version : [solved] Converting to DVD/MPEG2 - A/V Sync


Delta2
12th October 2008, 21:54
I'm sorry if this post doesn't belong here

I have a AVI with this info :

Video :

FrameCount : 151457
FrameRate : 25 FPS
Duration : 1:40:58,280

Audio :
Type : MP3 / CBR
SampleRate: 44100
Duration : 1:40:56,515

AVIMux and MediaInfo gives me only 3ms delay, nothing big or problematic, it is easily fixed with DelayCut as I do with any movie with delay

When I convert to a MPEG2 Stream using HCEnc, or other encoder such as CCE, I get gradual loss of v/a sync. Everything is normal at the beginning of the video file, but audio is gradually shifting during playback. At the end there is almost 3 seconds delay....and this is a CBR MP3...not a VBR

If I Uncompress Audio to PCM in VDub, I get the same a/v issue

But I can easily fix that by changing Video FrameRate to 25.007 FPS instead of the normal 25 FPS, and I can get a a/v fixed AVI..

But when I try to convert to DVD, here is where I'm in trouble

I used AssumeFPS(25.007) in my Video Script, and tried to encode with HCEnc.....but there was no change in video playtime/duration

I didn't changed Audio SampleRate, I kept 44100, but tried with SSRC(48000) without success

How can I force Video framerate in order to match audio play time ? is there any solution ?

thanks

setarip_old
12th October 2008, 22:00
1) Load the .AVI into GSpot and post a screen capture back here

2) What is the Title and Region number of your original DVD?

3) What software and procedures did you use to rip your original DVD?

4) What software and procedures did you use to convert your oroiginal DVD to .AVI?

5) Does the original DVD exhibit the same behavior?

6) Does the .AVI exhibit the same behavior?

7) Why don't you just make a (compressed, if necessary) backup of your original DVD?

Delta2
12th October 2008, 22:17
[Color=Blue]1) Load the .AVI into GSpot and post a screen capture back here


I already gave the important information

http://img253.imageshack.us/img253/9126/infoxo2.jpg (http://imageshack.us)

It is not from GSpot, but let me add the info that the MP3 audio is CBR

[Color=Blue]
2) What is the Title and Region number of your original DVD?


My region is PAL, as the original AVI


3) What software and procedures did you use to rip your original DVD?

4) What software and procedures did you use to convert your oroiginal DVD to .AVI?

5) Does the original DVD exhibit the same behavior?



Is just a AVI movie that I have here, a old one that I wish to convert manually



6) Does the .AVI exhibit the same behavior?


The AVI file which I want to convert is perfectly in sync

It only gets out of sync IF I UNCOMPRESS AUDIO IN VDUB

But even so, I can fix that AVI with PCM Audio by changing Video FPS to 25.007, making so I can fix that gradually audio shifting during playback

25.007 is not a standard frame rate, right ?!

There is where I get the problem, because I tried to use AssumeFPS(25.007) when frame serving VIDEO (ONLY) to HCEnc without success

I also tried to use Neuro2's DGPullDown tool, but it can't accept such strange values : changing 25.000 FPS to 25.007 FPS

Sagekilla
12th October 2008, 22:59
Where did you acquire this AVI file from? If it was made from a DVD why don't you just make another copy of the DVD?

Alex_ander
13th October 2008, 09:00
I also tried to use Neuro2's DGPullDown tool, but it can't accept such strange values : changing 25.000 FPS to 25.007 FPS
It is quite possible to use a 'strange' number for DGPulldown's input (not for output, it should be 25). This will work like AssumeFPS in AviSynth and will change output video duration (the ammount depends on difference between typed and actual input values).

P.S. You can only type values lower than the output 25, so in your case it is better to process audio (e.g. with SoundForge's Time Stretch).

Delta2
13th October 2008, 11:55
P.S. You can only type values lower than the output 25, so in your case it is better to process audio (e.g. with SoundForge's Time Stretch).


Thanks

Good ideia, I will try AVISynth's TimeStretch

BTW, a question out-of-topic

I notice that I can convert a 25FPS movie to 29.970FPS using TimeStretch for audio TEMPO CHANGE (without affecting PITCH) instead of BesWeet audio rate conversion ( ota switch )

What is best method ? besweet or TimeStretch ?

thanks

2Bdecided
13th October 2008, 12:48
To state the obvious...

1. The video and audio durations are different. If the end is simply missing from the audio, then any program that stretches the audio duration to match that of the video will cause a sync problem.

2. The audio is 44.1kHz. DVD requires 48kHz. Check the resampling is working properly.

3. You must use 25fps for "PAL" DVD. It's pointless trying any other frame rate - it's not supported. Yes you can us DGpulldown to add duplicate frames, but in this case it seems obvious to fix the audio, not change the video.

4. Read the forum rules.

Cheers,
David.

Delta2
13th October 2008, 12:57
========
2. The audio is 44.1kHz. DVD requires 48kHz. Check the resampling is working properly.
========

I checked that already, no problem with it


=====
3. You must use 25fps for "PAL" DVD. It's pointless trying any other frame rate - it's not supported. Yes you can us DGpulldown to add duplicate frames, but in this case it seems obvious to fix the audio, not change the video.
=====

Yes as Alex_ander suggested, I was focusing on video. I know that 25 is the standard


=====
4. Read the forum rules.
=====

Why are you saying that ? I'm always careful with forum rules

Sagekilla
13th October 2008, 20:33
Why read the forum rules? Because what you're dealing with sounds like an illegally obtained video. You still haven't answered my question of where you got the material to begin with. If this was made from a PAL DVD, why are you transcoding it back to a DVD again? If you own the DVD just make a copy of it, if you don't (which it sounds like) you're violating rule 6.

Delta2
13th October 2008, 21:38
If this was made from a PAL DVD, why are you transcoding it back to a DVD again?


Because this is not belonging to IMDb database, it is a portuguese presentation, and I need it in DVD to my studies in college, and because my DivX player can't play it either, maybe because it is too huge - with almost 2GB in a single file, with QPEL enabled..etc..

satisfied ?

Guess what, some colleagues of mine did convert it with VSO...it stutters a little bit...and the audio is awful, although it is watchable and in sync ..the overall quality is very bad

I'm currently trying to use TimeStretch, and it is almost fixed thanks to Alex_ander who gave me a clue

So thanks anyway, can be closed

Delta2
13th October 2008, 21:53
P.S. You can only type values lower than the output 25, so in your case it is better to process audio (e.g. with SoundForge's Time Stretch).

many thanks Alex for your clue, it is perfectly in sync now thanks to you

I said that I was able to fix the AVI file changing Video Framerate to 25.007, remember ?

Well, following your suggestion I used this script :

MySource = AVISource("C:\escola\mecanica.avi")
MyVideo = MySource.KillAudio().AssumeFPS(25)
MyAudio = MySource.GetChannel(1,2).TimeStretch(tempo = (100 * 24.993) / MySource.Framerate()).SSRC(48000)
AudioDub(MyVideo, MyAudio)

Hope this can help someone, nothing is impossible

IanB
13th October 2008, 22:46
For just a 0.028% speed change stop stuffing around with TimeStretch and just reclock the audio, you have to resample it to 48000 anyway for DVD.AVISource("....avi")
AssumeFPS(25.007, False) # Make V match A length
AssumeFPS(25, 1, True) # Reclock to standard V rate
ResampleAudio(48000) # Resample to standard A rateorAVISource("....avi")
AssumeSampleRate(44088) # Make A match V length
ResampleAudio(48000) # Resample to standard A rate

Delta2
14th October 2008, 00:27
For just a 0.028% speed change stop stuffing around with TimeStretch and just reclock the audio, you have to resample it to 48000 anyway for DVD.AVISource("....avi")
AssumeFPS(25.007, False) # Make V match A length
AssumeFPS(25, 1, True) # Reclock to standard V rate
ResampleAudio(48000) # Resample to standard A rateorAVISource("....avi")
AssumeSampleRate(44088) # Make A match V length
ResampleAudio(48000) # Resample to standard A rate

Well, IanB

can you explain your math ?

How did you reached 0.028% speed ?

and most important, how did you reached to the value of 44088 sample rate ?

And why TimeStretch is so bad if I just can get everything in sync ? because we are dealing with float values and rounding errors might occur ? do you think they are noticeable ? I didn't notice anything...is just perfect for my ears

I'm asking this because, I'm curious about that 44088 sample rate.....didn't tried that approach

Can you be more specific in your math ? give a detailed explanation on how did you reached to that values ?

IanB
14th October 2008, 02:47
(25.007-25)/25*100=0.028%44100*25/25.007=44087.65 => 44088The net result of the 2 scripts are identical, I just used different syntaxes to represent the same idea i.e. make the audio 0.028% slower.


Timestretch works by duplicating or removing short sections of sound, it tries to select the position of the join such that the correlation between the original and modified is as high as possible i.e. it looks for duplicate sounds. In order to maintain synchronisation it confines the search to a window and chooses the best match in that window, the best match may not always be very good, e.g. glide tones always develop a noticeable step after processing. So the result is content dependant.

With reclocking the phase and tonal relationship are absolutely maintained for all content, however the pitch is altered in direct proportion to the change in rate. For very small changes this kiss approach is always recommended. What constitutes "small" is very subjective, but I think 0.028% is always "small".


Industry practise for PAL broadcasting of 24 fps FILM is to speed up 4% by simply reclocking, this raises the pitch by 98% of 1 semitone in music. Most people cannot detect this without some external reference. Also the tempo is increased by 4%, also most people cannot detect this without some external reference. Industry regards 4% as "small".

Musicians that need to play along have such a reference and prefer not to retune their instruments (even if they can). The more complicated Timestretch is relevant here, there is still a 4% tempo increase but the musicians just play 4% faster to keep pace. If even the 4% tempo increase cannot be tolerated then some form of resampling the video must be used i.e. the simplest is to duplicate 1 field every 24 fields, this gives a 2Hz slight stutter to smooth movement. A variation is to duplicate 1 frame every 24 frames, this gives a 1Hz stronger stutter to smooth movement. The highend solutions involve expensive equipment from Snell and Wilcox. Musicians, etc, do not regards 4% as "small".

Delta2
14th October 2008, 21:50
IanB,

Your idea worked, I tried the script bellow

Thanks a lot for the explanation, I didn't notice any audio differences in quality, but as far as I understood TimeStrech is to avoid, and it is much better to reclock the audio, right ?

The strange thing about this all, is if you look to the File Information image I gave above (#3 post ) ...audio and video length match, audio length only gets shorter when I demux it

I found that 0.028% speed change only after I made 2 or 3 tentatives

By only analyzing MP3 demuxed audio length ( in my #1 post ) can you guess that value ? i.e., can you spare time in this ?



MySource = AVISource("C:\escola\mecanica.avi")
MyVideo = MySource.KillAudio().AssumeFPS(25)
MyAudio = MySource.GetChannel(1,2).AssumeSampleRate(44088).ResampleAudio(48000)
AudioDub(MyVideo, MyAudio)

IanB
15th October 2008, 00:05
...I didn't notice any audio differences in quality, but as far as I understood TimeStrech is to avoid, and it is much better to reclock the audio, right ?As I said "What constitutes "small" is very subjective". Reclocking is the tool of choice for "small" changes. Timestretching is a tool for non-small changes, it can cause artifacts for some program content. All tools for non-small changes will fail with some program materials, this is why you need a good collection of algorithms, to find one that will work with your material in the current circumstances.