Log in

View Full Version : removing black frames before and after a clip


patrick_cgn
2nd November 2006, 16:44
Hi all,

I have a lot of AVI Files with black frames before and after the content. Instead of trimming them by entering the frame numbers manually I'm trying to write a script which does this automaticaly (returning only non-black frames).

The detection of black frames itself is quite easy, ConditionalFilter(video, Subtitle(video, "BLACK!!!"), video, "AverageLuma()", "lessthan", "20") does it fine. But I want to remove them instead of only detecting them. So I've been trying for hours with FrameEvaluate() - without success :-(

Please help.

Best, Patrick

stickboy
2nd November 2006, 18:00
FrameEvaluate and ScriptClip can't do anything that changes the frame count.

You might be better off outputting the detected frames to a text file and then building a script that calls Trim and AlignedSplice (++) appropriately.

patrick_cgn
3rd November 2006, 16:35
thanks for the hint! I managed to write the frame numbers to a text file. The algorithm for finding the wanted start and endframes is more complex than expected, I'm happy that I don't have to implement all of this in Avisynth now as PHP is a bit more comfortable ;-)

dream-lx
3rd November 2006, 21:53
It would be nice if you could post your script to write the frame numbers of black frames to a text file. I can imagine that more than one people would be interested in this.

Thanks in advance
Bye,
David Arendt

patrick_cgn
8th November 2006, 12:03
Here it comes...

video = DirectShowSource("video.avi")
WriteFileIf(video, "d:\temp\frames.txt", "(AverageLuma < 30)", "current_frame", """ ":" """, "AverageLuma")