pixop / video-compare

Split screen video comparison tool using FFmpeg and SDL2
GNU General Public License v2.0
889 stars 41 forks source link

sync and time control issues when framerates are not identical #43

Closed chrizilla closed 1 year ago

chrizilla commented 1 year ago

Your tool would really be a godsend, but I cannot get it to work properly. In my tests, the side-by-side comparison works in sync during playback, but when pausing, the videos slip out of snyc.

When I pause the videos and drag the slider left/right, it is obvious that the frames are not in sync. So I tried the +/- hotkeys. They way I understand them to work is: Left video is frozen and right video goes forward/backward frame-by-frame. But on my computer, both videos jump to another position.

This is unfortunate, because it is difficult to compare a moving image (only) and I cannot compare still images when they are out of sync.

chrizilla commented 1 year ago

I think I have found the problem: The framerate seems different in the videos (50fps vs 25fps). I had made sure to check the values, but somehow I seem to have overlooked the discrepancy, because I could have sworn they had the same value when I first looked ... :-)

I compared 2 videos with identical framerate and it worked fine.

chrizilla commented 1 year ago

README: "for the best result video files should have the same frame rate"

I read this beforehand, so I was prepared that problems will be encountered with different frame rate, but I wasn't expecting the handling to be so dramatically different. I know it is asking probably too much, because the program isn't expected to work with videos with differing frame rates, but isn't there anything that could be done to improve the handling of the sync and time control (as described in the OP) ? I wouldn't have expected the handling to be so broken (especially in very straightforward cases such as this with exactly twice the frame rate, where every 2 frames should coincide).

jonfryd commented 1 year ago

Hi @chrizilla,

Sure, you can use the FFmpeg fps filter to harmonize the frame rates of your videos. Assuming video1.mp4 is your 25 FPS video and video2.mp4 is the 50 FPS counterpart...

./video-compare -l fps=50 video1.mp4 video2.mp4 (up-convert the frame rate of video1.mp4 to 50 FPS)

or

./video-compare -r fps=25 video1.mp4 video2.mp4 (down-convert the frame rate of video2.mp4 to 25 FPS)

chrizilla commented 1 year ago

@jonfryd : Thanks so much, this is excellent!! Would there be any downside in automatically detecting and harmonizing diverging frame rates ?

jonfryd commented 1 year ago

@jonfryd : Thanks so much, this is excellent!!

Happy to help 👍

Would there be any downside in automatically detecting and harmonizing diverging frame rates ?

I think harmonizing the frame rate is likely the preferred behaviour for most people and use cases. I'll consider it as an improvement for the future. This is a change that requires some careful thought in terms of how to deal with non-trivial cases such as VFR frame rates for example and I don't feel like I have all the answers at this point.

Thanks for your input! I'm closing this one for now.

chrizilla commented 1 year ago

Thanks for your comment and again thanks for your amazing app. You just saved my HDD from exploding because now I can compare compare and delete duplicate videos creating some space on my HDD again. Thanks so much, it really means a lot to me.

As for the issue at hand: The only problem I see with harmonizing the frame rate by default is that there should be an override switch allowing the user to compare the original (diverging) framerates for whatever reason (even if I don't see any good reason to do so given that apparently the videos cannot be synced and handling is almost impossible with diverging framerates) .... but what do I know, maybe there is some good reason I just cannot see so there should be a possibility for comparison of the original framerates too.

This would be the best of both worlds, since the user CAN have harmonized framerates but doesn't have to. When the user has this choice, I don't see any possible disadvantage.

jonfryd commented 10 months ago

@chrizilla,

I just pushed a commit to the master branch that attempts to automatically harmonize the frame rate:

https://github.com/pixop/video-compare/commit/d49651216a19caff9a43914032162d1452c7b821

jonfryd commented 7 months ago

@chrizilla, I've released the frame rate harmonization feature in today's release. Feel free to give it a try.