actionman133
29th December 2004, 12:27
Hi all,
I'm currently working on a script that will restore films to the full frames from the ones that are blended on NTSC VCD's. AFAIK, there is no dedicated filter for this, and I felt like challenging myself too.
The script works with the principle that for every 4 film frames (alphabetically), they are distributed across 5 film frames (numerically) like so:
VCD frame 1 2 3 4 5
Film frame aa bb bc cd dd
Frame 3 is a 50:50 blend of frames b and c. So we get frame 2 (which is wholely frame b), 'reduce it' by 50% (with levels), and subtract it from frame 3. This leaves us with a 50% frame c. Repeat the process with frame 4, to get another 50% frame c. Blend those two versions of frame c together and you get the restored frame c. Frames a, b and d pass through unchanged.
While the script that I have developed works very well on my perfect test footage, I am aware that the blending order does change in many VCD's, usually on cuts to different angles.
Here is my code at the moment. Feel free to post possible improvements. Right now, I am concerned with technical quality; cleaning the video can be done with other filters.
Function NTSC_VCD_DeBlend (clip Last) {
First = SelectEvery (5, 0)
Second = SelectEvery (5, 1) # Get the full frames to pass through
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)
Third = Overlay (Third1, Third2, mode = "blend", opacity = 0.5) # Extract the third frame from both blends, then combine.
Interleave (First, Second, Third, Fourth) # Re-integrate the restore frame with the orignal frames
}
What I am looking for is something to help detect where the blended frames are, since right now it just assumes the 3rd and 4th frames are blended.
I think I remember once upon a time about a filter that does detect blended frames and makes the frame numbers available, but I can't remember what it is and I don't remember where I looked.
Can anyone help?
I'm currently working on a script that will restore films to the full frames from the ones that are blended on NTSC VCD's. AFAIK, there is no dedicated filter for this, and I felt like challenging myself too.
The script works with the principle that for every 4 film frames (alphabetically), they are distributed across 5 film frames (numerically) like so:
VCD frame 1 2 3 4 5
Film frame aa bb bc cd dd
Frame 3 is a 50:50 blend of frames b and c. So we get frame 2 (which is wholely frame b), 'reduce it' by 50% (with levels), and subtract it from frame 3. This leaves us with a 50% frame c. Repeat the process with frame 4, to get another 50% frame c. Blend those two versions of frame c together and you get the restored frame c. Frames a, b and d pass through unchanged.
While the script that I have developed works very well on my perfect test footage, I am aware that the blending order does change in many VCD's, usually on cuts to different angles.
Here is my code at the moment. Feel free to post possible improvements. Right now, I am concerned with technical quality; cleaning the video can be done with other filters.
Function NTSC_VCD_DeBlend (clip Last) {
First = SelectEvery (5, 0)
Second = SelectEvery (5, 1) # Get the full frames to pass through
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)
Third = Overlay (Third1, Third2, mode = "blend", opacity = 0.5) # Extract the third frame from both blends, then combine.
Interleave (First, Second, Third, Fourth) # Re-integrate the restore frame with the orignal frames
}
What I am looking for is something to help detect where the blended frames are, since right now it just assumes the 3rd and 4th frames are blended.
I think I remember once upon a time about a filter that does detect blended frames and makes the frame numbers available, but I can't remember what it is and I don't remember where I looked.
Can anyone help?