0

world.

I have many videos that I want to compare one-to-one to check if they are the same, and get from there the delay of frames, let's say. What I do now is opening both video files with virtualdub and checking manually at the beginning of video 1 that a given frame is at position, i.e., 4325. Then I check video 2 to see the position of the same frame, i.e., 5500. That would make a delay of +1175 frames. Then I check at the end of the video 1 another given frame, position let's say 183038. I check too the video 2 (imagine the position is 184213) and I calculate the difference, again +1175: eureka, same video! The frame I chose to compare aren't exactly random, it must be one that I know it is exactly one I can compare to (for example, a scene change, an explosion that appears from one frame to another, a dark frame after a lighten one...) and I always try to check for the first comparison frames within the first 10000 positions and for the second check I take at the end. What I do next is to convert the audio from video 1 to video 2 calculating the number of ms needed, but I don't need help with that. I'd love to automatize the comparison so I just have to select video 1 and video 2, nothing else, that way I could forget forever virtualdub and save a lot of time.

I'm tagging this post as powershell too because I'm making a script where at the moment I have to introduce the delay between frames (after comparing manually) myself. It would be perfect that I could add this at the beginning of the script.

Thanks!

jaimepm
  • 13
  • 5
  • So your question is "how can I compare individual frames across two video files"? Might help if you included more details about the two video file formats :-) – Mathias R. Jessen Jan 08 '21 at 12:32
  • Well, yeah, maybe that's my real question. Video file formats: .h264, .h265, divx, xvid in mkv/mp4/avi. It depends... :) – jaimepm Jan 08 '21 at 12:40
  • What _is_ your question, in your own words? – Mathias R. Jessen Jan 08 '21 at 12:42
  • How can I compare two individual frames across two videos, one at the beginning and another one at the end, so I can see if they are the same video and if so, retrieve the delay between them? – jaimepm Jan 08 '21 at 12:48
  • Based on your post, you should be able to do so by picking a frame at a low offset (say, 5000), in one video, and then comparing it to frames 0 through 10000 in the other, calculate frame offset diff once you've found a match. Creating a loop that goes through the number 0 through 10000 is trivial, so the only real question left if "How do I compare two frames and determine if they are the same?" :-) – Mathias R. Jessen Jan 08 '21 at 13:00
  • Thanks for your answer, Mathias, but to be honest I'm the same point! Hahaha. Maybe for you it is trivial to do it but I don't know where and how should I start. :( I've never done something like that. I've googled before asking and I've seen that ffmpeg should be my call, but for the moment I'm not even sure. ^^ – jaimepm Jan 08 '21 at 13:24
  • Maybe [approximate image matching](https://stackoverflow.com/q/843972/503046) would be a starting point to find out similar enough frames? – vonPryz Jan 08 '21 at 13:37
  • @MathiasR.Jessen never ceases to impress with his ability to point in the right direction. I also found this [question](https://stackoverflow.com/questions/26550642/powershell-screenshot-of-a-particular-part), which helps take screenshots from moments in videos through powershell. Integrating this into a loop like Mathias mentioned might help. Vons question also shows some starting points, the tool recommended by Tobiasque [here](http://pdiff.sourceforge.net/) might also help. – Marley Stacy Jan 08 '21 at 16:02
  • Oh, I have no idea how to confidently compare two video frames, I was merely trying to help you formulate a better question ^_^ I'd definitely follow @vonPryz' recommendation and/or try to [find ways to specifically solve that problem](https://stackoverflow.com/questions/33300789/how-to-compare-visually-two-look-alike-videos-of-different-codec-size-resoluti) :) – Mathias R. Jessen Jan 08 '21 at 16:06
  • Based on your answers I think I will keep doing it manually. It seems it's a LOT of job and I think its not worthy, because I need the exact match. Doing it myself is 100% accurate and it just takes 2-3 minutes. :) Thx anyway! – jaimepm Jan 09 '21 at 21:25

0 Answers0