Spaces:
Sleeping
Sleeping
app.py
CHANGED
@@ -4,7 +4,7 @@ import os
|
|
4 |
|
5 |
def combine_video_subtitle(video_file, subtitle_file):
|
6 |
# Output video file name
|
7 |
-
output_file = "output_combined.mp4"
|
8 |
|
9 |
# Run ffmpeg command to combine video and subtitle
|
10 |
cmd = [
|
@@ -27,6 +27,10 @@ def combine_video_subtitle(video_file, subtitle_file):
|
|
27 |
st.title("Video Subtitle Combiner")
|
28 |
st.write("Combine a video file and a subtitle file using ffmpeg.")
|
29 |
|
|
|
|
|
|
|
|
|
30 |
video_file = st.file_uploader("Upload Video File", type=["mp4", "avi", "mov"])
|
31 |
subtitle_file = st.file_uploader("Upload Subtitle File", type=["srt"])
|
32 |
|
@@ -41,4 +45,4 @@ if video_file and subtitle_file:
|
|
41 |
st.video(video_bytes)
|
42 |
|
43 |
# Provide a link to download the combined video
|
44 |
-
st.download_button("Download Combined Video", video_bytes, file_name=
|
|
|
4 |
|
5 |
def combine_video_subtitle(video_file, subtitle_file):
|
6 |
# Output video file name
|
7 |
+
output_file = os.path.join(st.session_state.temp_dir, "output_combined.mp4")
|
8 |
|
9 |
# Run ffmpeg command to combine video and subtitle
|
10 |
cmd = [
|
|
|
27 |
st.title("Video Subtitle Combiner")
|
28 |
st.write("Combine a video file and a subtitle file using ffmpeg.")
|
29 |
|
30 |
+
# Create a temporary directory to store the output file
|
31 |
+
st.session_state.temp_dir = st.session_state.get("temp_dir", os.path.join(os.getcwd(), "temp"))
|
32 |
+
os.makedirs(st.session_state.temp_dir, exist_ok=True)
|
33 |
+
|
34 |
video_file = st.file_uploader("Upload Video File", type=["mp4", "avi", "mov"])
|
35 |
subtitle_file = st.file_uploader("Upload Subtitle File", type=["srt"])
|
36 |
|
|
|
45 |
st.video(video_bytes)
|
46 |
|
47 |
# Provide a link to download the combined video
|
48 |
+
st.download_button("Download Combined Video", video_bytes, file_name="output_combined.mp4")
|