File tree 1 file changed +14
-4
lines changed
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 12
12
import imageio .plugins .ffmpeg
13
13
import cv2
14
14
import sys
15
+ import math
15
16
import signal
16
17
import platform
17
18
from moviepy .editor import *
@@ -309,10 +310,19 @@ def video_detect(
309
310
read_iter = cam_read_iter (reader )
310
311
else :
311
312
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
316
326
if nested :
317
327
bar = tqdm (dynamic_ncols = True , total = nframes , position = 1 , leave = True )
318
328
else :
You can’t perform that action at this time.
0 commit comments