Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
3rd March 2009, 05:44 | #1 | Link |
Registered User
Join Date: Apr 2008
Posts: 3
|
Getting results from compare
I am trying to find a frame that match an other video using compare(). The problem seems to be that the returned value of compare is a frame, but I would need value...
Ex : psnr = compare(video, frame) if psnr > 40 then "I don't know yet". This is the be able to align to video on the same frame without having to do it manually. Maybe I'm just on the wrong track, any pointers would help. Thanks. |
8th March 2009, 18:24 | #2 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,433
|
I'm not aware of a function that returns the PSNR. However, here's a way of doing basically what you ask:
Code:
# given a clip 'c' and a (potentially one-frame) clip 'f', # show 'c' starting at frame matching (1st frame of) 'f'. function findFrame(clip c, clip f, int "thresh") { thresh = Default(thresh, 2) # threshold for declaring match f = f.Loop(c.FrameCount, 0, 0) n = findFrame2(c, f, thresh, 0) return c.Trim(n, 0) } # recursive auxiliary function called by findFrame function findFrame2(clip c, clip f, int thresh, int current_frame) { current_frame >= c.FrameCount-1 || LumaDifference(c, f) <= thresh ? \ current_frame : \ findFrame2(c, f, thresh, current_frame+1) } # contrived example for testing: c = AviSource("myVid.avi").ShowFrameNumber() f = c.Trim(30, -1) #select frame 30 findFrame(c, f) # should show starting at frame 30 The threshold parameter can be amended to suit how close a match you have or require. If no match is found, the last frame will be shown. |
Thread Tools | Search this Thread |
Display Modes | |
|
|