Log in

View Full Version : Looking for a script that can find blocky frames


jkilez
27th May 2014, 18:15
Many HDTV captures that I have often have a number of bad sections where the picture becomes blocky for just a frame or two before returning to normal. These dropouts are tolerable when watching live TV, but when rewatching, it can be distracting. Since I am starting the process of converting my captured MPEG streams to smaller x264 files, I would like to fix those glitches at the same time. I could fix them easily enough if I knew where they were.

What makes this difficult is that the captures are mostly pristine. There may only be one or two instances of blockiness in an hour of video (or there may be none). It is a task that is mind-numbing and arduous when done by a human, but hopefully it can be done simply by script. There are any number of scripts or plug-ins that will simply deblock, but that is not what I am seeking. I would like something that generates a file of frame numbers that I could use to locate and fix problem areas manually.

Has this been done somewhere already?

StainlessS
27th May 2014, 21:42
I asked similar question some time ago, did not get any answer, I think.

Suggest maybe change thread title from "bad" to "blocky" frames.

jkilez
27th May 2014, 22:53
Thread title has been updated per StainlessS's suggestion. At least now I know I that I did not overlook some obvious solution.

At this point I can create a log file, but I am missing the logic on how to determine the blockiness of the frame. One idea I had was to apply a heavy deblocker to a copy of the frame and compare it to the original. If the two varied substantially, I could record the frame number. This would use duplicate frame check logic, but in reverse.

AzraelNewtype
29th May 2014, 21:40
This is going to sound like a strange idea, but when I have captures of a particular show that is primarily progressive with some occasional combed bits, I run a good old writefileif(IsCombedTIVTC()) to find the spots to hit manually. Sometimes these areas are just combed, but other times the algorithm is tripping on heavy blocking. In fact all instances of particularly bad blocking show up as combed.

Obviously, if your source is completely interlaced this will do nothing for you, and if it's a telecine you'll probably want to ivtc first with as little post processing as possible, but it could be worth a shot.

jkilez
30th May 2014, 00:32
I run a good old writefileif(IsCombedTIVTC()) to find the spots to hit manually. Sometimes these areas are just combed, but other times the algorithm is tripping on heavy blocking. In fact all instances of particularly bad blocking show up as combed.
Thanks for the pointer. I am going to play around with the parameters to IsCombedTIVTC() to see if I can get it to pick up the blocking. If so, this would make a great solution.

jkilez
30th May 2014, 19:28
I have been playing with IsCombedTIVTC() to detect the flawed frames, but by default, it gives many false positives. I have also not been able to use the function outside of "WriteFileIf()" or "ConditionalFilter()". Any use outside of those two functions just gives an "invalid parameters" error. Is this normal?

In searching further for solutions, I came across this thread: Script for fixing corrupted frames (http://forum.doom9.org/showthread.php?t=158677). The script it discusses is attacking (more or less) the same problem I am experiencing.

StainlessS
30th May 2014, 23:05
IsCombedTIVTC() is a runtime function and has to be used in runtime environment.

http://avisynth.nl/index.php/Internal_functions/Runtime_functions

http://avisynth.nl/index.php/The_script_execution_model/Evaluation_of_runtime_scripts

EDIT:
You could use it something like this:

# Requires RT_Stats : http://forum.doom9.org/showthread.php?t=165479

Report="Report.Txt"

AviSource("D:\avs\Test.avi")

Exist(Report) ? RT_FileDelete(Report) : NOP

ScriptClip("""
IsC = IsCombedTIVTC()
(IsC) ? RT_TxtWriteFile(String(current_frame),Report,append=True) : NOP
RT_Subtitle( (IsC) ? "Two Legs Bad" : "Four Legs Good" )
return Last
""")


EDIT: You dont need RT_Stats if you dont use the three RT funcs.

EDIT: Here another script that writes a file of combed frames, and optionally deinterlaces them (of course you want to deblock instead).
http://forum.doom9.org/showthread.php?p=1666918&highlight=IsCombedTIVTC#post1666918