Spaces:
Running
Running
Commit
·
2213012
1
Parent(s):
4fbbf74
Refactor video_service.py to update fingerprinting logic and variable names
Browse files
app/services/video_service.py
CHANGED
@@ -77,8 +77,8 @@ async def fingerprint_video(video_url):
|
|
77 |
return {
|
78 |
'frame_hashes': frame_hashes,
|
79 |
'audio_hashes': audio_hashes,
|
80 |
-
'
|
81 |
-
'
|
82 |
}
|
83 |
finally:
|
84 |
if firebase_filename:
|
@@ -88,8 +88,8 @@ async def compare_videos(video_url1, video_url2):
|
|
88 |
fp1 = await fingerprint_video(video_url1)
|
89 |
fp2 = await fingerprint_video(video_url2)
|
90 |
|
91 |
-
video_similarity = 1 - (imagehash.hex_to_hash(fp1['
|
92 |
-
audio_similarity = 1 - (imagehash.hex_to_hash(fp1['
|
93 |
|
94 |
overall_similarity = (video_similarity + audio_similarity) / 2
|
95 |
is_same_content = overall_similarity > 0.9 # You can adjust this threshold
|
|
|
77 |
return {
|
78 |
'frame_hashes': frame_hashes,
|
79 |
'audio_hashes': audio_hashes,
|
80 |
+
'audio_hash': str(collective_audio_hash) if collective_audio_hash else None,
|
81 |
+
'video_hash': str(video_hash),
|
82 |
}
|
83 |
finally:
|
84 |
if firebase_filename:
|
|
|
88 |
fp1 = await fingerprint_video(video_url1)
|
89 |
fp2 = await fingerprint_video(video_url2)
|
90 |
|
91 |
+
video_similarity = 1 - (imagehash.hex_to_hash(fp1['video_hash']) - imagehash.hex_to_hash(fp2['video_hash'])) / 64.0
|
92 |
+
audio_similarity = 1 - (imagehash.hex_to_hash(fp1['audio_hash']) - imagehash.hex_to_hash(fp2['audio_hash'])) / 64.0 if fp1['audio_hash'] and fp2['audio_hash'] else 0
|
93 |
|
94 |
overall_similarity = (video_similarity + audio_similarity) / 2
|
95 |
is_same_content = overall_similarity > 0.9 # You can adjust this threshold
|