Pepguy commited on
Commit
8144385
·
verified ·
1 Parent(s): 85c5362

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -22,8 +22,10 @@ async def process(req: VideoJsonRequest):
22
  with open(v_p, "wb") as f: f.write(base64.b64decode(req.video_base64))
23
  probe = subprocess.run(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", v_p], capture_output=True, text=True).stdout
24
  dur = float(probe.strip() or 0)
 
 
25
  # Extract 15 frames
26
- subprocess.run(["ffmpeg", "-y", "-i", v_p, "-vf", f"fps={1/max(dur,1)}", "-vframes", "15", "-q:v", "5", f"{tmp}/f_%03d.jpg"])
27
  # Transcribe
28
  subprocess.run(["ffmpeg", "-y", "-i", v_p, "-vn", "-acodec", "pcm_s16le", "-ar", "16000", "-ac", "1", a_p])
29
  txt = whisper_model.transcribe(a_p)["text"].strip()
 
22
  with open(v_p, "wb") as f: f.write(base64.b64decode(req.video_base64))
23
  probe = subprocess.run(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", v_p], capture_output=True, text=True).stdout
24
  dur = float(probe.strip() or 0)
25
+ print(f"fps={1/max(dur,1)}")
26
+ f"fps={15/max(dur,1)}",
27
  # Extract 15 frames
28
+ subprocess.run(["ffmpeg", "-y", "-i", v_p, "-vf", f"fps={15/max(dur,1)}", "-vframes", "15", "-q:v", "5", f"{tmp}/f_%03d.jpg"])
29
  # Transcribe
30
  subprocess.run(["ffmpeg", "-y", "-i", v_p, "-vn", "-acodec", "pcm_s16le", "-ar", "16000", "-ac", "1", a_p])
31
  txt = whisper_model.transcribe(a_p)["text"].strip()