Spaces:
Runtime error
Runtime error
jhj0517
commited on
Commit
•
9d18995
1
Parent(s):
f3cdbdc
Enable overwriting
Browse files- modules/video_utils.py +6 -2
modules/video_utils.py
CHANGED
@@ -22,6 +22,7 @@ def extract_frames(
|
|
22 |
|
23 |
command = [
|
24 |
'ffmpeg',
|
|
|
25 |
'-i', vid_input,
|
26 |
'-q:v', str(quality),
|
27 |
'-start_number', str(start_number),
|
@@ -31,12 +32,13 @@ def extract_frames(
|
|
31 |
try:
|
32 |
subprocess.run(command, check=True)
|
33 |
except subprocess.CalledProcessError as e:
|
34 |
-
logger.exception("Error
|
35 |
raise f"An error occurred: {str(e)}"
|
36 |
|
37 |
|
38 |
def get_frames_from_dir(vid_dir: str,
|
39 |
available_extensions: Optional[Union[List, str]] = None) -> List:
|
|
|
40 |
if available_extensions is None:
|
41 |
available_extensions = [".jpg", ".jpeg", ".JPG", ".JPEG"]
|
42 |
|
@@ -50,7 +52,9 @@ def get_frames_from_dir(vid_dir: str,
|
|
50 |
if not frame_names:
|
51 |
return []
|
52 |
frame_names.sort(key=lambda x: int(os.path.splitext(x)[0]))
|
53 |
-
|
|
|
|
|
54 |
|
55 |
|
56 |
def clean_image_files(image_dir: str):
|
|
|
22 |
|
23 |
command = [
|
24 |
'ffmpeg',
|
25 |
+
'-y', # Enable overwriting
|
26 |
'-i', vid_input,
|
27 |
'-q:v', str(quality),
|
28 |
'-start_number', str(start_number),
|
|
|
32 |
try:
|
33 |
subprocess.run(command, check=True)
|
34 |
except subprocess.CalledProcessError as e:
|
35 |
+
logger.exception("Error occurred while extracting frames from the video")
|
36 |
raise f"An error occurred: {str(e)}"
|
37 |
|
38 |
|
39 |
def get_frames_from_dir(vid_dir: str,
|
40 |
available_extensions: Optional[Union[List, str]] = None) -> List:
|
41 |
+
"""Get image file paths list from the dir"""
|
42 |
if available_extensions is None:
|
43 |
available_extensions = [".jpg", ".jpeg", ".JPG", ".JPEG"]
|
44 |
|
|
|
52 |
if not frame_names:
|
53 |
return []
|
54 |
frame_names.sort(key=lambda x: int(os.path.splitext(x)[0]))
|
55 |
+
|
56 |
+
frames = [os.path.join(vid_dir, name) for name in frame_names]
|
57 |
+
return frames
|
58 |
|
59 |
|
60 |
def clean_image_files(image_dir: str):
|