soreepeong
13th December 2016, 16:19
I am trying to perform IVTC of an anime from VHS. The source usually has a fixed pattern, but occasionally a long sequence of interlaced frames appear.
My assumption is that for a telecined video, for each interlaced continuous sequence, one frame has to be a duplicate and should be dropped. That seems to be working so far, but detecting if a frame is interlaced or not happens to be more difficult than I thought.
One of the troubling frame is:
http://i.imgur.com/gftRwC0.png
It is a combed frame, but only IsCombedTIVTC(3) and IsCombed(22) would report that it is, which is way too sensitive. I found that it is usually combed when c_above is above ~250 from ShowCombedIVTC(9), but the value is not exported to AviSynth, and even if I modify the source by adding env->Set(Global)Var into ShowCombedTIVTC::GetFrame, when I try to use the value, it always reports a value for a previous frame.
List of questions:
Is there any good way to determine if a frame of an anime is combed or not? These are example frames: https://imgur.com/a/fmntK
Is there a script for IVTC that will work on this sample? https://www.mediafire.com/?t9vxjn1zypvyihq
It starts with and often has a steady IVTC pattern, but some parts are plain interlaced or progressive more than 5 consecutive frames.
Frame 251 ~ 400 are especially messy: when I just bob that part, for consecutive 5+ frames, the resulting 10 frames are all different.
How do I extract values printed in ShowCombedIVTC()
If I have to modify the plugin source code, which part should I modify?
Is there a way to stabilize a video from VHS source horizontally when some frames are combed, so that IsCombed(TIVTC) doesn't report a frame as combed even when they're in sensitive mode?
Does the idea written below make sense?
Current work: http://pastebin.com/Txgv6b5C (AviSynth script) and http://pastebin.com/aUzKTvdj (output processor coded in PHP)
It only works for converting 30000/1001 fps content into 24000/1001~30000/1001 fps (vfr).
What does it do:
"FieldDetect"
Find which frame is interlaced and determine its parity if it's the first frame of each interlaced sequence, and save it to file "out.txt"
"process.php 1"
Create a deinterlace strategy using "out.txt" and in PHP file, and save the file to "in.txt"
"PrepareDecimation"
Determine how similar is each frame to its previous frame after deinterlace using "in.txt" and save it to another file "in2.txt"
"process.php 2"
Determine which frame to drop and correct timing, assuming:
(1) at most 1 frame is dropped in 5 frames even when all 5 frames are not interlaced
(2) if there is a sequence of continuously interlaced frames, always drop 1 frame
and finally re-time the frames if at least 1 frame is dropped in every 5 frames
If the original sequence was (a b:dropped c d e f) and b-a=c-b=d-c=e-d=f-e, then assign c, d, e new values so that f-e=e-d=d-c=c-a
Save the frames to delete in "df.txt" and timecode v2 into "timecodes.txt"
"Use, DeleteFrame"
copy the content in "df.txt" into the script and encode
Any help will be appreciated!
My assumption is that for a telecined video, for each interlaced continuous sequence, one frame has to be a duplicate and should be dropped. That seems to be working so far, but detecting if a frame is interlaced or not happens to be more difficult than I thought.
One of the troubling frame is:
http://i.imgur.com/gftRwC0.png
It is a combed frame, but only IsCombedTIVTC(3) and IsCombed(22) would report that it is, which is way too sensitive. I found that it is usually combed when c_above is above ~250 from ShowCombedIVTC(9), but the value is not exported to AviSynth, and even if I modify the source by adding env->Set(Global)Var into ShowCombedTIVTC::GetFrame, when I try to use the value, it always reports a value for a previous frame.
List of questions:
Is there any good way to determine if a frame of an anime is combed or not? These are example frames: https://imgur.com/a/fmntK
Is there a script for IVTC that will work on this sample? https://www.mediafire.com/?t9vxjn1zypvyihq
It starts with and often has a steady IVTC pattern, but some parts are plain interlaced or progressive more than 5 consecutive frames.
Frame 251 ~ 400 are especially messy: when I just bob that part, for consecutive 5+ frames, the resulting 10 frames are all different.
How do I extract values printed in ShowCombedIVTC()
If I have to modify the plugin source code, which part should I modify?
Is there a way to stabilize a video from VHS source horizontally when some frames are combed, so that IsCombed(TIVTC) doesn't report a frame as combed even when they're in sensitive mode?
Does the idea written below make sense?
Current work: http://pastebin.com/Txgv6b5C (AviSynth script) and http://pastebin.com/aUzKTvdj (output processor coded in PHP)
It only works for converting 30000/1001 fps content into 24000/1001~30000/1001 fps (vfr).
What does it do:
"FieldDetect"
Find which frame is interlaced and determine its parity if it's the first frame of each interlaced sequence, and save it to file "out.txt"
"process.php 1"
Create a deinterlace strategy using "out.txt" and in PHP file, and save the file to "in.txt"
"PrepareDecimation"
Determine how similar is each frame to its previous frame after deinterlace using "in.txt" and save it to another file "in2.txt"
"process.php 2"
Determine which frame to drop and correct timing, assuming:
(1) at most 1 frame is dropped in 5 frames even when all 5 frames are not interlaced
(2) if there is a sequence of continuously interlaced frames, always drop 1 frame
and finally re-time the frames if at least 1 frame is dropped in every 5 frames
If the original sequence was (a b:dropped c d e f) and b-a=c-b=d-c=e-d=f-e, then assign c, d, e new values so that f-e=e-d=d-c=c-a
Save the frames to delete in "df.txt" and timecode v2 into "timecodes.txt"
"Use, DeleteFrame"
copy the content in "df.txt" into the script and encode
Any help will be appreciated!