Support file:// scheme in load_video (#13076)
Signed-off-by: Netanel Haber <58652339+netanel-haber@users.noreply.github.com>
This commit is contained in:
@@ -69,6 +69,7 @@ from typing import (
|
|||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import orjson
|
import orjson
|
||||||
@@ -945,7 +946,8 @@ def load_video(video_file: Union[str, bytes], use_gpu: bool = True):
|
|||||||
tmp_file.write(video_bytes)
|
tmp_file.write(video_bytes)
|
||||||
tmp_file.close()
|
tmp_file.close()
|
||||||
vr = VideoReader(tmp_file.name, ctx=ctx)
|
vr = VideoReader(tmp_file.name, ctx=ctx)
|
||||||
elif os.path.isfile(video_file):
|
# `urlparse` supports file:// paths, and so does VideoReader
|
||||||
|
elif os.path.isfile(urlparse(video_file).path):
|
||||||
vr = VideoReader(video_file, ctx=ctx)
|
vr = VideoReader(video_file, ctx=ctx)
|
||||||
else:
|
else:
|
||||||
video_bytes = pybase64.b64decode(video_file, validate=True)
|
video_bytes = pybase64.b64decode(video_file, validate=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user