akamhy / videohash

Near Duplicate Video Detection (Perceptual Video Hashing) - Get a 64-bit comparable hash-value for any video.

Home Page:https://pypi.org/project/videohash

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Long Video might fail to maketile due to the jpeg format

runck opened this issue · comments

commented

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!

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.

self.horizontally_concatenated_image_path = os.path.join(
self.horizontally_concatenated_image_dir,
"horizontally_concatenated_image.png",
)

^ 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.

commented

That's good news. Thank you!