Any way to remove duplicate frames?

twinbee wrote on 8/26/2022, 10:20 PM

I'm using the latest Vegas Pro 20 Build 139.

I have a Youtube video I've downloaded from a game called S.T.U.N. Runner, and I'd love to see it run smoother at 60 frames per second. Problem is each frame is repeated 2x or 3x, and there's no discernible pattern to when it'll even switch between these skips (example: 2x, 2x, 3x, 2x, 2x, 3x, 2x, 2x, 2x, 2x, 3x, 2x, 2x, 2x, 3x, 2x, 3x, 2x, 2x, 3x).

What I'd like to do is remove all the duplicate frames so that I only have one unique image for each frame. This means when I play the video back, it'll run smoothly, and I can then attempt to make it run even more smoothly by using the great Slow Motion plugin.

Seems like it should be a very basic feature. What's the easiest way of achieving this?

Comments

Former user wrote on 8/26/2022, 11:12 PM

@twinbee Hi, don't know if this will help. in the media Properties there's the Undersample rate, it'll make the fames seem shorter, you can use the Project Resample mode.. to help blend them 🤷‍♂️

twinbee wrote on 8/26/2022, 11:38 PM

@Former user Thanks, yeah I did see that and also experimented with the Playback Rate. Didn't help too much. I suspect the inconsistent timing of the frames prevents any simple way of removing frames which shouldn't be there.

twinbee wrote on 8/27/2022, 12:39 AM

@lan-mLMC Vegas has the "Slow Motion" option which as far as I know, imitates what Twixtor does. I'm not sure if Twixtor does a better job. But yes, otherwise, I want to remove the duplicated frames in either case.

Former user wrote on 8/27/2022, 1:22 AM

@twinbee As i understand it Twixter is a good one, when i can afford it i'm thinking of buying, How long is your clip?

 

Grazie wrote on 8/27/2022, 2:49 AM

My approach to using TWIXTOR, which may clarify the workflow here, and that is:

1 - Create the Event length.

2 - Disable Resampling.

3 - Create SubClip.

4 - THEN apply TWIXTOR.

Hope some of this helps.

Former user wrote on 8/27/2022, 5:00 AM

The problem @twinbee has, and he's trying to fix is his duplicated frame problem. Can't use optical flow on that for slow motion, it won't be smooth, but if it's a frame dropping causing the duplicated frames, then those duplicated frames need to be replaced by newly generated frames for smoothness and to keep audio sync.

Maybe if it is dropped frames and it's as regular as seen here, could use ffmpeg or shutter encoder to remove the duplicates, leaving a much shorter video track compared to audio, stretch out the video to match the audio, then use optical flow to create the extra frames to smooth out the video. I've never needed to do anything like this myself. Even if that was the correct method, using Vegas's optical flow for resample didn't work great when I tried it.

Maybe you could use twixtor to generate your initial 60fps smooth playing video or even start with a 30fps timeline, because it seems obvious you only have 30 fps + frame drops/dupes. Anyway it sounds like @lan-mLMC is one the case

3POINT wrote on 8/27/2022, 5:01 AM

I'm using the latest Vegas Pro 20 Build 139.

In VP20 resampling is disabled, this causes doubling frames when changing the projectframerate to a higher framerate than the original framerate of the used footage. To generate extra frames instead of doubling, to get a smoother (60 fps) playback, set in project properties resampling to optical flow. Be aware that this will tremendously extend the rendering times.

Grazie wrote on 8/27/2022, 5:04 AM

Great thread!

3POINT wrote on 8/27/2022, 5:21 AM

Great thread!

TIP: If want to do this really fast with very good results use Davinci Resolve (free version). :)

Musicvid wrote on 8/27/2022, 6:44 AM

All good speculation, but give us a link to the video in question. It may help determine the original frame rate, how it was processed, and if some form of pulldown removal will help, as is sometimes the case.

Grazie wrote on 8/27/2022, 7:24 AM

@Musicvid - I agree.

twinbee wrote on 8/27/2022, 1:10 PM

@twinbee As i understand it Twixter is a good one, when i can afford it i'm thinking of buying, How long is your clip?

How does Twixter compare to Vegas' Slow Motion feature? A minute long would be cool - just want to get a feel for how smooth it could be. Older 3D games always tended to run at 10-30fps - it'd be great to reimagine them at higher frame rates.

Anyway, here's a very short clip:

https://i.imgur.com/EgASmkb.mp4 (low quality, 1.5mb)

https://skytopia.com/stuff/stun.mp4 (higher quality, 3mb)

Frame repeats are either 1x, 2x, or 3x in this version (as I saved it out properly this time).

Maybe if it is dropped frames and it's as regular as seen here, could use ffmpeg or shutter encoder to remove the duplicates, leaving a much shorter video track compared to audio, stretch out the video to match the audio, then use optical flow to create the extra frames to smooth out the video.

Sounds like a plan. I'll take a look at ffmpeg or shutter encoder to see what I can do.

In VP20 resampling is disabled, this causes doubling frames when changing the project framerate to a higher framerate than the original framerate of the used footage. To generate extra frames instead of doubling, to get a smoother (60 fps) playback, set in project properties resampling to optical flow. Be aware that this will tremendously extend the rendering times.

I'm not sure I fully understand you, but to be clear, I'm not interested in obtaining a super smooth 60fps UNTIL I have removed all duplicate frames in the default (approx) 20-30fps mode I have right now. Such repeated frames will cause judder in the final video, even with the best frame interpolation software running the video at 1000 fps.

Great thread!

TIP: If want to do this really fast with very good results use Davinci Resolve (free version). :)

Aha, another avenue of exploration - thanks!

All good speculation, but give us a link to the video in question. It may help determine the original frame rate, how it was processed, and if some form of pulldown removal will help, as is sometimes the case.

Sure, see the links in this post just above!

Former user wrote on 8/27/2022, 1:42 PM

@twinbee Hi, I rendered out your Stun (higher quality, 3mb) as an image sequence then used Visipics to remove duplicates, here's the resulting files, https://drive.google.com/file/d/1fMM9cT2EeOVfzmYnMDJEN-PPPr8FzBWZ/view?usp=sharing

After removing those duplicates, in Vegas set your Preferences - New Still Image length to 0.040 so the imported pics are only 1 frame length, then select all images in the Windows folder & drag the first 000000 on to the timeline or use the Import option,

 

Musicvid wrote on 8/27/2022, 1:43 PM

Anyway, here's a very short clip:

Your video was probably captured at variable frame rate, then converted using CFR without interpolation. Since the frame changes are random and there is no identifiable cadence, there is not much you can do productively.

Congratulations, you have found a Frankenfile.

Howard-Vigorita wrote on 8/27/2022, 3:34 PM

Seems like it should be a very basic feature. What's the easiest way of achieving this?

@twinbee Easier said than done. A working approach depends on the nature of the duplicates and whether sync to an audio track is important. Good discussion on doing it with ffmpeg is here... easy only if you're familiar with that.

twinbee wrote on 8/27/2022, 4:12 PM

 

Your video was probably captured at variable frame rate, then converted using CFR without interpolation. Since the frame changes are random and there is no identifiable cadence, there is not much you can do productively.

Congratulations, you have found a Frankenfile.

Like you say, there's no pattern to the frame repetition, but there are possibilities to remove dupe files as @Former user just found.

Personally I think Twixtor is the best one compared with BCC Optical Flow, S_Retime, VEGAS Slow Motion & VEGAS Optical Velocity.

Couldn't see Optical Velocity as a plugin within Vegas 20. Is it like a more naive version of Slow Motion? Also is S_Retime part of BCC Optical Flow, or a separate rival to it?

Easier said than done. A working approach depends on the nature of the duplicates and whether sync to an audio track is important. Good discussion on doing it with ffmpeg is here... easy only if you're familiar with that.

I can always work on the audio afterwards and maybe time stretch it accordingly if necessary (or simply adjust the frame rate of the new video).

twinbee wrote on 8/27/2022, 4:43 PM

@twinbee Hi, I rendered out your Stun (higher quality, 3mb) as an image sequence then used Visipics to remove duplicates, here's the resulting files, https://drive.google.com/file/d/1fMM9cT2EeOVfzmYnMDJEN-PPPr8FzBWZ/view?usp=sharing

@Former user Wonderful stuff and thank you! I went ahead and imported the frames just as you described (I could have also renamed them using the awesome and ultra-portable "Siren Renamer" tool, to make them 0001, 0002, 0003 etc.).

I then saved the animation as 15fps (which turned out to be near the equivalent frame rate without the dupe frames), reloaded the video back in, and set the Slow Motion to 0.25. Converted it all to 60fps, and...

Here's the final result!

https://www.skytopia.com/stuff/stun60.mp4 (6 meg)

Love to see how that compares to Twixtor.

Other than the curious artifacts, there's an odd 'jolting' motion every fraction of a second, but I'm almost certain that comes from the original game/source. Rather than use proper curves for its motion, STUN Runner used some kind of approximation, almost as if key frames were used. And I don't just mean the pseudo-linear tweening between every 4 frames (which is inevitable, due to the pseudo-linear interpolation of frames from my venture in this entire post), but more like every 20 frames, and the the 60fps smoothness just makes the odd motion more apparent.

I'll still research how to easiest/best way to remove the frames myself (other/bigger videos to do) and you've given me yet another option with Visipics. I presume you had to saved the frames out individually to do this though.

In the meantime, time to suggest this "frame duplicate removal" in the main feature request thread.

Thanks everyone for your advice and endeavors!

Former user wrote on 8/27/2022, 9:12 PM

@twinbee I've had VisiPics for 12yrs or more, I take a lot of pictures of my work or at least i used to do before phone cameras got good enough & i started filming instead, In VisiPics you load the folder from the menu or drag it in, set the Strictness of what it searches for, full Strict only finds images that are exactly the same, press Play & it searches mages in that folder, you can manually go through & pick the ones you want to delete, Auto Select to pick duplicates to delete but you still have the option then to change each it auto selects, press Delete only deletes the selected, the remaining files in the folder stay as they were, just like they were in the folder i shared, If you select a folder with sub folders or even an entire drive full of folders it'll pick according to the setting, you've got to be careful of this tho because it might take an image from somewhere & mess up the order in that file, best to move all to one folder if that really matters, but you can deselect them from the list n tell it to ignore those, It's pretty much automated but you just have to keep an eye what it's selected because if it doesn't find any copies oon Strict, the slider moves down & it starts picking ones that look almost the same but aren't a perfect copy, It's fast tho n i like it 👍 & it's free with no Advert crap 😁,,

twinbee wrote on 9/3/2022, 1:59 PM

Amazingly, I find the Twixtor interpolation to not look as smooth as default Vegas "Slow Motion" plugin. Comparison:

http://www.skytopia.com/stuff/STUN-TwixtorM70-fps60.mp4

http://www.skytopia.com/stuff/stun60.mp4

There's some 'artifacting' in the sides of the screen in the Vegas plugin version, but the Twixtor version often has sections of the tube that run at 30 or even 15fps, while Vegas is mostly 60fps for everything.

@Former user - I found another way of achieving duplicate frame removal via ffmpeg, which may be simpler than your approach, so you (or others) might find it interesting. It does require very minimal knowledge of command prompt usage however. All I needed to do was download the ffmpeg essentials from this location. Then type in a prompt:

ffmpeg.exe -r 60 -i "input.mp4" -crf 0 -vf mpdecimate,setpts=N/FRAME_RATE/TB "output.mp4"

...and it saved out a complete video in mp4 (presumably h.264) format.

Hulk wrote on 9/4/2022, 4:47 PM

If the video in question is short you could go brute force on it.

Render it out to a photo format.

Remove dupes.

Put the photos back on the timeline and render back out.