-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pHash does not work with MKV and WebM files #36
Comments
I ran into another issue with the above approach: for some WEBM and MKV videos, pHash returns 0 hashes. Cause: the frame count calculated in the above snippet is only an estimate. However, in If the frame count is an overestimation, the last portion of the video is simply ignored, which is only slightly less bad. Solution: allocate space in the --- a/src/pHash.cpp
+++ b/src/pHash.cpp
@@ -354,6 +354,7 @@ CImgList<uint8_t> *ph_getKeyFramesFromVideo(const char *filename) {
if (N <= 0) {
return NULL;
}
+ N *= 1.2f;
float frames_per_sec = 0.5 * fps(filename);
if (frames_per_sec < 0) {
@@ -413,6 +414,8 @@ CImgList<uint8_t> *ph_getKeyFramesFromVideo(const char *filename) {
} while ((nbread >= st_info.nb_retrieval) && (k < nbframes));
vfinfo_close(&st_info);
+ nbframes = k;
+
int S = 10;
int L = 50;
int alpha1 = 3; An alternative approach to the first half of the patch would be to change the snippet in the OP to overestimate by 20%, instead of doing it here. This would avoid some overallocation when the frame count is not an estimate, such as for MP4 containers, but would tie |
GetNumberVideoFrames()
only checks for per-stream frame counts or durations, which MKV and WebM containers do not include in their headers. This causes the hashing of these files to fail almost before it even begins.Solution: adding another fallback resolves that situation and in my (limited) tests allows pHash to work with MKV and WebM containers as well:
The text was updated successfully, but these errors were encountered: