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. |
![]() |
#1 | Link |
Registered User
Join Date: Apr 2012
Posts: 7
|
detecting black frames
I found a script that detects black frames in a video file. I created a test video with black frames. I opened this script in VirtualDubMod, it loads the video but there is no report text file with detected black frames. I am a professional editor but a TOTAL Avisynth noob. There must be something I am doing wrong. Below is the script I am using.
#Specify the name and location of the output file filename = "c:\output_blank_frames.txt" #Specify the threshold that will be considered black (0 = pure black) global blankthreshold=28 #DirectShowSource("black_frames_av2i.avi").killaudio() AVISource("black_frames_test.avi").killaudio() #Only look at half the fields (speeds up processing i=separatefields.selectodd.ConvertToYV12() #Write the frame number WriteFileIf(last, filename, "(AverageLuma(i)<blankthreshold)", "current_frame+1", append = false) thanks for help |
![]() |
![]() |
![]() |
#2 | Link | ||
Registered User
Join Date: Nov 2011
Posts: 63
|
Quote:
Quote:
|
||
![]() |
![]() |
![]() |
#3 | Link |
Registered User
Join Date: Apr 2012
Posts: 7
|
I added "global" before "filename" and added "i." before "writefileif" but I get a message:
Script error: Invalid arguments to function "WriteFileIf" If I delete "i.", I don't get any message but there is no output text file too. |
![]() |
![]() |
![]() |
#4 | Link | |
Registered User
Join Date: Nov 2011
Posts: 63
|
Quote:
i.WriteFileIf( filename, "(AverageLuma(i)<blankthreshold)", "current_frame+1", append = false) not: i.WriteFileIf(last, filename, "(AverageLuma(i)<blankthreshold)", "current_frame+1", append = false) just like I posted above. |
|
![]() |
![]() |
![]() |
#5 | Link |
Registered User
Join Date: Apr 2012
Posts: 7
|
decompressor
Now I got a message like this:
[!] Couldn't locate decompressor for format 'YV12' (unknown). VirtualDub requires a Video for Windows (VFW) compatible codec to decompress video. DirectShow codecs, such as those used by Windows Media Player, are not suitable. Only 'Direct stream copy' is available for this video. I tried this with DV avi and uncompressed avi, same answer. Where to download best codecs for Avisynth? |
![]() |
![]() |
![]() |
#8 | Link |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,738
|
Here's a script I use all the time. I'm sure you'll need to modify it, but perhaps it will get you started.
You'll note that I wrote the script to only output the first frame that falls below a given luma threshold. The reason for this is that there are lots of situations where a video will go to black for many frames (like between commercials), and with my editing workflow I only need to know where the blank/black series of frames starts. The script below has a line that is commented out that will give you every frame that falls below the blank luma threshold. Code:
#Script to find blank frames #The script outputs the frame number of the first frame that falls below #the threshold luma value. #Specify the name and location of the output file filename = "m:\output_blank_frames.txt" #Specify the blank threshold. Set to zero for pure black. global blankthreshold=49 #Specify the name and location of your video file AVISource("E:\fs.avi").killaudio().ConvertToYV12 #Optional: For analog captures, get rid of the borders. # Analog video can have border garbage that affects averageluma Crop(16,16,-16,-16) # Use the following to reduce the number of fields by 50% in order to speed processing separatefields.selectodd i=last j=trim(i,1,0) #Previous frame [edit] Actually, it is the NEXT 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 line below will output EVERY frame that is below threshold, which results in LOTS of frames #Normally you don't do this, but it is included for those who want this capability. #WriteFileIf(last, filename, "(AverageLuma(i)<blankthreshold)", "current_frame+1", append = false) #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) Last edited by johnmeyer; 12th March 2013 at 18:02. Reason: Fixed incorrect comment next to the trim(1,0) statement |
![]() |
![]() |
![]() |
#9 | Link |
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
|
Try this: Run your script from the first post (which works perfectly fine and creates the file with the frames numbers) through AVSMeter.
__________________
Groucho's Avisynth Stuff |
![]() |
![]() |
![]() |
#10 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
as an alternative, you might also find that using silence detection on the audio gets you something usable in less time.
both would be nice of course... i have an EDL generating script that finds hard cuts if you need that. very good for splitting up a tape capture into shots that can be graded in an app that supports CMX format EDLs.
__________________
sucking the life out of your videos since 2004 |
![]() |
![]() |
![]() |
#11 | Link |
Registered User
Join Date: Apr 2012
Posts: 7
|
open failure
I am a pro editor but a total avisynth noob, although I think avisynth is a great tool that could help me in my everydays work, that's why I am not giving up!
When I try to work with a DV AVI I get the message: Avisynth open failure: Avisource: couldn't locate a decompressor for fourdcc dvsd when I try uncompressed avi I get: Couldn't locate decompressor for format YV12 (uknown). VirtualDub requires a Video for Windows (VFW) compatible codec to decompress video. DirectShow codecs, such as those used by Windows Media Player, are not suitable. Only 'Direct stream copy' is available for this video. |
![]() |
![]() |
![]() |
#13 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,111
|
It is perhaps likely that you will in future encounter further problems without a YV12 decoder, see here if you do:
http://forum.doom9.org/showthread.ph...ght=helix+yv12
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
#17 | Link | |
typo lover
Join Date: May 2009
Posts: 595
|
Quote:
Code:
#detect_silence.avs LoadPlugin("ffms2.dll") LoadPlugin("MinMaxAudio.dll") src = "file path to the source" aud = FFAudioSource(src) vid = BlankClip(FFVideoSource(src), width=32, height=32) AudioDub(vid, aud) #assume max is lesser than -100db as silence frame WriteFileIf("silence.log", "AudioMax(0) < -100", "current_frame") > avs2pipemod -benchmark detect_silence.avs
__________________
my repositories Last edited by Chikuzen; 12th March 2013 at 21:05. |
|
![]() |
![]() |
![]() |
#18 | Link |
Registered User
Join Date: Sep 2012
Posts: 12
|
Love the "find silence" script, but now how could I make it write out just the first and/or last frames where there is silence?
following johnmayer's example... I would make i the last frame and j the previous frame, Then create another && condition and put the "i" and "j" into AudioMax? Somehow I fear that wouldn't work, would it? What is the "0" in AudioMax(0) ? Thanks |
![]() |
![]() |
![]() |
#19 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,111
|
Generally the best place to find such info is in the documentation:
Code:
Conditional Audio Filters - MinMaxAudio v0.2 Usage: Computes the root mean square, maximal or minimal value over all samples in all channels, or just over all samples in channel, and outputs the value (in decibels) as a float. It's a conditional audio filter, so the computation is done framewise. The audio is converted to float internally. Syntax: AudioMax(channel) # maximal volume in channel (framewise) AudioMin(channel) # minimal volume in channel (framewise) AudioRMS(channel) # root mean square volume in channel (framewise) # channel = 0 (default) means that the max/min/rms is taken over all samples in all channels (framewise) Examples: v = BlankClip(pixel_type="YV12") a = Tone(type="Triangle", frequency=2, level=0.4) w = AudioDub(v,a) #.Histogram(mode="audiolevels") #w = ScriptClip(w, "Subtitle(String(AudioMax(1)))") w = ScriptClip(w, "Subtitle(String(AudioRMS(0)))") #w = ScriptClip(w, "Subtitle(String(AudioMin(1)))") w = w #.ConvertToRGB32.AudioGraph(20) return w Note that the values are given in decibels (see also histogram docs for an explanation). License: Licensed under GPL by Wilbert Dijkhof
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
Tags |
avisynth, black, detection, frames |
Thread Tools | Search this Thread |
Display Modes | |
|
|