Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import ffmpeg
|
|
4 |
import tempfile
|
5 |
import os
|
6 |
import shutil
|
|
|
7 |
|
8 |
def save_uploaded_file(uploaded_file):
|
9 |
try:
|
@@ -22,8 +23,14 @@ def add_hard_subtitle_to_video(input_video_path, subtitle_file_path):
|
|
22 |
output_video,
|
23 |
vf=f"subtitles={subtitle_file_path}:force_style='FontName=Arial,FontSize=24'"
|
24 |
)
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
def video_demo(video, subtitle):
|
29 |
video_path = save_uploaded_file(video)
|
|
|
4 |
import tempfile
|
5 |
import os
|
6 |
import shutil
|
7 |
+
import subprocess
|
8 |
|
9 |
def save_uploaded_file(uploaded_file):
|
10 |
try:
|
|
|
23 |
output_video,
|
24 |
vf=f"subtitles={subtitle_file_path}:force_style='FontName=Arial,FontSize=24'"
|
25 |
)
|
26 |
+
try:
|
27 |
+
# Use subprocess to capture stdout and stderr
|
28 |
+
out, err = ffmpeg.run(stream, overwrite_output=True, capture_stdout=True, capture_stderr=True)
|
29 |
+
return output_video
|
30 |
+
except ffmpeg.Error as e:
|
31 |
+
# Print stderr to Streamlit to help diagnose the issue
|
32 |
+
st.error(f"FFMPEG error: {e.stderr}")
|
33 |
+
return None
|
34 |
|
35 |
def video_demo(video, subtitle):
|
36 |
video_path = save_uploaded_file(video)
|