PDA

View Full Version : Frames NOT the same!


drakend
9th January 2007, 15:26
Hi people,
I'm trying my first encodings using filters and the results are generally very nice, but I encountered an unexcepted problem: the frames of the source video aren't the same of the target video. I mean, for example, frame number 12500 of source video ISN'T the same as the frame 12500 of the target video, it is 12502 or 12503, and this is for all the the frames of course.
This causes some disynchronization between video and audio as well.
I used this script:

LoadPlugin("c:\Programmi\Avisynth 2.5\Plugins\Decomb.dll")
LoadPlugin("c:\Programmi\Avisynth 2.5\Plugins\Fluxsmooth.dll")
LoadPlugin("c:\Programmi\Avisynth 2.5\Plugins\Undot.dll")
LoadPlugin("c:\Programmi\Avisynth 2.5\Plugins\Dgdecode.dll")
LoadPlugin("c:\Programmi\Avisynth 2.5\Plugins\Convolution3d.dll")
LoadPlugin("c:\Programmi\Avisynth 2.5\Plugins\Unfilter.dll")
LoadPlugin("c:\Programmi\Avisynth 2.5\Plugins\Deblock.dll")
Import("c:\Programmi\Avisynth 2.5\Plugins\LimitedSharpenFaster.avsi")

DirectShowSource("video.avi")
Crop(0,0,512,380)
LanczosResize(512,384)
Deblock(15,15,15)
Convolution3d (preset="animeLQ")
LimitedSharpenFaster(strength=150)
Unfilter(-7,-7)
Undot()
Limiter()
ConvertTOYV12()

I use DirectShowSource on an avi file because AviSource returns me an error (the height isn't mod2) whereas DirectShowSource doesn't.

I used this script to encode the avi file to an mp4 h264 file with two passes at a target bitrate of 500 Kbps.
The really strange thing is that the frames are the same between the source avi file and the avisynth preview (checked in VirtualDubMod), while they are different between the source avi file and the target mp4 file (opened through another avs script in VirtualDubMod).
How can I solve this problem?

Zarxrax
9th January 2007, 17:36
Well to start, directshowsource isn't perfectly frame-accurate if you seek around. Next, if your source has b-frames, I believe this could cause the difference, if you are viewing the source and output in different ways. I mean, if you are viewing the source video through a video for windows decoder, while the avisynth is going through directshow, I believe that may cause them both to be off by a few frames.

Maybe I'm wrong about that though, in case I hope someone corrects me.

drakend
9th January 2007, 18:17
Yes and how can I solve the problem? I mean this problem creates some desyncronization between audio and video... not much but it's present. :(

IanB
10th January 2007, 08:35
Cheapest workaround is to use the Seek=False option of DirectShowSource() to stop any seeking backwards in the AV streams, and add a SetMemoryMax(256) or more to allocate a generous cache to (hopefully) cover any small range back seeking that is happening.

Better solution is to transcode the video to a lossless version, like huffyuv, in a single pass without an complex filtering, then process the lossless copy. You will need a generous amount of temporary disk space.

Also Crop(0,0,512,380).LanczosResize(512,384), i.e. resize up 4 pixels, is a little iffy. It is usually better to just add a 2 pixel border top and bottom and leave the video unmolested.

Have a look for BorderControl from Si Walters if hard borders is not your thing.