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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 10th April 2013, 12:22   #1  |  Link
HappyLee
Registered User
 
Join Date: Mar 2013
Posts: 27
A script that automatically detect and replace broken frames?

Greetings, everyone. My first post here.

I have a video source that is full of broken frames, so I need to make a script to restore them automatically. And because I'm not good at writing avs script, I have to come and ask for a little help. Sorry for my poor English grammar.

The broken frames are nearly white (due to flashlights), and each broken frame comes alone (that is to say, no 2 broken frames are neighbours). So I'm guessing I can use those properties to replace them with the good frames right before them. Here's my plan:

1. Find a way to calculate the average brightness of every frames.
2. Compare every neighbouring 2 frames using the brightness information.
3. If frame (2) is greater than both frame (1) and frame (3) in brightness, and the difference is greater than a specified value, then it's been detected that frame (2) is a broken frame.
4. .DeleteFrame(that broken frame) and .DuplicateFrame(that broken frame-1)
5. Loop until every broken frames are replaced.

If anyone could help me with that script, I'll be much obliged. Thank you.
HappyLee is offline   Reply With Quote
Old 10th April 2013, 14:35   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Try this (Requires RT_Stats, on first Avisynth Usage Page, few threads before this thread, at time of posting).

Code:
# FixBadWhiteFrame.avs
# https://forum.doom9.org/showthread.php?p=1623487#post1623487

AVISource("D:\avs\test.avi")

TestClip() # Make a TestClip with White Frame every 10 frames


Offset=DeleteFrame(Framecount-1).DuplicateFrame(0)

super = Offset.MSuper()
backward_vectors = MAnalyse(super, isb = true, delta=2)
forward_vectors = MAnalyse(super, isb = false, delta=2)
inter = Offset.MFlowInter(super, backward_vectors, forward_vectors, time=50, ml=70)


LIMIT=200.0 # Average Luma above this is White Frame

CondS="""
    ave=RT_AverageLuma()
    prv=RT_YDifference(delta=-1)
    nxt=RT_YDifference(delta=1)
    alt=RT_YDifference(current_frame-1,delta=2)
    clpn=(ave>LIMIT && alt < prv && alt < nxt) ? 1 : 0
#   RT_Debug(String(current_frame)+"]","Ave="+String(ave),"Prv="+String(prv),"Nxt="+String(nxt),"Alt="+String(alt),"ClpN="+String(clpn))
    clpn
"""

ConditionalSelect(Last,CondS,Last,inter)    # Fix bad frames
    
return Last 
 

Function TestClip(clip c) {
    c
    KillAudio()
    WHT=Last.BlankClip(color=$FFFFFF)
    A=SelectEvery(9,0)
    B=SelectEvery(9,1)
    C=SelectEvery(9,2)
    D=SelectEvery(9,3)
    E=SelectEvery(9,4)
    F=SelectEvery(9,5)
    G=SelectEvery(9,6)
    H=SelectEvery(9,7)
    I=SelectEvery(9,8)
    Interleave(A,B,C,D,E,F,G,H,I,WHT)
    Trim(0,999)
    return last
}
Comment out the TestClip line, that just creates a testing clip.

Hope that makes you a happy chappy.
__________________
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 ???

Last edited by StainlessS; 23rd July 2018 at 18:24.
StainlessS is offline   Reply With Quote
Old 10th April 2013, 19:56   #3  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
I have two scripts that I use which you should be able to combine together to do what you ask. You say you are not an advanced programmer, but combining these two should be very straightforward. I think only one line will need to be changed in the second set of code below.

The first set of code is designed to find a "flash" frame. I use this all the time with video that I create from amateur 8mm and 16mm movies. The first frame of every scene that is filmed with an amateur camera is overexposed because the rotating shutter in the camera is still coming up to speed. To find these single, overexposed frames, all I do is compare the current frame to the frames immediately before and after. If the ratio of the averageluma is significantly greater than both of the adjacent frames, then this frame is a "flash frame."

Here is the code for finding a flash frame:

Code:
#Script to find "flash" frames

#Specify the name and location of the output file
filename = "m:\flash_frames.txt"
global flashthresh=1.15

AVISource("E:\fs.avi").killaudio()

global i=AssumeBFF
global p=selectevery(i, 1, -1) #Previous frame
global n=selectevery(i, 1,  1) #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)/AverageLuma(p)) + " " + String(AverageLuma(i)/AverageLuma(n)))"""  )

#This is the line that writes the frame number of any frame that falls above the threshold
WriteFileIf(last, filename,  "(AverageLuma(i)/AverageLuma(p)>flashthresh)&&AverageLuma(i)/AverageLuma(n)>flashthresh", "current_frame", append = false)
The second function is one that replaces a frame with a motion-estimated frame, but only when a condition is met. In this case it is looking for a near-duplicate frame (or, if you set the comparison to 0.0 instead of 0.1, it will only find exact duplicates).

Here is that code:

Code:
function filldrops (clip c)
{
  super=MSuper(c,pel=2)
  vfe=manalyse(super,truemotion=true,isb=false,delta=1)
  vbe=manalyse(super,truemotion=true,isb=true,delta=1)
  filldrops = mflowinter(c,super,vbe,vfe,time=50)
  fixed = ConditionalFilter(c, filldrops, c, "YDifferenceFromPrevious()", "lessthan", "0.1")
  return fixed
}
This function is for progressive video and is based on MugFunky's original idea from many years ago. If your video is interlaced, search these boards for my user name and the word "filldropsi()". That is a variation I created for interlaced video.

To combine these two together, I think all you need to do is take the code from the WriteFileIf function in the first code snippet, and put it into the ConditionalFilter line in the filldrops function. They both have similar syntax. So, what you will be doing is creating a "filldrops" function that, instead of substituting a sysnthesized ("estimated") video frame when a duplicate frame is detected, will instead substitute that synthesized frame when a frame is detected that doesn't match either the frame that precedes or the frame that follows.

One note: at first you might think this function would be activated at scene changes, but at a scene change the last frame of the earlier scene always matches the preceding frame, and the first frame of the new scene always matches the following frame, so the function doesn't get activated.

BTW, this same logic is useful for identifying photographer's flashes; for finding noise frames (from excessive dropouts, for instance) and any other situation that creates a "bad frame."

[edit] I took a long time creating this post, and didn't realize Stainless had posted essentially the same idea.

Last edited by johnmeyer; 10th April 2013 at 20:00. Reason: Acknowledge Stainless post
johnmeyer is offline   Reply With Quote
Old 10th April 2013, 21:16   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
My previous post is for progressive, if your problem clip is Interlaced, then use John's script (EDIT: filldropsi) or say so here and I'll do an interlaced version.
__________________
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 ???

Last edited by StainlessS; 10th April 2013 at 22:36.
StainlessS is offline   Reply With Quote
Old 11th April 2013, 04:03   #5  |  Link
HappyLee
Registered User
 
Join Date: Mar 2013
Posts: 27
Thank you both so much! You're really awesome! I hope one day I would be just like you, and I'm still learning.
HappyLee is offline   Reply With Quote
Old 16th February 2014, 20:54   #6  |  Link
Boffee
Registered User
 
Join Date: Oct 2011
Location: Worthing, UK
Posts: 24
John's script did not work for me, received "only planar images as (YV12) supported!". Added the .ConvertToYV12() after killaudio(). This fixed the issue.

Last edited by Boffee; 16th February 2014 at 20:56. Reason: spelling
Boffee is offline   Reply With Quote
Old 17th February 2014, 20:40   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Here, slight mod of scripts posted elsewhere, replaces bad frames (single isolated frame eg black OR white)

Progressive, TweenFrames.avs

Code:
AVISource("D:\avs\test.avi")

# Pick a test below

#Return TestClip($FFFFFF)   # White NOFIX
#Return TestClip($FFFFFF).TweenFrames(LimitLo=200.0,LimitHi=255.0,Show=true)    # Fix White frames PROGRESSIVE

#Return TestClip($000000)   # BLACK NOFIX
#Return TestClip($000000).TweenFrames(LimitLo=0.0,LimitHi=32.0,Show=true)   # Fix Black frames PROGRESSIVE


Function TweenFrames(clip c,float  "LimitLo",float "LimitHi",bool "show") {
# TweenFrames() by StainlessS
# PROGRESSIVE.
# Replace isolated bad frames eg Black or White with a frame tweened from those either side using MvTools, and RT_Stats.
# LimitLo: is minimum luma value of frame to replace. Allows select, eg black/White.
# LimitHi: is maximum luma value of frame to replace.
# Show: Puts indicator on fixed frames.
    c
    LimitLo=Float(Default(LimitLo,200.0))                       # Average Luma greater or equal to this eligible for replacement
    LimitHi=Float(Default(LimitHi,255.0))                       # Average Luma lesser or equal to this eligible for replacement
    show=Default(show,False)
    Prev=DeleteFrame(FrameCount-1).DuplicateFrame(0)
    super = Prev.MSuper()
    backward_vectors = MAnalyse(super, isb = true,truemotion=true, delta=2)
    forward_vectors  = MAnalyse(super, isb = false,truemotion=true, delta=2)
    inter = Prev.MFlowInter(super, backward_vectors, forward_vectors, time=50, ml=70)
    inter = (show) ? inter.Subtitle("FRAME FIXED") : inter
    CondS="""
        ave=RT_AverageLuma()
        prv=RT_YDifference(delta=-1)
        nxt=RT_YDifference(delta=1)
        alt=RT_YDifference(current_frame-1,delta=2)
        clpn=(ave>=LimitLo && ave<=LimitHi && alt < prv && alt < nxt) ? 1 : 0
#       RT_Debug(String(current_frame)+"]","Ave="+String(ave),"Prv="+String(prv),"Nxt="+String(nxt),"Alt="+String(alt),"ClpN="+String(clpn))
        clpn
    """
    CondS=RT_StrReplaceMulti(CondS,"LimitLo"+Chr(10)+"LimitHi",String(LimitLo)+Chr(10)+String(LimitHi))
    ConditionalSelect(Last,CondS,Last,inter)    # Fix bad frames
    return Last
}


Function TestClip(clip c,int "Color") {
# Replace every 8th frame with blank.
    c
    Color=Default(Color,$FFFFFF)
    BAD=Last.BlankClip(color=Color)
    A=SelectEvery(8,0)  B=SelectEvery(8,1)  C=SelectEvery(8,2)  D=SelectEvery(8,3)
    E=SelectEvery(8,4)  F=SelectEvery(8,5)  G=SelectEvery(8,6)
    Interleave(A,B,C,D,E,F,G,BAD)   # every 8th frame replaced with BAD
    Return Trim(0,1000)
}
Interlaced, TweenFields.avs
Code:
AVISource("D:\avs\test.avi")

# Pick a test below

#Return TestClipI($FFFFFF)          # White NOFIX
#Return TestClipI($FFFFFF).TweenFields(LimitLo=200.0,LimitHi=255.0,Show=true)   # Fix White frames INTERLACED

#Return TestClipI($000000)          # BLACK NOFIX
#Return TestClipI($000000).TweenFields(LimitLo=0.0,LimitHi=32.0,Show=true)  # Fix Black frames INTERLACED


Function TweenFields(clip c,float  "LimitLo",float "LimitHi",bool "show") {
# TweenFields() by StainlessS
# INTERLACED.
# Replace isolated bad fields eg Black or White with a field tweened from those either side using MvTools, and RT_Stats.
# LimitLo: is minimum luma value of field to replace. Allows select, eg black/White.
# LimitHi: is maximum luma value of field to replace.
# Show: Puts indicator on fixed fields.
    c
    LimitLo=Float(Default(LimitLo,200.0))                       # Average Luma greater or equal to this eligible for replacement
    LimitHi=Float(Default(LimitHi,255.0))                       # Average Luma lesser or equal to this eligible for replacement
    show=Default(show,False)
    SEP=SeparateFields()
    Even=SEP.SelectEven()
    Prev=Even.DeleteFrame(FrameCount-1).DuplicateFrame(0)
    super = Prev.MSuper()
    backward_vectors = MAnalyse(super, isb = true,truemotion=true, delta=2)
    forward_vectors  = MAnalyse(super, isb = false,truemotion=true, delta=2)
    inter = Prev.MFlowInter(super, backward_vectors, forward_vectors, time=50, ml=70)
    inter = (show) ? inter.Subtitle("EVEN FIELD FIXED") : inter
    CondS="""
        ave=RT_AverageLuma()
        prv=RT_YDifference(delta=-1)
        nxt=RT_YDifference(delta=1)
        alt=RT_YDifference(current_frame-1,delta=2)
        clpn=(ave>=LimitLo && ave<=LimitHi && alt < prv && alt < nxt) ? 1 : 0
#       RT_Debug(String(current_frame)+"] EVEN","Ave="+String(ave),"Prv="+String(prv),"Nxt="+String(nxt),"Alt="+String(alt),"ClpN="+String(clpn))
        clpn
    """
    CondS=RT_StrReplaceMulti(CondS,"LimitLo"+Chr(10)+"LimitHi",String(LimitLo)+Chr(10)+String(LimitHi)) # Import explicit into script
    EvenFixed=ConditionalSelect(Even,CondS,Even,inter)  # Fix bad even fields
    Odd=SEP.SelectOdd()
    Prev=Odd.DeleteFrame(FrameCount-1).DuplicateFrame(0)
    super = Prev.MSuper()
    backward_vectors = MAnalyse(super, isb = true,truemotion=true, delta=2)
    forward_vectors  = MAnalyse(super, isb = false,truemotion=true, delta=2)
    inter = Prev.MFlowInter(super, backward_vectors, forward_vectors, time=50, ml=70)
    inter = (show) ? inter.Subtitle("ODD FIELD FIXED",align=9) : inter
    CondS=RT_StrReplace(CondS,"EVEN","ODD")
    OddFixed=ConditionalSelect(Odd,CondS,Odd,inter) # Fix bad Odd fields
    Interleave(EvenFixed,OddFixed)
    Weave()
    return Last
}


Function TestClipI(clip c,int "Color") {
# Replace every 8th EVEN field and every 12th ODD field with a blank.
    Color=Default(Color,$FFFFFF)
    SEP=c.SeparateFields    BAD=SEP.BlankClip(color=Color)  EVEN=SEP.SelectEven()
    A=EVEN.SelectEvery(8,0) B=EVEN.SelectEvery(8,1) C=EVEN.SelectEvery(8,2) D=EVEN.SelectEvery(8,3)
    E=EVEN.SelectEvery(8,4) F=EVEN.SelectEvery(8,5) G=EVEN.SelectEvery(8,6) EVEN=Interleave(A,B,C,D,E,F,G,BAD)
    ODD=SEP.SelectODD()     A=ODD.SelectEvery(12,0) B=ODD.SelectEvery(12,1) C=ODD.SelectEvery(12,2)
    D=ODD.SelectEvery(12,3) E=ODD.SelectEvery(12,4) F=ODD.SelectEvery(12,5) G=ODD.SelectEvery(12,6)
    H=ODD.SelectEvery(12,7) I=ODD.SelectEvery(12,8) J=ODD.SelectEvery(12,9) K=ODD.SelectEvery(12,10)
    ODD=Interleave(A,B,C,D,E,F,G,H,I,J,K,BAD)   Interleave(EVEN,ODD)    Weave()
    Return Trim(0,1000)
}
Scripts included with RT_Stats.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 17th February 2014, 23:32   #8  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Stainless,

Thanks for that code. I have used the "filldrops()" code from MugFunky, and my updates to it, both to make it work with interlaced footage, and also to use MVTools2. However, having used your code for other projects, I'll bet this works better. I'll use it the next time I need to replace bad frames or duplicates (simple mod to make it work for that) and I'll report back what I find.
johnmeyer is offline   Reply With Quote
Old 18th February 2014, 02:38   #9  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I'm guessin it works pretty good. (works great, with the only flash sample that I have).
It perhaps could be improved a little, but quite gud as is.

Will miss double frame flash'es (flash photography), but really quite resilient.
Those that take epileptic fits over flash photography may feel more comfortable, once processed.

Sample scripts as given able to provide I think much better control than original MugFunky (all hail) script,
and more easily modded.

EDIT: The flash photography sequence I used had already been temporally processed, and because of that,
may have resulted in a double flash frame (un-detected by above scripts). Not sure that, the double flash
would generally appear in real unprocessed clips, but no longer have the original clip.
EDIT: if need was there, scipts could be modified to also detect double and/or single flash frames at the expense of a little speed (methinks).
__________________
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 ???

Last edited by StainlessS; 18th February 2014 at 13:49.
StainlessS is offline   Reply With Quote
Old 19th February 2014, 10:35   #10  |  Link
Boffee
Registered User
 
Join Date: Oct 2011
Location: Worthing, UK
Posts: 24
I have a video made from an old 8mm cine film film where the first frame of each scene is over exposed. I have put this through John's script above using the "global flashthresh=1.15" and hey presto I have a text file of all the broken frames. So far so good. I then tried John's suggestion to amend the conditional filter in filldrops to eliminate these automatically, however Avisynth throws a syntax error. Can anyone tell me what the line
Quote:
fixed = ConditionalFilter....etc
should be amended to. Thanks
Boffee is offline   Reply With Quote
Old 19th February 2014, 20:46   #11  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Boffee, try this (Untested, no test clip)

Code:
# FixFlashAfterSceneCut.avs, https://forum.doom9.org/showthread.php?p=1669349#post1669349

Avisource("D:\avs\FLASHTEST.avi")

FlashThresh = 1.15
SETUP=True                                                  # Show f1 and f2 to setup FlashThresh
SHOWFIXED=True                                              # No effect if SETUP == true, else show fixed frames if true

CondS="""
    ave_p=Max(RT_AverageLuma(delta=-1), 0.01)                # Avoid Division By Zero
    ave_i=RT_AverageLuma()
    ave_n=Max(RT_AverageLuma(delta=1), 0.01)
    f1 = ave_i / ave_p
    f2 = ave_i / ave_n
    clpn = ((f1 > FlashThresh) && (f2 > FlashThresh)) ? 1 : 0
    return clpn
"""

Next = DuplicateFrame(FrameCount-1).DeleteFrame(0)

Replace = (SHOWFIXED) ? Next.Subtitle("FRAME FIXED",Align=9,size=30) : Next

(SETUP)
    \ ? Scriptclip("""
            ave_p=Max(RT_AverageLuma(delta=-1), 0.01)        # Avoid Division By Zero
            ave_i=RT_AverageLuma()
            ave_n=Max(RT_AverageLuma(delta=1), 0.01)
            f1 = ave_i / ave_p
            f2 = ave_i / ave_n
            Subtitle(String(f1)+" "+String(f2)+((f1>FlashThresh&&f2>FlashThresh)?" FIXING":""),size=30)
        """)
    \ : ConditionalSelect(Last,CondS,Last,Replace)

Return Last
EDITED: Fixed division by zero.
EDIT: Fixed again alternative method

It replaces bad frames with following frame, no motion compensation.
(cannot tween with frame before scene change and MC not very good using two following frames although might be good in some cases).

Give it a try. (Based on mixture of previously given scripts in thread with Johns first clip for detection)
__________________
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 ???

Last edited by StainlessS; 23rd July 2018 at 18:33.
StainlessS is offline   Reply With Quote
Old 19th February 2014, 21:08   #12  |  Link
Boffee
Registered User
 
Join Date: Oct 2011
Location: Worthing, UK
Posts: 24
Thanks very much StainlessS, this works brilliantly and does just what I want. Much appreciated.
Boffee is offline   Reply With Quote
Old 19th February 2014, 21:17   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
You're welcome Boffee, however, be aware that there should be a guard again Division by Zero eg here

Code:
 f1 = ave_i / RT_AverageLuma(delta=-1)
Ill fix in script a bit later, I have to leave in a moment or two.

EDIT: FIXED
__________________
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 ???

Last edited by StainlessS; 19th February 2014 at 21:35.
StainlessS is offline   Reply With Quote
Old 20th February 2014, 00:23   #14  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
BTW, those "flash frames," each time the film camera starts, show up in most film transfers. They happen because the camera motor can't instantly get the rotating shutter up to full speed. As a result, the shutter speed on the first few frames is slower, resulting in over-exposure. The over-exposure on the first frame can sometimes be as much as three f-stops (or more), so the frame is useless.

However, my reason for posting is to point out that often the next 1-2 frames are also over-exposed, sometimes significantly. Therefore, the "ultimate" script for this application would detect the flash frame (that problem has been "solved" in this thread), but then look at the next 5-10 frames and make a determination as to how many additional frames after the initial flash frame should be eliminated.

In my existing film transfer workflow, I use my own script (which I will replace with the Stainless code) to output a list of flash frames. I then have a second script that operates inside of Vegas (my NLE) which cuts the video at each flash. I then use a keyboard shortcut to go to each flash frame and decide how many frames to cut. I could save myself a lot of time if the script gave me the option of deleting 1-3 of these subsequent over-exposed frames.

The only downside to what I am proposing (and please, Stainless, let me take a shot at this -- I am not asking for you to write additional code) is that sometimes those overexposed frames are important. For instance, I do film transfers from 1950s and 1960s American football games. These game films had the camera start just before each play. However, sometimes the camera operator forgot to start until the ball was hiked, so the play is already under way. In this case I only eliminate the flash frame (which usually has nothing but white), and then keep the additional frames.

So I definitely will use any modification which automatically cuts the flash frame because those are never useful, and I will work on a modification which provides a way to cut "n" number of additional frames if they are more than "m%" above the average exposure of frames 5-9 after the flash (I have never seen a camera take more than four frames to get up to speed).

Last edited by johnmeyer; 20th February 2014 at 00:23. Reason: Fix bad punctuation
johnmeyer is offline   Reply With Quote
Old 20th February 2014, 02:08   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by johnmeyer View Post
let me take a shot at this
Arh, you like to spoil all my fun

Go for it John.

EDIT: I cannot guarentee that I will not leech off it, and perhaps mod. (Hopefully you will not mind too much if so)
__________________
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 ???

Last edited by StainlessS; 20th February 2014 at 12:41. Reason: speeling
StainlessS is offline   Reply With Quote
Old 20th February 2014, 21:44   #16  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Hi John, just something for you to consider,

The FrameSel: http://forum.doom9.org/showthread.ph...light=FrameSel

plugin allows you reject frames rather than select
so eg
Code:
 FrameSel(cmd="Frames.txt",Reject=True)
Frames.txt
Code:
10      # reject frame 10
20,-1   # reject frame 20
30,-2   # reject 2 frames starting at frame 30
40,-3   # reject 3 frames starting at frame 40
50,53   # reject 4 frames, 50, 51, 52 and 53
perhaps of some use.

EDIT: Presumably no audio (it dont support audio, returns null audio)
EDIT: Can also use SPACE rather than COMMA as separator in frames.txt
__________________
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 ???

Last edited by StainlessS; 20th February 2014 at 22:05.
StainlessS is offline   Reply With Quote
Old 20th February 2014, 22:28   #17  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
I'm in the midst, as I write this, of transferring eight small reels of film. I'll try out everything later today and let you know what I find.

Thanks!
johnmeyer is offline   Reply With Quote
Old 21st February 2014, 03:11   #18  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Well, this guy's dad had pro cameras: no flash frames on either the 16mm or 8mm film. If I get a chance, I'll try to find some older transfers and try out the scripts on that.
johnmeyer is offline   Reply With Quote
Old 27th February 2014, 19:18   #19  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
I transferred about 1,000 feet of NFL football film last night and had a chance to try out the Stainless code. Unfortunately, the script doesn't work for a real-world situation. The reason is that flash frame are not overexposed compared to an absolute limit (i.e., above 200 luma) but instead are overexposed compared to their immediate neighbors. I think the mathematicians call it a "local maxima." Therefore, the detection must be done by comparing the test parameter to the averages on either side of each frame. Also, there are situations (fogging) where the luma value is moving up and down, but these frames should not be touched.

Here is a test clip where I have used VirtualDub (direct stream copy) to eliminate most of each scene, but left about half a dozen frames on each side of each flash. I've also included a small segment of fogged film, so you can so an example of luma variations that should not be rejected. Also note how the contrast and overall luma changes from one part of the film to the next. These short snippets were taken from several different reels of film, each having different exposure. Amateur film is always like this. You cannot guarantee any sort of exposure consistency.

Here is the sample clip (44 MB NTSC DV AVI file):

Flash Frame Example.avi (edit: changed from Dropbox to Mediafire)

Note: even though DV is always stored as interlaced, the actual content of this file is progressive, and it should be treated as progressive when doing any detection or modification.

Finally, once in awhile you do get a "big" flash frame that fits the description of what I think this script was designed to find and fix. I included this as the last "flash" in the test file.

I am going to spend a little more time on this and see if I can use the Stainless detection tools to do a better job than the script I have been using (posted a few weeks ago, earlier in this thread).

Last edited by johnmeyer; 2nd March 2014 at 18:08. Reason: changed "the flash" to "each flash"; changed download from dropbox to mediafire
johnmeyer is offline   Reply With Quote
Old 27th February 2014, 19:54   #20  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Thank you John, I'll have a play with your sample.

I saw a flv clip earler today (well late last night) that showed flash photography flashes extending up to 4 frames (30FPS),
where alternate frames started the flash at a particular vertical postion, and usually stopped about the same position
on the next frame (usually in paired Y postions). And also frames where flash area occupied only eg vertically central part
of a frame. Looks like these flashes can vary in characteristic somewhat.

PS, The Limits in previously given TweenFrames script are just to select between Black OR White frame detection, not to detect
the bad frames themselves (you could eg use LimitLo=128, LimitHi=255 for white and LimitLo=0, LimitHi=127 for black.
__________________
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 ???

Last edited by StainlessS; 27th February 2014 at 20:25.
StainlessS is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 19:42.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.