Spaces:
Sleeping
Sleeping
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import subprocess
|
3 |
+
|
4 |
+
def combine_video_subtitle(video_file, subtitle_file):
|
5 |
+
# Output video file name
|
6 |
+
output_file = "output_combined.mp4"
|
7 |
+
|
8 |
+
# Run ffmpeg command to combine video and subtitle
|
9 |
+
cmd = [
|
10 |
+
"ffmpeg",
|
11 |
+
"-i", video_file.name,
|
12 |
+
"-i", subtitle_file.name,
|
13 |
+
"-c:v", "copy",
|
14 |
+
"-c:a", "copy",
|
15 |
+
"-c:s", "mov_text",
|
16 |
+
"-map", "0:v:0",
|
17 |
+
"-map", "0:a:0",
|
18 |
+
"-map", "1",
|
19 |
+
output_file
|
20 |
+
]
|
21 |
+
|
22 |
+
subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
23 |
+
return output_file
|
24 |
+
|
25 |
+
# Streamlit UI
|
26 |
+
st.title("Video Subtitle Combiner")
|
27 |
+
st.write("Combine a video file and a subtitle file using ffmpeg.")
|
28 |
+
|
29 |
+
video_file = st.file_uploader("Upload Video File", type=["mp4", "avi", "mov"])
|
30 |
+
subtitle_file = st.file_uploader("Upload Subtitle File", type=["srt"])
|
31 |
+
|
32 |
+
if video_file and subtitle_file:
|
33 |
+
st.write("Combining... Please wait.")
|
34 |
+
output_filename = combine_video_subtitle(video_file, subtitle_file)
|
35 |
+
st.success("Video and subtitle combined successfully!")
|
36 |
+
st.video(output_filename)
|