AI Script for deleting specific video fragments

4sol-n wrote on 10/24/2022, 10:38 AM

Hi

Can you advice an AI script, which will delete fragments in a video which are viewed as stationary, non moved frames?

e.g. a video 10 minutes long, where in the middle nothing is happening and you actually see a still image, as nothing is moving there for 1 minute. This part must be cut, deleted and the right side of the video and everything after the it should move to the left to the distance of deleted fragment.

There should be definitely one for this purpose.

Comments

jetdv wrote on 10/24/2022, 12:36 PM

As far as a script is concerned, it does not "see" the video. I'm not saying it can't be done. It just can't be done using the tools provided by VEGAS. For this to work, the script would have to actually be able to open the original file to look at every frame and see if a frame has changed from the previous frame. Would not be a simple process to identify the frames.

For a quick test, I took a video segment I have of a screenshot where the screen is not changing. I took two images a few frames apart. Visually I could see nothing change between the two. However, the file sizes were slightly different which means, even looking at the image bits, something was definitely different in the files.

Alternately, it may be able to export many images and compare them to see "how different" they are. Then you have to figure out "How different are they allowed to be and still be the same?"

Certainly and interesting proposition!

wwaag wrote on 10/24/2022, 2:11 PM

@4sol-n

A tool to do this could easily be developed by adding such an option to the FrameFixer tool in HOS or use the output from FrameFixer and write a standalone script to do that.

At the moment, there is an option to find duplicate frames and add markers to the timeline.

As a test, I added a still image to some video, rendered to a new file, and then analyzed that file for duplicates.

Here are the results.

As you can see, a marker was added to each frame where a duplicate was found.

There is also a log that is created showing the statistics.

Once the frame numbers are known for duplicates, a script could be written to remove those from the timeline.

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia 1050ti graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.

jetdv wrote on 10/26/2022, 10:25 AM

@4sol-n Well, that's taken me down a rabbit hole. I've actually created a script now that can detect "duplicates" but you have to determine what threshold you want to use. I've tried many different numbers and it depends on how much of a change indicates a change. Basically, the routine I'm using calculates a percentage difference between two images (and I've determined that a frozen screen taking a snapshot of two different frames ARE different to a small degree!).

While the routine I've come up with isn't the fastest in the world (took 39 minutes to process a 44 second clip) it does seem to be working fairly well. It doesn't yet do everything you're wanting and, instead, right now just places a marker on each frame to be removed as test to see how the detection was working.

wwaag wrote on 10/26/2022, 5:35 PM

@jetdv

39 minutes for a 44sec clip. That's painful. Using Avisynth, it took around 8 sec for a 15 sec 1080 60P clip. Having said that, I know too well the joy of going down rabbit holes. LOL.

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia 1050ti graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.

jetdv wrote on 10/26/2022, 9:38 PM

@wwaag, I knew it wasn't going to be fast. At this point, though, it's a matter of seeing what can be done INSIDE VEGAS without resorting to calling 3rd party programs. Plus, I'm letting VEGAS do all the reading of the files so I don't have to worry about that. I can think of a faster option but that's another rabbit hole. Today I modified it so that it created 26 regions instead of over 1200 markers. The regions indicate the area(s) that would be removed because of "no movement". Of course, there really is "some" movement in those regions - just not enough for the images to be classified as "different" - unless you lower the threshold!

Here's what it now looks like with regions!

vs Markers:

Joelson wrote on 10/26/2022, 10:31 PM

@4sol-n @wwaag @jetdv

HOS Frame Fixer Tool in conjunction with Vegasaur Markers do this job.

jetdv wrote on 10/26/2022, 10:58 PM

@Joelson, That's fine. I'm not saying it doesn't. And certainly not aiming at copying anything someone else has done. But this is actually different:

  1. I'm chasing a rabbit now caused by the original post here.
  2. I'm looking to do the whole thing in one step without needing to go through multiple programs and even 3rd party applications or even multiple steps.
  3. I know it will be a whole lot SLOWER than what HOS FrameFixer and Vegasaur combined will do. I'm OK with that as I'd rather the method you demonstrated be used instead.
  4. I'm seeing what can be done direct from VEGAS using only the VEGAS scripting API (and what's built into .NET).

I'm not saying what I'm doing is better or should be used instead. At this point, it's more of a demonstration of what CAN be done inside VEGAS directly using the scripting API only.

So first I created a proof of concept that placed markers on the timeline. Then I got rid of the markers and had it place regions on the timeline instead. Next step will be to remove the regions too, as they're also really not needed but were used to verify the correct areas were being marked.

Like I said, not trying to replace existing functionality that's faster, more powerful, and already built. Just following this original this original post to a logical conclusion leading up to some more tutorials explaining how it was done even though it's not the fastest/most efficient way to do it. And it's really been a learning process as well.

So, please, by all means continue using the existing tools to do this. This is more of a learning experience that will end up doing what the original post requested and teach some things along the way. That doesn't mean it will be the best solution for doing so.

I already know there are more efficient ways of getting the images than what I'm using. But it's more of a learning process and how things can be done instead of the way they really should be done for the quickest result. And rolling your own tools really does teach a lot! So, no, what I'm doing is not what I would recommend for a final solution but it has been an interesting exercise.

jetdv wrote on 10/27/2022, 10:28 AM

@wwaag just generating the images is taking over 17 of the 39 minutes. I know there are faster ways (for example, rendering to an image sequence took between 1 and 1.5 minutes) but I'm not looking for speed at this time. As this isn't for a release product but more as an education, I'm ok with the slower speed. Starting the first of many tutorials based on this post...

4sol-n wrote on 10/30/2022, 4:01 PM

Very interesting comments here.

Want to update a little my thread:
My videos originally are from 5 to 10 hours long, using Vegas I'm speeding them up (4x time and x 500% by event velocity), so they appear to be 10-20 minutes videos.
As a result there will be "still frames" where I'm not doing anything, like went to eat dinner or to the toilet, in example, that results a lot of "still frames" areas, also you can see there some micro-still-frames, like for 5-10 ms, which are everywhere and the video goes like: plays-suddenly stops for a micro-still-frame then plays and stops... Cleaning these areas manually is really painful and very routine.

Using 3rd party apps is OK (it's good to know all the methods available)
Free options are also considered, since I only need one function, and buying something separate with a hundred different features which I will not use is not good.

So by so far as I understand we already have a complete solution, using HOS Frame Fixer Tool and Vegasaur Markers as Joelson mentioned, but I don't have free funds atm

jetdv wrote on 10/30/2022, 7:50 PM

@4sol-n, the series of tutorials I'm doing on this will start November 14th. It will be a multipart series. In the end it will do what you want. However, it will NOT be fast. If you want fast, you'll need to look at some of the retail options. I'm just doing it as more of a proof of concept that it can be done directly using a script direct from VEGAS with nothing else needed.

4sol-n wrote on 11/11/2022, 4:22 AM

@4sol-n, the series of tutorials I'm doing on this will start November 14th. It will be a multipart series. In the end it will do what you want. However, it will NOT be fast. If you want fast, you'll need to look at some of the retail options. I'm just doing it as more of a proof of concept that it can be done directly using a script direct from VEGAS with nothing else needed.

Sure, where can I find your series of tutorials? Is that will be a live stream or a video on YouTube?

btw how slow it will be? Just curious, e.g. for a video of 10 minutes.

jetdv wrote on 11/11/2022, 7:01 AM

@4sol-n. It's a 6 part series on my YouTube channel that starts this coming Monday November 14 (3 days from now). It will be each Monday for the next 6 weeks with each week building on the previous week. Each video is typically between 5 and 10 minutes long.

Week 1 (November 14): Figuring out how to get the images we need to "look" at in a way we can look at them

Week 2 (November 21): Compare the two images to see if they are "different"

Week 3 (November 28): Add markers at each "different" frame

Week 4 (December 5): Now add regions around unchanging sections instead of markers

Week 5 (December 12): Delete unchanging regions without adding regions to the timeline

Week 6 (December 19): Remove the empty space between the remaining events

The full code will be available for download as well on week 6.

 

It will be pretty slow. It took about 30 minutes for a 45 second segment so for 10 minutes, it could easily be 5-10 hours. It was more of a proof of concept than a "let's find the fastest way" and I only wanted to use what was available direct inside VEGAS without needing any third party tools.