Pepguy commited on
Commit
2fa21b8
·
verified ·
1 Parent(s): 8144385

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -22,10 +22,12 @@ 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
  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()
 
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("-------------------")
26
+ print(f"fps={8/max(dur,1)}")
27
  print(f"fps={1/max(dur,1)}")
28
+ print("-------------------")
29
  # Extract 15 frames
30
+ subprocess.run(["ffmpeg", "-y", "-i", v_p, "-vf", f"fps={8/max(dur,1)}", "-vframes", "15", "-q:v", "5", f"{tmp}/f_%03d.jpg"])
31
  # Transcribe
32
  subprocess.run(["ffmpeg", "-y", "-i", v_p, "-vn", "-acodec", "pcm_s16le", "-ar", "16000", "-ac", "1", a_p])
33
  txt = whisper_model.transcribe(a_p)["text"].strip()