Log in

View Full Version : conditional choice of frame from 2 streams


FredThompson
8th July 2003, 23:40
I'm looking for a way to conditionally choose frames from one of two streams based on scene change detection. It doesn't have to be absolutely perfect.

Here's the thought:

Starting with a raw source stream, establish a second stream through a filter.

A test is done such that frame X comes from the filtered stream unless a test of frame X+n shows a scene change. This allows a way to reduce the unwanted effects of temporal smoothing across scene changes.

If Donald Graft's Dup is modified such that it would, if instructed, return only a boolean for change detection given the frames X and X+n, this would be fairly easy from a user standpoint. The regular Dup functionality could be used to tune configuration for a given source.

Construction of the output stream would, essentially, be choosing frames from either input stream based on the state switch of the boolean.

Questions:

1) Is there a filter which provides scene change detection for a specified frame and returns a boolean?

2) If so, how would a stream be constructed from two source streams?

FredThompson
9th July 2003, 01:22
ok, I've tracked this issue down to the ConditionalFilter. From this page:

http://www.avisynth.org/index.php?page=ConditionalFilter

There is an example in the middle of the page:
Example (this will replace the last frame before a scenechange with the first frame after the scenechange):

ConditionalFilter(last, last, last.trim(1,0), "YDifferenceToNext()", ">", "10", true)That's pretty close to what I'm looking for. The only difference is I want to replace the last frame before the scene change with the source frame. That particular frame won't have the temporal filter but at least it should be sharper.

If there's a way to use temporalsoften such that the source frame isn't affected by the scene change frame, that would be cool. Hope that makes sense.

FWIW, here's the filter I'm trying to modify:

ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= 2 ? \
unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

bilu
9th July 2003, 01:39
The frame_number variable may help.

http://forum.doom9.org/showthread.php?s=&postid=332378#post332378


Bilu

FredThompson
9th July 2003, 02:05
Yeah, it might, thanks.

The filter I've shown above will work on an entire stream. The only thing it's doing which I/d like to change is how it processes the final frame before a scene change.

Thanks, I'll do some more research.

Wilbert
9th July 2003, 09:27
It's difficult to help you, without trying myself. But does something like this work:

clip_u = [unfiltered clip]
cilp_f = [filtered clip]
ConditionalFilter(clip_u, clip_f, clip_u, "YDifferenceToNext()", ">", "10", true)

edit: corrected small mistake

FredThompson
9th July 2003, 18:49
That's what I was thinking lately.

Leave the current algorithm alone because it filters quite well. Use another ConditionalFilter to chose between its stream or the original.

I'd started with bilu's idea then realized what a style mistake I'd made by planning to alter the filter.

Thanks for the feedback.