VideoHelp Forum
+ Reply to Thread
Results 1 to 17 of 17
Thread
  1. Hi everyone,

    I am digitalizing some old VHS-C tapes from the 90's. However when the last few tapes where shot back then, the camera was going bad. Apparently one of the record heads was going bad, resulting in noise and and reduced colors in only the odd frames. The other frames look good. see the examples below.

    I was wondering if it is possible to improve those bad frames using the good ones. But since i have alsmost no experience at video editing i have no idea how. So i was wondering if someone knows some tricks to do this. I am currently using adobe premiere pro CC 2015 and i also have after effects installed.

    Is there someone who could help me?

    Thanks a lot.


    Good frame:
    Image
    [Attachment 54040 - Click to enlarge]


    Bad frame:
    Image
    [Attachment 54039 - Click to enlarge]
    Quote Quote  
  2. VHS-C is interlaced video. Are your 2 pictures taken after deinterlacing/bobbing? Maybe only one field of the interlaced source is bad and you could just bob and keep the good field, loosing temporal resolution unless you synthesize and replace the dropped bad field.
    When you upload a short sample of the captured source you may get better advice.
    Quote Quote  
  3. If you look at the Y, U, and V channels you'll see that the problem is mostly in the chroma channels:

    Good YUV:
    Image
    [Attachment 54042 - Click to enlarge]


    Bad YUV:
    Image
    [Attachment 54043 - Click to enlarge]


    If the bad frames are infrequent and there's not too much motion you can detect the bad frames and replace the chroma with the chroma of a good frame (in AviSynth):
    Image
    [Attachment 54044 - Click to enlarge]


    A video sample would be helpful.
    Quote Quote  
  4. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    Originally Posted by jagabo View Post
    If the bad frames are infrequent and there's not too much motion you can detect the bad frames and replace the chroma with the chroma of a good frame (in AviSynth):
    Automatically, or by specifying frames?
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  5. Originally Posted by lordsmurf View Post
    Originally Posted by jagabo View Post
    If the bad frames are infrequent and there's not too much motion you can detect the bad frames and replace the chroma with the chroma of a good frame (in AviSynth):
    Automatically, or by specifying frames?
    Possibly automatically if the bad frames are typically that bad, there aren't too many in a row, and there's not too much motion.
    Quote Quote  
  6. I wrote a script to automatically detect frames which differ significantly from both adjacent frames. It gives you the option of simply saving the bad frame numbers, or having the script automatically replace a bad frame with a frame motion estimated from its neighbors.

    Here is a link to that script:

    Finding individual "bad" frames in video; save frame number; or repair

    Note that there is a link in the first line of my post which takes you to a better version of the script which I eventually created using hints and ideas that people gave me.

    To adapt the script to the OP's problem, and given what jagabo showed (that the main problem is in the chroma channel) I would probably add a couple of lines to feed the comparison function only the chroma portions of the video.

    BTW, one neat thing about scripts like this one is that if you set the threshold a little too low so that some frames are flagged that aren't really a problem, the motion estimation usually creates a replacement frame that is very close to the real frame.
    Quote Quote  
  7. I only have two frames to work with so I wrote a script that interleaves them, identifies the frames with more noise in the Y channel, and replaces the chroma of those frames with the chroma of the frame before:

    Code:
    ##########################################################################
    #
    # Abs(v1-v2)
    #
    # Y, channel only
    #
    ##########################################################################
    
    function AbsSubtract(clip v1, clip v2)
    {
        Subtract(v1, v2)
        Overlay(last.ColorYUV(off_y=-126), last.Invert().ColorYUV(off_y=-129), mode="add")
    }
    
    ##########################################################################
    
    
    v1 = ImageSource("good.jpg", start=0, end=23, fps=23.976) # get the good image as a short clip
    v2 = ImageSource("bad.jpg", start=0, end=23, fps=23.976)  # get the bad image as a short clip
    src = Interleave(v1, v2).ConvertToYV12() # interleave the two videos, convert to YV12
    
    test = src.ConvertToYV12().Spline36Resize(192, 288) # spots in the chroma channel reduced to about 1 pixel
    test = AbsSubtract(test.UtoY(), test.UtoY().Blur(1.4)) # subtract blurred image from original (a high pass filter) to see only spots, abs(v1-v2)
    
    patch = MergeChroma(src, src.Loop(2,0,0)) # merge luma of every frame with the chroma of the previous frame
    
    ConditionalFilter(test, patch, src, "AverageLuma()", "greaterthan", "5") # if the spots are strong enough select the patch image instead of the original
    You'll probably need to change the threshold (the 5) once you have the real full motion video. And the patch filter could be frames interpolated between the frame before and after. Or some other type of replacement.
    Quote Quote  
  8. Thanks for the replies so far. I uploaded a sample video.

    I have no real experience with video, but i do have a background in electronics/programming so hopefully i should be able to understand things.

    I played the VHS-C tape in a VCR and captured the video using a dongle. I couldn't capture it directly from premiere so i had to use the software that came wit it. That software did output a mpeg file. I then used premiere pro in order to cut and edit the video in order to make a dvd.
    Also the flickering noise is also visible on the (crt) tv when playing the tape. The good and bad frames are alternating. This continues to be the case for the whole tape.

    Thanks for the scripts. I will have a look at aviSynth.
    Since I will be busy the coming days it could take a while before i am able to respond.
    Image Attached Files
    Quote Quote  
  9. Every other frame is screwed up. All bad frames replaced with motion interpolated frames:

    Code:
    ##########################################################################
    #
    # Abs(v1-v2)
    #
    # Y, channel only
    #
    ##########################################################################
    
    function AbsSubtract(clip v1, clip v2)
    {
        Subtract(v1, v2)
        Overlay(last.ColorYUV(off_y=-126), last.Invert().ColorYUV(off_y=-129), mode="add")
    }
    
    ##########################################################################
    
    # replace every frame with a motion interpolated frame (between the frame before and the frame after)
    
    function InterpolateAll(clip c)
    {
        e = SelectEven(c).InterFrame(cores=4, FrameDouble=true).SelectOdd()
        o = SelectOdd(c).InterFrame(cores=4, FrameDouble=true).SelectOdd()
        Interleave(e,o)
        Loop(2,0,0)
    }
    
    ##########################################################################
    
    src = Mpeg2Source("Sequence 01.d2v")
    
    test = src.ConvertToYV12().Spline36Resize(192, 288)
    test = AbsSubtract(test.UtoY(), test.UtoY().Blur(1.4))
    
    patch = InterpolateAll(src)
    
    ConditionalFilter(test, patch, src, "AverageLuma()", "greaterthan", "5")
    Image Attached Files
    Quote Quote  
  10. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    Originally Posted by jagabo View Post
    Originally Posted by lordsmurf View Post
    Originally Posted by jagabo View Post
    If the bad frames are infrequent and there's not too much motion you can detect the bad frames and replace the chroma with the chroma of a good frame (in AviSynth):
    Automatically, or by specifying frames?
    Possibly automatically if the bad frames are typically that bad, there aren't too many in a row, and there's not too much motion.
    I'd like to see that script.

    KNLmeansCL can do wonders with horrid sources.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  11. Originally Posted by lordsmurf View Post
    Originally Posted by jagabo View Post
    Originally Posted by lordsmurf View Post
    Originally Posted by jagabo View Post
    If the bad frames are infrequent and there's not too much motion you can detect the bad frames and replace the chroma with the chroma of a good frame (in AviSynth):
    Automatically, or by specifying frames?
    Possibly automatically if the bad frames are typically that bad, there aren't too many in a row, and there's not too much motion.
    I'd like to see that script.
    See post #9.
    Quote Quote  
  12. Note that the video the OP provided in post #8 had all even frames that were good, all odd frames that were bad. In that particular case it would have been easy to just blindly replace all the odd frames. But the code I gave identifies frames with the noisy chroma and replaces only those. Yes, in this case it's the same thing. But the given code would work with any random sequence of good/bad frames -- except when there are multiple bad frames in a row.
    Quote Quote  
  13. Originally Posted by jagabo View Post
    If the bad frames are infrequent and there's not too much motion you can detect the bad frames and replace the chroma with the chroma of a good frame (in AviSynth):
    Originally Posted by lordsmurf View Post
    Automatically, or by specifying frames?
    Originally Posted by jagabo View Post
    Possibly automatically if the bad frames are typically that bad, there aren't too many in a row, and there's not too much motion.
    Originally Posted by lordsmurf View Post
    I'd like to see that script.
    Jagabo provided the script in post #9. That script replaces the chroma in the bad frame with the chroma from an adjacent frame.

    As for automatic detection, here is a link to the script I created over at doom9.org:

    Finding individual "bad" frames in video; save frame number; or repair

    This script detects frames which differ significantly from both adjacent frames (i.e., scene changes don't trigger anything).

    All you need to do is put jagabo's function into my script, and change the call to the motion estimated replacement to a call to jagabo's function.
    Quote Quote  
  14. Originally Posted by johnmeyer View Post
    Jagabo provided the script in post #9. That script replaces the chroma in the bad frame with the chroma from an adjacent frame.
    Actually the script in post #9 replaces the bad frame with a motion interpolated frame. It could easily be changed to copy the chroma from the previous frame by replacing the "patch" line with the patch line from post #7. In this particular video motion interpolated frames look better because there's very little motion. It does screw up at the scene change though.
    Quote Quote  
  15. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    So ... what would a merge script look like then?

    And how long does it take for you to run the script?
    Perhaps some GPU acceleration?
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  16. Originally Posted by lordsmurf View Post
    So ... what would a merge script look like then?

    And how long does it take for you to run the script?
    Perhaps some GPU acceleration?
    The time would depend on the video, but generally speaking the script runs blazingly fast, usually several hundred fps. The reason for this is that the frame comparison logic uses the built-in AVISynth comparison functions. The interpolation code, which is pretty slow, only gets called when a replacement is actually needed.

    However, if every other frame needs to be replaced, then the speed will drop to well below real time.
    Quote Quote  
  17. I described how to use the previous frame's chroma in post #14.

    Code:
    ##########################################################################
    #
    # Abs(v1-v2)
    #
    # Y, channel only
    #
    ##########################################################################
    
    function AbsSubtract(clip v1, clip v2)
    {
        Subtract(v1, v2)
        Overlay(last.ColorYUV(off_y=-126), last.Invert().ColorYUV(off_y=-129), mode="add")
    }
    
    ##########################################################################
    
    # replace every frame with a motion interpolated frame (between the frame before and the frame after)
    
    function InterpolateAll(clip c)
    {
        e = SelectEven(c).InterFrame(cores=4, FrameDouble=true).SelectOdd()
        o = SelectOdd(c).InterFrame(cores=4, FrameDouble=true).SelectOdd()
        Interleave(e,o)
        Loop(2,0,0)
    }
    
    ##########################################################################
    
    src = Mpeg2Source("Sequence 01.d2v")
    
    test = src.ConvertToYV12().Spline36Resize(192, 288)
    test = AbsSubtract(test.UtoY(), test.UtoY().Blur(1.4))
    
    #patch = InterpolateAll(src)
    patch = MergeChroma(src, src.Loop(2,0,0)) # merge luma of every frame with the chroma of the previous frame
    
    ConditionalFilter(test, patch, src, "AverageLuma()", "greaterthan", "5")
    On my computer using the previous frame's chroma the script runs about 400 fps. Using motion interpolated frames about 90 fps.
    Last edited by jagabo; 11th Jul 2020 at 12:12.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!