VideoHelp Forum




+ Reply to Thread
Page 2 of 3
FirstFirst 1 2 3 LastLast
Results 31 to 60 of 73
  1. Originally Posted by b5fan View Post
    I'm just a video noob so I'm not sure if this is even possible, but mathematically speaking, could you upscale both videos to the least common framerate (in your case 600 fps) or whatever the highest rate possible is, then every frame will match. Isn't this basically what the newer TVs with super high Hz ratings do. That way they can take all different types of videos and they all look good. Then scale it back down to whatever you want for the final video.
    600 is not an LCM of 23.976 and 25. A mathematically-accurate FPS would be 74925 to perfectly match them, but there are some complications. The 23.976 fps video has duplicates and its real fps is around 20-22 so the frames would NOT match up.

    manono, logo removers suck and produce results far more annoying than the logo itself. MSU did release a new version but I couldn't get it to work. The video DOES have a lot of movement and projector wobble on static parts.

    jagabo
    I'm not absolutely sure this will work but I would look into using ConditionalFilter() to pick from multiple phase shifted versions (ie, plus and/or minus one or more frames temporally) of the secondary video.
    Whaaat? I never heard of such a filter and can't find info on it on avisynth.org.

    Match the overall frame count first.
    Should I upscale the logoless video to 25fps or downscale the 25fps video to 23.976?

    Then create some phase shifted versions of the secondary video (Trim (1,0), Trim(2,0), etc.). Use Subtract() of the main video vs phase shifted videos to create some test videos.
    Duplicate frames will collide with non-duplicates so I don't see the usefulness of this.

    Rectify the results of Subtract() and normalize based at zero, ie, abs(a-b) -- the brighter the result the worse the match. Then use the runtime feature to locate the phase shifted video with the closest match (lowest average intensity of the rectified test videos) and select the frame from that video.
    I'm lost.
    Quote Quote  
  2. Originally Posted by Mephesto View Post
    I'm not absolutely sure this will work but I would look into using ConditionalFilter() to pick from multiple phase shifted versions (ie, plus and/or minus one or more frames temporally) of the secondary video.
    Whaaat? I never heard of such a filter and can't find info on it on avisynth.org.
    http://avisynth.nl/index.php/ConditionalFilter
    Quote Quote  
  3. Weird, Google failed to turn that page up.

    But okay, from what I understand you want me to subtract the first video from the second video that's trimmed by one frame and then run Conditionalfilter on the subtraction to throw out mismatching frames which'll be done by discriminating the average luma.

    I don't think this will work because the difference between changing frames have brighter as well as darker differences and in the end the average is the same luma value as the average between matching frames because the darker spots mitigate the brighter spots.
    Also, the logoless video is half the resolution, compressed with crappy MPEG1 and has a different contrast/brightness which I tried to fix so the global average luma and sat would match but there's still clipping and noticeable difference between the two.

    The condition for exclusion shouldn't be the average luma but average amount of detail, which subtracted matching frames would have a lot less than mismatching ones.
    Quote Quote  
  4. After Subtract() and rectifying what you have is the amount of detail difference encoded as brightness. Try this simple script on a video:

    Code:
    Subtract(last, Trim(last,1,0))
    Overlay(ColorYUV(off_y=-128), Invert().ColorYUV(off_y=-128), mode="add") #rectify
    It gives the difference between consecutive frames, not frames of two different videos. But you'll see that in still shots you get a black image. In moving shots you see lots of detail. During a panning shot (the two compared frames don't match) you get this:

    Click image for larger version

Name:	diff.jpg
Views:	130
Size:	26.3 KB
ID:	18497

    During still shots (the two compared frames match) the picture is totally black.

    If the videos are different sizes, brightness, alignment, etc. you just have to adjust the frames before subtracting. You have to do most of that to replace the logo anyway.
    Last edited by jagabo; 25th Jun 2013 at 07:25.
    Quote Quote  
  5. Ah, clever. But what do you want me to do? Subtract VideoA by VideoA.trim(1,0) or VideoA by VideoB(Trim(1,0)?
    I have the impression you want me to do the former, so whats the purpose of this? To delete duplicates?

    If the videos are different sizes, brightness, alignment, etc. you just have to adjust the frames before subtracting. You have to do most of that to replace the logo anyway.
    They're already adjusted so they have the same average global luma and sat but they still look different if subtracted from one another because the logoless version was messed around with. Its blacks and whites are clipped so there's no way to match them perfectly. Thank god only the smaller logo area needs to be matched and it doesn't look too bad.

    I have done this sort of thing before but the temporal frame orientation matched perfectly so I didn't have to worry about this hard part. The logoless version was half the resolution and on top of that compressed heavily with H264 but the covered area was not really noticeable at all unless you knew what to look for.
    Quote Quote  
  6. Originally Posted by Mephesto View Post
    Ah, clever. But what do you want me to do? Subtract VideoA by VideoA.trim(1,0) or VideoA by VideoB(Trim(1,0)?
    The latter. And as many other trimmed versions as you need to get matches.

    Starting with two videos A (with logo) and B (logoless) with the following sequence of frames:

    Code:
    A) 30 31 32 33 34 35 36 37 38 39 40
    B) 30 31 32 32 33 34 35 36 37 38 39 40
    B has a duplicate frame at frame #33 so after frame 32 the frames don't match. So create a new video, C, which is Trim(B,1,0)

    Code:
    A) 30 31 32 33 34 35 36 37 38 39 40
    B) 30 31 32 32 33 34 35 36 37 38 39 40
    C) 31 32 32 33 34 35 36 37 38 39 40
    Now the first 2 frames of B match A, the third is matched be either B or C, and the rest are matched by C. You need a way to pick between B and C. Using the rectified subtraction method:

    Code:
    A)   30 31 32 33 34 35 36 37 38 39 40
    B)   30 31 32 32 33 34 35 36 37 38 39
    A-B)  0  0  0  x  x  x  x  x  x  x  x
    Code:
    A)   30 31 32 33 34 35 36 37 38 39 40
    C)   31 32 32 33 34 35 36 37 38 39 40
    A-C)  x  x  0  0  0  0  0  0  0  0  0
    Zeros mean the frames were identical, x means they were not. Of course, in your case the "identical" frames won't be perfect zeros. But picking the smaller of the diffs should work. So pick from B or C depending on whether A-B or A-C has the smaller difference.


    Originally Posted by Mephesto View Post
    If the videos are different sizes, brightness, alignment, etc. you just have to adjust the frames before subtracting. You have to do most of that to replace the logo anyway.
    They're already adjusted so they have the same average global luma and sat but they still look different if subtracted from one another because the logoless version was messed around with. Its blacks and whites are clipped so there's no way to match them perfectly.
    So use a blown out version of the good video for the subtraction.

    The unknown part (at least to me) is in using ConditionalFilter (or one of the related runtime filters) to perform the comparison of A-B and A-C -- since it isn't designed exactly for this purpose. I don't know it well enough to say for sure if it will be able to accomplish what's needed. But at least you now have a potential method to look in to.
    Quote Quote  
  7. If I subtract by a phase shifted video then almost all frames would be rejected by ConditionalFilter. Majority of them match up if I don't Trim() at all. What's the purpose of trim?

    So use a blown out version of the good video for the subtraction.
    What do you mean?
    Quote Quote  
  8. Originally Posted by Mephesto View Post
    If I subtract by a phase shifted video then almost all frames would be rejected by ConditionalFilter. Majority of them match up if I don't Trim() at all. What's the purpose of trim?
    To give you a second logoless video from which to choose frames when the first logoless video doesn't match.

    Originally Posted by Mephesto View Post
    So use a blown out version of the good video for the subtraction.
    What do you mean?
    Make a copy of the logo'd video with blown out darks and brights just like the logoless video -- used only for the subtraction process.
    Quote Quote  
  9. Ok I got the brightness and contrast to match for the most part. It looks pretty good now and all the matching frames return mostly-black frames when subtracted. The worst one I've seen only had salt-n-pepper differences because of the MPEG1 artifacts and noise. The matching frames are easily distinguishable by the mismatching ones, by eye at least.

    So I'll now have two subtractions to work with, A by B and A.Trim by B. I've no reason for now to believe I'll need another one shifted by 2 frames.

    What now? This Conditionalfilter-- does it output a statsfile I could use to combine the two subtractions and decide which frames to throw out?
    Quote Quote  
  10. You now have two logoless videos (B, C) and their corresponding diff videos (diffB, diffC). ConditionalFilter allows the input of one test video and two videos. You can Subtract(diffB, diffC) and send that to ConditionalFilter as the test clip. If the average luma is >128 video B is the closer match, if less<128 video C is the closer match. Use the video returned by ConditionalFilter as the source for the logo replacement.
    Quote Quote  
  11. What should be the two sources videos for ConditionalFilter? diffB and diffC? You said subtract(diffB,diffC) should be one of them so I'm confused.
    Quote Quote  
  12. Did you read the description of ConditionalFilter? It should be obvious what videos to use for each.
    Quote Quote  
  13. This whole thing is really labyrinthine so it ain't obvious to me. Are you wanting me to use three videos in ConditionalFilter? You said use subtract(diffB,diffC) in Conditionalfilter then said test diffB against diffC.
    Quote Quote  
  14. Subtract(diffB,diffC) is the test video, B and C are the other two videos. The condition to test for is averageluma of the test video > 128.
    Quote Quote  
  15. ConditionalFilter(a, b, c, "AverageLuma()", "lessthan", "128")

    Is that what it's supposed to look like?
    a is subtract(diffB,diffC)

    b is A
    c is A.Trim(1,0)

    Because the result is back to where I started: videoA.

    I'm going to bed. I'm tired.
    Quote Quote  
  16. Originally Posted by Mephesto View Post
    ConditionalFilter(a, b, c, "AverageLuma()", "lessthan", "128")

    Is that what it's supposed to look like?
    a is subtract(diffB,diffC)

    b is A
    c is A.Trim(1,0)
    Yes, that's the idea. I had a similar problem with another video so I went ahead and made my own test script. I found that Subtract() gives values around 126 with YUV video, not 128. So the script needs to be modified to reflect that. This script takes a video and creates two videos with some wrong frames by discarding and duplicating. It then locates the frames in those "wrong videos" that match the original source:

    Code:
    function RectifiedDiff(clip video1, clip video2)
    {
        Subtract(video1, video2)
        Overlay(ColorYUV(off_y=-126), Invert().ColorYUV(off_y=-126), mode="add")
    }
    
    src=WhateverSource("filename.ext")
    
    # create some alternate videos with missing/duplicate frames
    v1=SelectEvery(src,3,0,1,1)
    v2=SelectEvery(src,3,0,2,2)
    # out of every 3 frames:
    # frames 0 and 1 of v1 match the source
    # frames 0 and 2 of v2 match the source
    
    # create the diff videos
    d1=RectifiedDiff(src,v1)
    d2=RectifiedDiff(src,v2)
    
    # mark the alternate videos so we know for sure which was chosen
    v1=v1.Subtitle("v1")
    v2=v2.Subtitle("v2")
    
    # pick v1 or v2, based on which matches the source best
    ConditionalFilter(Subtract(d1,d2), v1, v2, "AverageLuma()", "lessthan", "126", show=true)
    
    # stack and show them
    StackHorizontal(src,last)
    Stackvertical(last,StackHorizontal(d1,d2))
    Quote Quote  
  17. Should I use your script? What goes in the src=whateversource?
    Quote Quote  
  18. Originally Posted by Mephesto View Post
    Should I use your script?
    You can use it as a guide but you'll need to modify it for your videos. You have to use your second video as v1, phase shifted for v2. Add whatever brightness, contrast, cropping, alignment adjustments you need for the diff videos, etc. For your logo removal you have to remove all the stacking code that's just used to show the source, the diffs and the selected frames. Use the output of ConditionalFilter() as the logoless video to overlay onto the logo'd video.

    Originally Posted by Mephesto View Post
    What goes in the src=whateversource?
    Whatever source filter is appropriate for your source video. AviSource(), Mpeg2Source(), ffVideoSouce(), etc.

    The script as given will work as a standalone demo just by replacing WhateverSource(). I recommend you try it with a small frame video to see it in action.
    Quote Quote  
  19. Well, one thing at a time. I meant what video should I put in that whateversource line? My logo'd or logoless vid?
    Quote Quote  
  20. Originally Posted by Mephesto View Post
    Well, one thing at a time. I meant what video should I put in that whateversource line? My logo'd or logoless vid?
    Logo'd. v1 would be the logoless video, v2 the phase shifted version. The output of ConditionalFilter is the logoless frame (from v1 or v2) that most closely matches the logo'd frame.
    Quote Quote  
  21. Something's wrong here. When I open the script, I'm seeing the subtraction difference frames. The stacking code at the end of your script is not working because I see nothing stacked. I know you told me to remove that but it appears I didn't even have to. I copied your code directly from here, made it into an .avsi and threw it in the Avisynth plugins folder.

    Then I did
    Code:
    a=avisource("C:\logoless.avi")
    
    b=avisource("C:\logod.avi")
    
    RectifiedDiff(a,b)
    There was no # before the stack codes so what is going on?
    Quote Quote  
  22. If you're only calling RectifiedDiff() all you'll get is the difference between a and b. That's the only purpose of that function. The script I gave was meant to be run as a standalone script for demo purposes.
    Quote Quote  
  23. Ohh, damn I missed that. It makes sense now.

    Anyway, you said the src=the logo'd video but looking in your script I don't see the logoless video being referenced anywhere
    Why is does v1 and v2 = src?
    Code:
    v1=SelectEvery(src,3,0,1,1)
    Quote Quote  
  24. I don't have logo'd and logoless videos sitting around. And I don't have multiple versions of a movie with slightly different frames. So I created v1 (to stand in for a logoless video) and v2 (to stand in for the phase shifted copy of the logoless video) to have videos from which to select frames that match the logo'd (src) video. The demo script was to show you that indeed the technique can select the proper matching frames from two "logoless" videos, neither of which had all the matching frames alone.

    I told you already to substitute your logoless video for v1 and the phase shifted version for v2.

    Basically, I'm giving you a few tools and a simple sample script to show that they work. I expect you to figure out what's going on and adapt the tools to your videos.
    Last edited by jagabo; 28th Jun 2013 at 10:39.
    Quote Quote  
  25. Maybe breaking the functions out like this will help you out:



    Code:
    #################################################################################
    #
    # Rectified difference of two videos -- abs(ClipA - ClipB).
    #
    #################################################################################
    
    function RectifiedDiff(clip ClipA, clip ClipB)
    {
        Subtract(ClipA, ClipB)
        Overlay(ColorYUV(off_y=-126), Invert().ColorYUV(off_y=-126), mode="add")
    }
    
    
    #################################################################################
    #
    # On a frame by frame basis, determines whether ClipA or ClipB most closely
    # matches MatchClip. Returns that most closely matched frame (ClipA or ClipB).
    #
    #################################################################################
    
    function SelectBestMatch(clip MatchClip, clip ClipA, clip ClipB)
    {
        d1 = RectifiedDiff(MatchClip, ClipA)
        d2 = RectifiedDiff(MatchClip, ClipB)
        ConditionalFilter(Subtract(d1,d2), ClipA, ClipB, "AverageLuma()", "lessthan", "126.000", show=false)
    }
    
    
    #################################################################################
    
    LogoVid = AviSource("video.avi") # substitute your logo'd video here
    Logoless1 = SelectEvery(LogoVid,3,0,1,1).Subtitle("1")  # substitute your logoless video here
    Logoless2 = SelectEvery(LogoVid,3,0,2,2).Subtitle("2") # substitute Trim(logoless1,1,0) here
    
    BestLogoless = SelectBestmatch(LogoVid, Logoless1, Logoless2)
    
    # Use BestLogoless to overlay the clear part of the picture onto LogoVid (the logo'd video)
    
    # For purposes of the demo just show the original frame and the best match side by side
    StackHorizontal(LogoVid, BestLogoless) # these two should match
    Quote Quote  
  26. Many thanks jagabo for your patience and persistence. I owe you.

    My bad if I was being a newb, I normally wouldn't ask for this kind of hand holding. I'm working an overnight shift right now so I'm trying to sleep in the middle of the summer heat. I can't think.

    We're not there yet though. Most of the frames now match up but the logoless 23.976 fps video has duplicate frames which is made worse when upscaling it to match the 25fps logo video so there's a consistent pattern of mismatching where everything's fine for half a second and then a mismatch every 4 frames 4 times like

    4
    4
    3
    13
    4
    4
    4
    13
    4
    4
    4
    13
    4
    4
    4

    I think I need a third logoless trim to fix this. Does conditionalfilter work with 3 clips at once?
    Quote Quote  
  27. Oh wait, wait a minute. I got it backwards. The 4 4 4 13 pattern should've told me the obvious: this is the result of the upscaling of 21 fps to 25.

    In this script of yours it tries to match the lower-FPS logoless video to the logo'd but this is impossible because of the lower fps. Instead, the logo'd frames have to be matched to the logoless.

    Let me see if I can remedy this...

    EDIT: Ugh no, it failed.
    Last edited by Mephesto; 29th Jun 2013 at 09:46.
    Quote Quote  
  28. Originally Posted by Mephesto View Post
    Does conditionalfilter work with 3 clips at once?
    No. You have to repeat the process with the frame it returned and the third video. And you could repeat with as many other clips as necessary:

    Code:
    BestLogoless = SelectBestmatch(LogoVid, Logoless1, Logoless2)
    BestLogoLess = SelectBestmatch(LogoVid, BestLogoless, Logoless3)
    BestLogoLess = SelectBestmatch(LogoVid, BestLogoless, Logoless4)
    BestLogoLess = SelectBestmatch(LogoVid, BestLogoless, Logoless5)
    Quote Quote  
  29. Thanks but it was a post too late. It didn't work anyhow. Frames in the logo'd video must be dropped and duplicated to properly match the logoless.
    Quote Quote  
  30. I'm not sure what your saying. But no amount of phase shifting will restore missing frames in your logoless video. And you may need backward shifts as well as forward shifts. You can use Loop(N,0,0) to insert copies of the first frame, shifting the rest of the video back.
    Last edited by jagabo; 29th Jun 2013 at 11:30.
    Quote Quote  



Similar Threads

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