View Full Version : Standalone tool to find black scenes in videos?
Chetwood
16th September 2014, 07:02
Didn't know where to put this so please move if necessary. Some time ago when I was ripping my Lost DVDs to my NAS I had some issues with out of sync subs. I had to manually adjust some scenes usually after the commercial break which on DVDs is still present as (up to) several seconds of black screen. I was wondering, is there some tool to scan a video file and report such scenes?
johnmeyer
16th September 2014, 08:33
The following is a very simple script that I use all the time. If you have frames that are truly blank, then it should work just fine. This script simply outputs a text file with the frame numbers of your blank frames. If you have several blank frames in a row, the script will only output the frame number of the first blank frame. I designed it that way because I was trying to find the beginning of commercial breaks in video captured from OTA broadcasts.
If you need something more sophisticated, the amazing suite of functions in the RT_Stats package will let you do even more.
If you are looking for an actual program to use, rather than an AVISynth script, VideoRedo has a commercial finder that basically looks for blank frames and inserts cut points at those locations.
#Script to find blank frames
#Specify the name and location of the output file
filename = "e:\output_blank_frames.txt"
global blankthreshold=25
AVISource("E:\myvideo.avi").killaudio()
#Get rid of the borders, which on analog captures can have all sorts of
#black garbage that can affect the averageluma value
#Crop(16,16,-16,-16)
# Use the following to reduce the number of fields by 50% in order to speed processing
separatefields.selectodd
i=AssumeTFF
j=trim(i,1,0) #Previous frame
# Temporarily un-comment next line to display the average luma value on screen to help determine threshold value
#ScriptClip(i,"Subtitle(String(AverageLuma(i) ))" )
This is the line that actually writes the frame number of the FIRST frame that falls below the threshold
WriteFileIf(last, filename, "(AverageLuma(i)<blankthreshold)&&AverageLuma(j)>blankthreshold", "current_frame+1", append = false)
#The line below finds the LAST blank frame.
#WriteFileIf(last, filename, "(AverageLuma(i)>blankthreshold)&&AverageLuma(j)<blankthreshold", "current_frame+1", append = false)
fvisagie
16th September 2014, 10:45
VirtualDub may also be worth looking into. From what you say it isn't clear to me exactly how you want the information reported and what you intend doing with it, but VirtualDub's scene change detection is at least quite accurate, as well as adjustable.
Chetwood
17th September 2014, 07:08
A text file with the times where such a few second black scene starts would be fine. Gonna try your suggestions.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.