Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
| 27 |
# Extract 15 frames
|
| 28 |
-
subprocess.run(["ffmpeg", "-y", "-i", v_p, "-vf", f"fps={
|
| 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()
|