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. |
15th November 2011, 21:12 | #1 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
Delete Dups
I have a video where sometimes there's a single dup after a frame. How can I remove this?
Code:
scriptclip(""" YDifferenceFromPrevious<.1?deleteframe(current_frame):last """) |
15th November 2011, 21:33 | #2 | Link |
typo lover
Join Date: May 2009
Posts: 595
|
__________________
my repositories |
15th November 2011, 21:55 | #3 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
DeDup as suggested above will probably sort you out, but also, if you have any other weird reasons
for deleting frames (other than duplicates) then the below might come in handy to create a command file for Prune(), where you list the frames to keep rather than chuck. You would though probably want to only use it as last resort. Code:
# Edited:- avisource("d:\avs\avi\1.avi").ConvertToYV12() Writefileif("d:\avs\avi\1.txt","YDifferenceFromPrevious>=0.1 || current_frame==0",""" "0," ""","current_frame",append=false)
__________________
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 November 2011 at 21:35. |
15th November 2011, 21:58 | #4 | Link | |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
Thanks, I'm trying dedup now, however the log file is empty except this line:
Quote:
|
|
15th November 2011, 22:11 | #5 | Link | |
typo lover
Join Date: May 2009
Posts: 595
|
Quote:
use VDub's 'Run video analysis pass'
__________________
my repositories |
|
15th November 2011, 22:22 | #6 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
The recursive procedure could now be replaced by a GScript 'while' loop (not available at the time). DeDup is probably a simpler way if it works for your source. |
|
15th November 2011, 22:49 | #7 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
Ok, fixed the problem with the log file, now I can't get all the frames dedeupped, it's quite clear the threshold. I find the docs confusing. If I could do multiple passes I might get it to work, but it's quite awkward.
I tried Gavino's approach, no luck either, it's taking away too many frames. Code:
function DarkFrames(clip c, int current_frame, float thresh) { # returns the number of consecutive 'dark' frames at the current frame c.YDifferenceFromPrevious< thresh ? 0 \ : (current_frame >= c.frameCount-1) ? 1 \ : 1 + DarkFrames(c.Trim(1,0), current_frame, thresh) } dir="D:\project001a\dedup fields\" DirectShowSource(dir+"jvc-with-ext-tbc.mov") SeparateFields selectevery(2,0) converttoyv12 threshold = 2.6 # <- change this to suit requirements offset = 0 # assume 'last' set earlier in script ScriptClip(""" subtitle(string(YDifferenceFromPrevious)) offset = offset + DarkFrames(Trim(offset, 0), current_frame, threshold) Trim(offset, 0) """) |
15th November 2011, 23:07 | #9 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Code:
function DupFrames(clip c, int current_frame, float thresh) { # returns the number of consecutive duplicate frames at the current frame c.YDifferenceFromPrevious > thresh ? 0 \ : (current_frame >= c.frameCount-1) ? 1 \ : 1 + DupFrames(c.Trim(1,0), current_frame, thresh) } |
|
15th November 2011, 23:13 | #10 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Tricky yes, but I doubt any of your fancy NLE's will give you the ability to delete an arbitary set of frames according to some user-defined criterion based on frame contents. The power and flexibility of Avisynth is shown by examples like this.
|
15th November 2011, 23:37 | #11 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Jmac, eg below should work (or whatever you called the command file.
Code:
Prune(cmd="D:\avs\avi\1.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; 16th November 2011 at 00:10. |
15th November 2011, 23:50 | #13 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Hi Jmac, just want to make sure you saw the previous edit.
__________________
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 ??? |
16th November 2011, 13:09 | #15 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Code:
..., "YDifferenceFromPrevious>=0.1 || current_frame==0", ... |
|
16th November 2011, 17:21 | #16 | Link |
Registered User
Join Date: Oct 2011
Location: Germany
Posts: 39
|
Are you sure you want to delete the dups? When you're dealing with VHS grabbings the dups might be a simple replacement to fill the gaps where the capture device could not sync to a frame. When using USB video grabbers I had often series of 1...10 dups at places with problems in tape flow. In that cases the dups are 100% identical copies of the last frame.
In those cases I found that cutting off the dups can disturb the flow of motions, and also it leads to jumps in audio flow. If would be better to interpolate the missing frames from their neighbors using mflow. (If there is no scene transisition -- then interpolation will not make much sense). The latter is exactly the problem I am working on, but I did not succeed in writing a script that replaces n1, n2 frames at positions x1, x2 ... using a list of duplicate frames from a ConditionalReader file. Last edited by sven_x; 16th November 2011 at 17:26. |
16th November 2011, 17:41 | #17 | Link | |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,695
|
Quote:
Automatically fix dups followed (eventually) by drops It turns out that in some capture situations, the capture card misses (drops) a frame. So, to get the audio back in sync, it later duplicates a frame (as sven_x says, this is a perfect duplicate). Thus, while you can easily find the dups and interpolate a frame at that point (search this forum for "deletedup"), that usually doesn't give you smooth video. Instead, you have to find the unwanted jump where a frame was not captured, and interpolate a new frame at that point (using mvtools2). The beauty of Didée's approach, which I modified to get better detection with my particular source, is that it also "automatically" finds and removes the exact duplicates. Thus the duplicates are decimated, and new interpolated frames are inserted at the points which have the biggest "gap" in motion from one frame to the next. The gap detection isn't perfect, but it was, for my source, pretty darned good (about 98% correct). I'm sure another smart person could take the script as a starting point and, while referring back to Didée's original masktools approach for finding gaps, combine the various ideas and perhaps come up with a detection scheme that is even better. The underlying "plumbing" is all in place, so you can spend you time just on doing better detection of the places where the frame was actually dropped. Of course if the audio is NOT in sync, and you have to drop these duplicate frame to get back into sync, then all you need is the original "deletedups" function created many years ago. You'll find a link to that if you click on the hyperlink above. |
|
16th November 2011, 19:01 | #18 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
You're right, that is the underlying problem, but I have an even better approach. I have two copies of video with different dropped *fields*, and yes there is a dupe in place of the dropped field, so it's easy to find. However the dupes were created by a TBC, so it's an analog dupe, and it's not perfect - however still a simple YDifferenceFromPrevious detects them well.
So the reason I'm eliminating dupes is because I do interleave(clip1.separatefields, clip2.separatefields) so normally there's two dupes, if one stream is missing a field there will be 3 dupes. I just remove all dupes, and patch with one of the audio, and I'm done. Since my detection is reliable, I don't want to rely on detecting jumps. There's no further drops after the dupes; one field is duped (to the next top field) and that's it. Last edited by jmac698; 16th November 2011 at 19:35. |
16th November 2011, 19:25 | #19 | Link |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,695
|
If you are consistently getting dropped frames from new captures, it sure sounds like you need to find a better capture card. I have captured thousands of hours of off-the-air and VHS, Beta, & 8mm videotape, and I never get any dropped frames. The only time I had these problems was when I tried capturing with my ATI Radeon card and those awful Catalyst drivers. I never could get consistent results.
Years ago, I created a "FAQ" for Sony Vegas for someone who was operating a Vegas help site, and in the video capture segment I asked the question: "How many dropped frames is acceptable?" My answer: none. You should never have any. |
16th November 2011, 19:37 | #20 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
I have many capture cards. I have tested them with my Glitch Analyzer, would you like to try it? Sometimes the drops were due to the software or settings I used; for example I found that VirtualDub by default has screwed up my captures for years What software do you use?
Anyhow this particular project is to help a board member. I have a different problem myself; there's a duped *frame* followed by a dropped frame. http://forum.doom9.org/showthread.php?p=1462931 |
|
|