Log in

View Full Version : detect if a source is interlaced


hanfrunz
17th July 2012, 09:59
Hello everyone,

i am developing a little script for mp4 encoding. I try to find a way to detect if a source is interlaced or not and store this info in a textfile. I don't want to rely on a flag in the source file.
I found the "Interlace detection" (http://avisynth.org/mediawiki/Interlace_detection) article in the wiki, but the output is to much in my case. I just need a "interlaced" or "progressive" (i know it can be hybrid too, but let's assume it won't be :) ) So any idea how i could get my info?
Is there a commandline tool? Or can the script be altered?

regards,
hanfrunz

StainlessS
17th July 2012, 15:43
I will be doing a little work in this area and any algo's etc posted would be appreciated.
Same for telecine detection and field order detection, all would be appreciated.

librarian
17th July 2012, 16:17
I ... and field order detection, all would be appreciated.

Have you already seen http://forum.doom9.org/archive/index.php/t-34511.html?

StainlessS
17th July 2012, 16:58
Thankyou, snapped both pages.
Not doing it just yet, but want to make a prescan detector to provide info to script,
for eg, autocrop, field order/interlace/telecine and return maybe some kind of string
(multiple reply stats) that would need be parsed via script (OR/ MAYBE, reply via global
vars). Intent for auto conversion/ eg mpg to mp4, via MeGUI.
Currently implementing (almost there) a suite of runtime filters similar to eg AverageLuma,
YDifferenceFromPrevious , LumaDifference, where for say YDifference/Previous/Next version,
the framenum is optional default to current_frame so eg current_frame-1 is possible, also a
delta arg for frame to compare, relative whatever the primary frame is (eg primary =current_frame-1,
and delta = 2, compares either side of current_frame) and compare area x,y,w,h as in crop, with a
relative x/y offset for the secondary frame (which actually could be the same frame as the primary frame),
and lastly, an interlaced compare, only alternate fields (remember the secondary offset).
Consider also exactly the same sort of possiblilites if applied to an alternate version of LumaDifference (two clips),
eg matching clips, frame dropouts etc. Could be quite handy tool.
Anyway, once I've got it working, It will provide a handy instrument for exploring field order etc.
(But I think I've gotta get some sleep now really, I'm knackered).
More suggestions welcome.

EDIT: The LumaDifference (two clips) version would have primary frame n and primary delta,
the second clips a secondary n2 and secondary delta2, so if eg frame matching for dropouts,
the n and n2 could be used as anchor points and use delta and delta2 offsets for exploration.
when a match is found the n and n2 could be updated as they march through both streams.

Wilbert
17th July 2012, 18:12
See Advanced conditional filtering: part II (http://avisynth.org/mediawiki/ConditionalFilter) for the use of IsCombed.

librarian
18th July 2012, 09:39
Tested with good results the function Interlacing2Reader by Momonster, included in the old package R-pack. For me it fails only on detection of "Europulldown" generated with this script

assumetff()
SeparateFields()
SelectEvery(48, 0,1, 2,3, 4,5, 6,7, 8,9, 10,11, 12,13, 14,15, 16,17, 18,19, 20,21, 22,23, \
22,25, 24,27, 26,29, 28,31, 30,33, 32,35, 34,37, 36,39, 38,41, 40,43, 42,45, 44,47, 46,47)
Weave
but maybe it's my fault.