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
Whaaat? I never heard of such a filter and can't find info on it on avisynth.org.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.
Should I upscale the logoless video to 25fps or downscale the 25fps video to 23.976?Match the overall frame count first.
Duplicate frames will collide with non-duplicates so I don't see the usefulness of this.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.
I'm lost.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.![]()
+ Reply to Thread
Results 31 to 60 of 73
-
-
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. -
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
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.
-
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.
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. -
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
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
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
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. -
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. -
To give you a second logoless video from which to choose frames when the first logoless video doesn't match.
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. -
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? -
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.
-
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.
-
Did you read the description of ConditionalFilter? It should be obvious what videos to use for each.
-
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.
-
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.
-
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. -
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))
-
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.
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. -
Well, one thing at a time. I meant what video should I put in that whateversource line? My logo'd or logoless vid?
-
-
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 didCode:a=avisource("C:\logoless.avi") b=avisource("C:\logod.avi") RectifiedDiff(a,b)
-
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.
-
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)
-
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.
-
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
-
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? -
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.
-
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)
-
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.
-
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.
Similar Threads
-
Any decent way to convert higher fps movies to a lower 29.97 fps ? (or othe
By Jonz in forum Video ConversionReplies: 1Last Post: 5th Nov 2012, 02:01 -
Matching frames of HQ and LQ video
By Mephesto in forum EditingReplies: 6Last Post: 30th Sep 2012, 11:47 -
How to lower the FPS for a MKV file?
By sldvd in forum EditingReplies: 6Last Post: 1st Jan 2010, 09:30 -
how do you lower fps on camcorder???
By aug3r in forum Capturing and VCRReplies: 6Last Post: 9th Jan 2009, 22:48 -
How to convert a video of 120 Fps to... well 23.9fps or 25 fps or 30 fps
By Chuba753 in forum Newbie / General discussionsReplies: 7Last Post: 6th Jun 2008, 19:17