Hieucyber2208 commited on
Commit
864775e
·
verified ·
1 Parent(s): eb133a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -24
app.py CHANGED
@@ -8,11 +8,9 @@ except RuntimeError:
8
  import streamlit as st
9
  from main import main
10
  import os
11
- import subprocess
12
 
13
  # Định nghĩa đường dẫn video đầu ra
14
  OUTPUT_VIDEO_PATH = "final_output.mp4"
15
- OUTPUT_VIDEO_FIXED_PATH = "final_output_fixed.mp4"
16
 
17
  # Tiêu đề ứng dụng
18
  st.set_page_config(page_title="KnowFlow", page_icon="📖")
@@ -76,24 +74,6 @@ art_style = st.text_input("🖌️ Image Description Style", placeholder="Exampl
76
  style = st.text_input("🎨 Image Style", placeholder="Example: realistic, anime,...")
77
  color_palette = st.text_input("🌈 Color Palette", placeholder="Example: vibrant, monochrome,...")
78
 
79
- def convert_audio_format(video_input, video_output):
80
- """Chuyển đổi định dạng âm thanh của video sang AAC."""
81
- if not os.path.exists(video_input):
82
- raise FileNotFoundError(f"File '{video_input}' không tồn tại!")
83
-
84
- command = [
85
- "ffmpeg", "-i", video_input,
86
- "-c:v", "copy", "-c:a", "aac", "-b:a", "192k",
87
- "-y", # Ghi đè nếu file output đã tồn tại
88
- video_output
89
- ]
90
-
91
- try:
92
- subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
93
- print(f"✅ Chuyển đổi thành công: {video_output}")
94
- except subprocess.CalledProcessError as e:
95
- print(f"❌ Lỗi khi chuyển đổi video: {e.stderr.decode()}")
96
-
97
  # Nút chạy pipeline
98
  if st.button("🚀 Generate Video"):
99
  if file_path and os.path.exists(file_path):
@@ -103,12 +83,9 @@ if st.button("🚀 Generate Video"):
103
  # Kiểm tra xem video đã được tạo chưa
104
  if os.path.exists(OUTPUT_VIDEO_PATH):
105
  st.success("🎉 Video generated successfully!")
106
-
107
- # Chuyển đổi định dạng âm thanh
108
- convert_audio_format(OUTPUT_VIDEO_PATH, OUTPUT_VIDEO_FIXED_PATH)
109
 
110
  # Tạo link tải về
111
- with open(OUTPUT_VIDEO_FIXED_PATH, "rb") as video_file:
112
  st.download_button(label="📥 Download Video", data=video_file, file_name="final_output_fixed.mp4", mime="video/mp4")
113
  else:
114
  st.error("⚠️ Video generation failed. Please check the logs.")
 
8
  import streamlit as st
9
  from main import main
10
  import os
 
11
 
12
  # Định nghĩa đường dẫn video đầu ra
13
  OUTPUT_VIDEO_PATH = "final_output.mp4"
 
14
 
15
  # Tiêu đề ứng dụng
16
  st.set_page_config(page_title="KnowFlow", page_icon="📖")
 
74
  style = st.text_input("🎨 Image Style", placeholder="Example: realistic, anime,...")
75
  color_palette = st.text_input("🌈 Color Palette", placeholder="Example: vibrant, monochrome,...")
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  # Nút chạy pipeline
78
  if st.button("🚀 Generate Video"):
79
  if file_path and os.path.exists(file_path):
 
83
  # Kiểm tra xem video đã được tạo chưa
84
  if os.path.exists(OUTPUT_VIDEO_PATH):
85
  st.success("🎉 Video generated successfully!")
 
 
 
86
 
87
  # Tạo link tải về
88
+ with open(OUTPUT_VIDEO_PATH, "rb") as video_file:
89
  st.download_button(label="📥 Download Video", data=video_file, file_name="final_output_fixed.mp4", mime="video/mp4")
90
  else:
91
  st.error("⚠️ Video generation failed. Please check the logs.")