VideoHelp Forum




+ Reply to Thread
Results 1 to 10 of 10
  1. Member
    Join Date
    Oct 2018
    Location
    United Kingdom
    Search Comp PM
    Hi guys,

    I have a video which has been spliced into 1 minute segments. I want to make it whole again but each segment has a small overlap from the previous one (the overlap is a random length from around 1 second to 3 seconds). Is there a video editor or tool I can use to auto detect the duplicate footage and remove it? If not, is there an editor that would make the process by hand easier? I am using Adobe premier and it's very slow going. Thanks in advance!

    Sonya
    Quote Quote  
  2. Avid Media Composer.
    Premiere Pro
    DaVinci Resolve

    None of them will remove it automatically. How would they know which one you don't want?
    Quote Quote  
  3. Member
    Join Date
    Oct 2018
    Location
    United Kingdom
    Search Comp PM
    Thanks for your reply. I was hoping there was software that could detect duplicate frames in a video, it wouldn't matter which copy was deleted as they are exactly the same and once that duplicated part is gone the video will be perfect. I have about 500 overlaps that need editing by hand. I am currently looking at the audio and finding the end of one clip and beginning of another that way...it's painstaking!
    Quote Quote  
  4. humans are only one that can detect the dups.. no ai
    Quote Quote  
  5. Originally Posted by teodz1984 View Post
    humans are only one that can detect the dups.. no ai
    Nonsense. It's easy to detect duplicates (or near duplicates) in software. Especially in a scenario like the the OP describes (aligning two tracks with overlapping segments). I don't know of any program or filter that's set up to do exactly what he wants though.
    Quote Quote  
  6. If the overlaps are long enough, there is software that will do exactly what you want to do, and will do it automatically:

    PluralEyes

    It is designed to automatically sync video from multiple cameras when you do a multi-camera shoot (i.e., several cameras filming the same scene at the same time).

    It works by looking for common audio. For your application, the key question will be whether it can detect the video with only a few seconds of audio that overlap. There may be some hidden settings that you'll have to invoke.

    I use this all the time, and for syncing multiple cameras, it is absolute magic and works incredibly well.
    Last edited by johnmeyer; 22nd Nov 2019 at 09:32.
    Quote Quote  
  7. Here's a proof of concept AviSynth script that will identify where an overlap starts:

    Code:
    p1 = AviSource("p1.avi") 
    p2 = AviSource("p2.avi") 
    
    testframe = p2.Trim(0,-1) # first frame of p2
    testframe = Loop(testframe, p1.framecount, 0, 0) # repeated for number of frames in p1
    p1
    WriteFileIf("matches.txt", "LumaDifference(testframe)<2.0", "current_frame")
    Matches.txt will indicate the frame of p1 that matches the first frame of p2. You may have to adjust the threshold value (2.0) depending on compression artifacts and other minor differences between the clips. I used a couple of Xvid compressed AVI files for testing. At 1.0 there were no matches. At 2.0 I got a match at frame 447.

    The following script joined the two clips seamlessly:

    Code:
    p1 = AviSource("p1.avi").Trim(0,446)
    p2 = AviSource("p2.avi")
    
    p1+p2
    Of course, false positives may occur. For example, if the second clip starts with a black frame (a fade to/from black) it may match many other black frames.

    A more sophisticated algorithm would match several frames, not just one. For example, it could start by overlapping one frame then subtracting that overlapping frame to see how close the result is to zero. Then it would repeat the process with 2 overlapping frames, 3 overlapping frames, etc. Then see what amount of overlap gives an average closest to zero.
    Last edited by jagabo; 22nd Nov 2019 at 08:25.
    Quote Quote  
  8. Originally Posted by jagabo View Post
    Nonsense. It's easy to detect duplicates (or near duplicates) in software. Especially in a scenario like the the OP describes (aligning two tracks with overlapping segments). I don't know of any program or filter that's set up to do exactly what he wants though.
    In theory one could write a piece of software that calculated the PSNR between 2 adjacent frames and if the value was infinite then drop one of the frame, and repeat until EOF; I'm wondering if this would be possible via script+ffmpeg, it would take forever but it should be able to remove all duplicate frames for a given file.
    Quote Quote  
  9. Here's an example of how comparing multiple frames would work. I'm using AviSynth's Subtract() filter which subracts pixels of one clip from pixels of another clip, and returns the result as an image. Since an image can't have pixels with negative values Subtract() adds medium gray. When two images match perfectly the result is a flat grey image. When A-B results in a value less than zero you get a darker pixel. when A-B results in a value greater than zero you get a lighter pixel.

    Image
    [Attachment 50946 - Click to enlarge]


    At the top of these film strips is the end of the first clip. At the bottom is the start of the second clip. The grey-ish frames are the overlapping frames after Subtract(first, second). At the left there is only one overlapping frame and it shows obvious differences between the two clips. In the middle there are two overlapping frames and there are only very tiny differences. On the right three frames are overlapped and all three show significant differences. So from these results you would say there are 2 frames of overlap at the end of the first clip and start of the second clip. And indeed, I created the clips with 2 frames of overlap.
    Quote Quote  
  10. I forgot to include the script that generated those images:

    Code:
    ##########################################################################
    #
    #  Overlap two videos.  Show Subtract() at the overlapped frames.
    #  The second clip is overlapped at the end of the first clip by
    #  "overlap" frames.
    #
    ##########################################################################
    
    function Overlap(clip v1, clip v2, int overlap)
    {
        # build a clip of only the overlapping frames, and Subtract() them
        o1 = v1.Trim(v1.framecount-overlap,0)
        o2 = v2.Trim(0, length=overlap)
        ol = Subtract(o1,o2)
    
        # show v1 before the overlap, the overlap, then then v2
        v1.Trim(0, v1.framecount-overlap-1) + ol + v2.Trim(overlap,0)
    }
    
    ##########################################################################
    
    part1 = AviSource("part1.avi")
    part2 = AviSource("part2.avi")
    
    Overlap(part1, part2, 3) # overlap 3 frames
    
    StackVertical(Loop(3,0,0), Loop(2,0,0), last, Trim(1,0), Trim(2,0)) # stack 5 consecutive frames
    Of course, you don't need to perform the stacking if you want to view frames one at a time (and stacking large frames is impractical).

    Here's an example with 3 overlapping frames where the frames were numbered before being overlapped. The first clip is numbered at the top left of the frame, the second at the top right:

    Image
    [Attachment 50948 - Click to enlarge]


    You can see the last 3 frames of the first clip and the first 3 frames of the second clip are overlapped. This is the equivalent of the right column in my previous post.
    Quote Quote  



Similar Threads

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