mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 08:48:13 +00:00
Fix issue with getting frame count from webm files in ffmpeg
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
import time
|
||||
import ffmpeg
|
||||
from utilities.render_worker import *
|
||||
|
||||
|
||||
@@ -14,14 +13,11 @@ class FFMPEGRenderWorker(BaseRenderWorker):
|
||||
super(FFMPEGRenderWorker, self).__init__(input_path=input_path, output_path=output_path, ignore_extensions=True,
|
||||
args=args)
|
||||
|
||||
self.total_frames = -1
|
||||
if os.path.exists(input_path):
|
||||
media_stats = ffmpeg.probe(input_path)
|
||||
for stream in media_stats['streams']:
|
||||
if stream['codec_type'] == 'video':
|
||||
self.total_frames = stream['nb_frames']
|
||||
break
|
||||
|
||||
stream_info = subprocess.check_output([self.renderer_path(), "-i", # https://stackoverflow.com/a/61604105
|
||||
input_path, "-map", "0:v:0", "-c", "copy", "-f", "null", "-y",
|
||||
"/dev/null"], stderr=subprocess.STDOUT).decode('utf-8')
|
||||
found_frames = re.findall('frame=\s*(\d+)', stream_info)
|
||||
self.total_frames = found_frames[-1] if found_frames else '-1'
|
||||
self.frame = 0
|
||||
|
||||
# Stats
|
||||
|
||||
Reference in New Issue
Block a user