Home
RecentChanges

Search:

» AviSynth is a powerful video FrameServer for Win32.

AviSynth Links:
»Download
»Learn to script
»FAQ
»Manual
»Discussion fora
»Project page
»External filters
»FeedBack

» You can add pages to this website immediately. No login required.
Edit this document

» AboutAviSynth

 

Avisynth 
Logo

RemovingBlendedFilmFramesOnVcds

If anyone who owns films on NTSC VCD's and has a done a frame by frame playback, it can be easily seen that two consecutive frames out of every five frames are blended with adjacent frames. This is done to match the speed of film to NTSC video. Film plays at 24 frames per second, while video plays at 30 frames per second. To match the speeds, one new film frame must be added to every four existing frames. The process is similar, although simpler, than telecine, so if you want to understand how the blending procedure is undertaken, search for 'telecine'. The difference is instead of interlaced frames, you have blended frames. If you want to recover the original frames, problems arise, because one doesn't exist.

Here is an example: the VCD film frames will be listed as numbers, and the corresponding 'film' frames will be listed as letters. Where letters are doubled up, that means the frame is complete.

VCD Frames     1    2    3    4    5
Film Frames    aa   bb   bc   cd   dd

Frames a, b and d are kept in their entirety. But frame c is not. It is blended into 2 different frames, but there is no independent copy. So it must be recovered digitally.

This is how it's done. Frame 3 consists of an even blend of frames b and c. Since we have a complete version of frame b, we can 'subtract' that image from the blended frame, leaving behind frame c. Frame b has to be reduced to 50% effectiveness in the subtraction, because only 50% of frame 3 is frame b, the other 50% is frame c. Likewise, frame 4, consisting of frames c and d, can subtract frame d (which is complete in frame 5) to leave behind a second version of frame c.

This redundancy is not entirely necessary, however it is recommended because video compression noise affects the restore frames appearance. By combining the two restorations, the majority of video noise is hidden.

So here is the code:

Function DeBlend (clip Last) {

	First = SelectEvery (5, 0)
	Second = SelectEvery (5, 1)     # Frames a, b and d get passed through untouched.
	Fourth = SelectEvery (5, 4)

	Third1 = Subtract (SelectEvery (5, 2), Second.Levels (0, 1, 255, 128, 255)).Levels (0, 1, 127, 0, 255)
	Third2 = Subtract (SelectEvery (5, 3), Fourth.Levels (0, 1, 255, 128, 255)).Levels (0, 1, 127, 0, 255)

# Recovering frame c from the blends by subtraction. Note that the first Levels' halfs the range of frames b and d.
# The second Levels' boosts each restoration of frame c from 50% value to 100%.

	Third = Overlay (Third1, Third2, mode = "blend", opacity = 0.5)    # Blend the two versions of frame c together to get the most accurate restoration

	Interleave (First, Second, Third, Fourth)   # Re-integrate the restored frame into the other frames.

}

This code is effective, but not perfect. It does not perform noise reduction - other than the simplistic and not very effective blending of the different versions of the frames - nor can it detect which frames are blended. It assumes the 3rd and 4th frames out of every 5 are blended, but many poorly mastered VCD's break this pattern, in which case, this function is useless.

If anyone can add some sort of detection code to determine which frames are blended and then apply this code,that would be great.

Thanks!

SourceForge Logo

 


Edit this document | View document history
Document last modified Wed, 29 Dec 2004 07:52:27