akamhy / videohash

Near Duplicate Video Detection (Perceptual Video Hashing) - Get a 64-bit comparable hash-value for any video.
https://pypi.org/project/videohash
MIT License
264 stars 41 forks source link

Long Video might fail to maketile due to the jpeg format #91

Closed runck closed 2 years ago

runck commented 2 years ago

Problem: When I try to get the hash of a long video (about 90 min), it turns out errors when making tile: "encoder error -2 when writing image file" and "Maximum supported image dimension is 65500 pixels".

My solution now: Instead of just changing the frame_interval to shorten the width, I found that it might be a limit of the jpeg format. So the solution I am using is to change the default output of the function "make_tile" in "tilemaker.py" to png format: save_tiles(tiles, prefix="tile", directory=tiles_dir, file_format="png")

Suggestion: Now, there is no error. However, I am not sure if this will affect the hash value (as generated with jpeg format), or if any confilct to any part of this lib. As I notice the default parameter of "file_format" in th function "save_tiles" is already png, I am confused why the jpeg format is explictly given in the function "make_tile". If there is no other problem, maybe using png as the default in "make_tile" is better considering some long videos?

Thank you!

akamhy commented 2 years ago

I was aware of the limit of jpeg but didn't thought it would be an issue with the tiles, of course I'm wrong as longer video duration will not only result in a wider horizontally_concatenated_image.png but also generate wider tiles.

https://github.com/akamhy/videohash/blob/735d063a48487f8a2babb0a0305347ccfd61677c/videohash/videohash.py#L90-L93

akamhy commented 2 years ago

^ Now, there is no error. However, I am not sure if this will affect the hash value (as generated with jpeg format), or if any confilct to any part of this lib.

It didn't affect the test cases, also even if it results in some pixel column in a different tile than in the jpeg codec it can't change the dominant colour.

runck commented 2 years ago

That's good news. Thank you!