Spaces:
Build error
Build error
Fall back to streaming as alternative for m3u8 files
Browse files- videohash.py +6 -1
videohash.py
CHANGED
|
@@ -50,7 +50,12 @@ def binary_array_to_uint8s(arr):
|
|
| 50 |
return [int(bit_string[i:i+8], 2) for i in range(0, len(bit_string), 8)]
|
| 51 |
|
| 52 |
def compute_hashes(url: str, fps=FPS):
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
for index, frame in enumerate(change_ffmpeg_fps(clip, fps).iter_frames()):
|
| 55 |
# Each frame is a triplet of size (height, width, 3) of the video since it is RGB
|
| 56 |
# The hash itself is of size (hash_size, hash_size)
|
|
|
|
| 50 |
return [int(bit_string[i:i+8], 2) for i in range(0, len(bit_string), 8)]
|
| 51 |
|
| 52 |
def compute_hashes(url: str, fps=FPS):
|
| 53 |
+
try:
|
| 54 |
+
clip = VideoFileClip(download_video_from_url(url))
|
| 55 |
+
except IOError:
|
| 56 |
+
logging.warn(f"Falling back to direct streaming from {url} because the downloaded video failed.")
|
| 57 |
+
clip = VideoFileClip(url)
|
| 58 |
+
|
| 59 |
for index, frame in enumerate(change_ffmpeg_fps(clip, fps).iter_frames()):
|
| 60 |
# Each frame is a triplet of size (height, width, 3) of the video since it is RGB
|
| 61 |
# The hash itself is of size (hash_size, hash_size)
|