Skip to content

Commit 7d9002d

Browse files
committed
Adjusting the frame and bar if fps is specified
Idea for adjusting the bar to be the new fps if specified so the bar progress completes. ORB-HD#18 (comment)
1 parent 0e40f71 commit 7d9002d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

anonfaces/main/main.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import imageio.plugins.ffmpeg
1313
import cv2
1414
import sys
15+
import math
1516
import signal
1617
import platform
1718
from moviepy.editor import *
@@ -309,10 +310,19 @@ def video_detect(
309310
read_iter = cam_read_iter(reader)
310311
else:
311312
read_iter = reader.iter_data()
312-
if platform.system() == "Darwin":
313-
nframes = None # Frame counting fails on macOS - do not have a mac to test - someone? anyone?
314-
else:
315-
nframes = reader.count_frames()
313+
try:
314+
if platform.system() != "Darwin":
315+
total_frames = reader.count_frames()
316+
original_fps = meta.get('fps', 30) # Default to 30 FPS if not provided
317+
specified_fps = ffmpeg_config.get('fps', original_fps)
318+
319+
# Calculate adjusted total frames based on specified FPS
320+
nframes = math.ceil(total_frames * (specified_fps / original_fps))
321+
else:
322+
nframes = None # Frame counting fails on macOS - do not have a mac to test - someone? anyone?
323+
except:
324+
nframes = None # Fallback if counting frames fail
325+
# Now intialize the progress bars with the adjusted nframes
316326
if nested:
317327
bar = tqdm(dynamic_ncols=True, total=nframes, position=1, leave=True)
318328
else:

0 commit comments

Comments
 (0)