Log in

View Full Version : 1080i HDV downconvert to SD MPEG2: audio/video sync problems


cail
8th July 2007, 10:07
Hi all,

Hope someone already rushed through the stuff I'm stuck in and can help me.

What I'm trying to do is to edit my 1080i footage from Canon HV10 in NLE (Ulead MSP) and get on output an HD and SD mpeg2.

With HD everything is fine. Uleads works good (at most) with smart rendering and forwards all the mpeg streams without reencoding (except transitions and clip edges of course).

The final HD mpg is ok, playing fine on any software player.

What I'm trying next is using smthng. like


input = MPEG2Source("Devil's Lake - Mountains [HDV].d2v")
last = input.SeparateFields.SelectEvery(2,1).LanczosResize(720, 480)
AssumeFrameBased
last
ConvertToYV12

(this should give me a progressive 29.97 SD video)
and feed this into quEnc.

The SD mpg output then is out of sync with audio (which is original mpa from hdv).

The problem is not in quenc, or avisynth. I've even tried feeding the source HD mpg directly into Canopus. Video is still out of sync.

As far as I understood (reading forum and googling), the problem I have is with PTS stamps in original HD clips, which is mixed after feeding clips via Ulead MSP. The delays are actually in a target video stream, it becomes slower than the corresponding mpa stream. It's difficult to determine any constant scale factor, some times (depending on source clip) it looks like a random (probably depends on a number of PTS breakages?).

I've tried to use ProjectX to analyze the target HD mpg, it really shows PTS mix up, but after demuxing/repairing the thing gets even worse - even the final HD mpg is corrupted - it becomes 10 min. instead of 3 min., audio gets out of sync, etc. - I can do nothing with this video.

The thing I can't understand is why any s/w player keeps video in sync fine, but DGMPGDec (or even ffdshow via DirectShowSource() ) can't give me a correct synchronization. Hope someone can clarify this to me.

The question is, obviously, how to overcome this (PTS?) problem. Probably a software exist (or some projectX settings I'm not aware of), which can fix the stream according to PTS info?

PS. just to be clear - I really need the NLE, and I really need a smart rendering (my pc will just die if I start HD rerendering on it). I'm aware of mpeg2 editors (womble and video redo), not sure if they'll help and if they'll fit my editing needs. Still have to try.

--
Igor

Leak
15th July 2007, 19:26
The thing I can't understand is why any s/w player keeps video in sync fine, but DGMPGDec (or even ffdshow via DirectShowSource() ) can't give me a correct synchronization. Hope someone can clarify this to me.
Because player apps both send the audio and video data to the renderer *with* timestamps, which then makes sure the timestamps line up correctly while playing.

With DGMpgDec, you're just operating on the video part, and you're creating new timestamps for the video as frame 0 from an AviSynth script always starts at 0:00:00 - your encoder app never sees the original timestamps.

I bet if you use ffdshow's AviSynth filter to apply your script (without MPEG2Source, of course) on the fly to your video in a media player (available CPU permitting) you should get proper synchronization since ffdshow's AviSynth filter retains the original timestamps (modulo some interpolation and smoothing where neccessary) - you could actually try remuxing the result of that (original audio + re-encoded video, using ffdshow's DirectShow encoding filter to encode the result coming out of the ffdshow video decoder) in GraphEdit to get a properly synced file, but it's a bit of a hassle I guess...

Come to think of it, if your NLE supports DirectShow sources you could just use ffdshow for opening your HD source to apply the AviSynth script on the fly, then render that...

Also, drop the "last =" and "last" from your script or AssumeFrameBased won't have any effect.

np: The Orb - Ultraworld Ten - A Huge Evergrowing Pulsating Brain That Rules From The Centre Of The Ultraworld (Live Mix Mk 10) (Adventures Beyond The Ultraworld (Disc 2))

scharfis_brain
15th July 2007, 19:45
it is better to retain the video interlaced to preserve the motion smoothness:

MPEG2Source("Devil's Lake - Mountains [HDV].d2v")
bicubicresize(704,height)
yadif(mode=1)
bicubicresize(width,480)
assumetff()
separatefields().selectever(4,0,3).weave()

cail
17th July 2007, 03:46
I bet if you use ffdshow's AviSynth filter to apply your script (without MPEG2Source, of course) on the fly to your video in a media player (available CPU permitting) you should get proper synchronization since ffdshow's AviSynth filter retains the original timestamps (modulo some interpolation and smoothing where neccessary) - you could actually try remuxing the result of that (original audio + re-encoded video, using ffdshow's DirectShow encoding filter to encode the result coming out of the ffdshow video decoder) in GraphEdit to get a properly synced file, but it's a bit of a hassle I guess...

Probably this makes sence, what I've found is that using VirtualDub to open the same AVS script above, and encoding it with ffdshow to mpeg4 AVI, gives me much better results. I see only a minor audio length variations (2-3 sec on 10min. file) and I can fix this by stretching the audio.

At least for me this is the only workaround I've found for my workflow: most modern dvd players works fine with mpeg4, and this is what I need - good lowres version of my HD material.


Come to think of it, if your NLE supports DirectShow sources you could just use ffdshow for opening your HD source to apply the AviSynth script on the fly, then render that...

The point here is that I'll loose a smart rendering then. I don't want original HD m2t stream to be recompressed, but this is what'll happen.

Another way I'm now evaluating is using another NLE (Whomble), which seems to give me a correctly stamped HD mpeg2 on output. At least (for the sample test clip) no sync problems at all. This forces me to think that still, the real root cause is not AVS or ffdshow, but Ulead MSP NLE.



it is better to retain the video interlaced to preserve the motion smoothness:

Thanks, probably you are right, but I'm still trying to evaluate if progressive is better or not, because the prevailing SD video playback device will be PC (and just sometimes TV DVD player).
BTW, why your script makes 704x480, not 720?

Leak
17th July 2007, 08:37
The point here is that I'll loose a smart rendering then. I don't want original HD m2t stream to be recompressed, but this is what'll happen.
Wait a second - I thought the idea was to re-encode your video at a lower resolution?

When you do what I said above you're using ffdshow to decompress your HD video, then immediately apply the AviSynth script to resize it and present the uncompressed video to your NLE - I can't see how that is going to change anything vs. just decompressing your video...

cail
17th July 2007, 19:39
Wait a second - I thought the idea was to re-encode your video at a lower resolution?

Yep, sorry, I did not get your point correctly.


When you do what I said above you're using ffdshow to decompress your HD video, then immediately apply the AviSynth script to resize it and present the uncompressed video to your NLE - I can't see how that is going to change anything vs. just decompressing your video...
Still, at this point I don't need NLE at all. All I need is to reencode already edited and rendered HD mpg to SD mpg/avi.
I don't need to edit that 'AviSynth'-ed video in NLE - it is already edited.
The best point for me would be to use quEnc or other mpeg2 encoder against AVS file - but it doesn't work either via d2v or via ffdshow sources.

VirtualDub performs better (via d2v), but I'm forced to do smthng like this for each clip:

input = MPEG2Source("Devil's Lake - Mountains [HDV].d2v")
input = AudioDub(input, DirectShowSource("Devil's Lake - Mountains [SD].mp2"))
input.ConvertToYUY2.SeparateFields.SelectEvery(2,1).LanczosResize(720, 480)
## tune up audio sampling rate to sync it up manually with video.
ResampleAudio(47880)
AssumeSampleRate(48000)

That's odd, but at least it works for me.

Again, I don't see this problem now with HD mpg output from other NLE (Womble) - so think this is up to 'great' HD support in ulead MSP. And this is for the another thread discussion.