Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,8 +11,9 @@ st.title("Videoya Logo Ekleme Uygulaması")
|
|
| 11 |
video_file = st.file_uploader("Bir video dosyası yükleyin", type=["mp4", "mov", "avi"])
|
| 12 |
logo_file = st.file_uploader("Bir logo dosyası yükleyin", type=["png", "jpg", "jpeg"])
|
| 13 |
|
| 14 |
-
#
|
| 15 |
if video_file and logo_file:
|
|
|
|
| 16 |
with tempfile.NamedTemporaryFile(delete=False) as tmp_video:
|
| 17 |
tmp_video.write(video_file.read())
|
| 18 |
video_path = tmp_video.name
|
|
@@ -21,36 +22,42 @@ if video_file and logo_file:
|
|
| 21 |
tmp_logo.write(logo_file.read())
|
| 22 |
logo_path = tmp_logo.name
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
# Sonuç videosunu geçici olarak kaydetme
|
| 41 |
output_path = os.path.join(tempfile.gettempdir(), "output.mp4")
|
| 42 |
-
final_clip.write_videofile(output_path, codec="libx264")
|
| 43 |
-
|
| 44 |
-
# İlerleme çubuğunu tamamla
|
| 45 |
-
progress_bar.progress(100)
|
| 46 |
-
progress_text.text("İşlem tamamlandı!")
|
| 47 |
-
|
| 48 |
# Kullanıcıya video indir butonu
|
| 49 |
with open(output_path, "rb") as output_file:
|
| 50 |
st.download_button(label="Videoyu İndir", data=output_file, file_name="video_with_logo.mp4", mime="video/mp4")
|
| 51 |
|
| 52 |
-
except Exception as e:
|
| 53 |
-
st.error(f"Bir hata oluştu: {e}")
|
| 54 |
-
|
| 55 |
else:
|
| 56 |
st.write("Lütfen bir video ve logo dosyası yükleyin.")
|
|
|
|
| 11 |
video_file = st.file_uploader("Bir video dosyası yükleyin", type=["mp4", "mov", "avi"])
|
| 12 |
logo_file = st.file_uploader("Bir logo dosyası yükleyin", type=["png", "jpg", "jpeg"])
|
| 13 |
|
| 14 |
+
# Ekran ayarları
|
| 15 |
if video_file and logo_file:
|
| 16 |
+
# Geçici dosyalar
|
| 17 |
with tempfile.NamedTemporaryFile(delete=False) as tmp_video:
|
| 18 |
tmp_video.write(video_file.read())
|
| 19 |
video_path = tmp_video.name
|
|
|
|
| 22 |
tmp_logo.write(logo_file.read())
|
| 23 |
logo_path = tmp_logo.name
|
| 24 |
|
| 25 |
+
# Logoyu yükle ve boyutlandırma ayarlarını göster
|
| 26 |
+
video_clip = VideoFileClip(video_path)
|
| 27 |
+
logo_clip = ImageClip(logo_path).set_duration(video_clip.duration)
|
| 28 |
+
|
| 29 |
+
st.sidebar.header("Logo Ayarları")
|
| 30 |
+
|
| 31 |
+
# Logonun boyutu
|
| 32 |
+
logo_height = st.sidebar.slider("Logonun yüksekliği (piksel)", min_value=50, max_value=500, value=150)
|
| 33 |
+
|
| 34 |
+
# Logonun konumu
|
| 35 |
+
position_options = {
|
| 36 |
+
"Sol Üst": ("left", "top"),
|
| 37 |
+
"Sağ Üst": ("right", "top"),
|
| 38 |
+
"Sol Alt": ("left", "bottom"),
|
| 39 |
+
"Sağ Alt": ("right", "bottom")
|
| 40 |
+
}
|
| 41 |
+
logo_position = st.sidebar.selectbox("Logonun konumu", options=list(position_options.keys()))
|
| 42 |
+
position = position_options[logo_position]
|
| 43 |
+
|
| 44 |
+
# Logoyu boyutlandırma ve yerleştirme
|
| 45 |
+
logo_clip = logo_clip.resize(height=logo_height).set_position(position)
|
| 46 |
+
|
| 47 |
+
st.header("Örnek Ekran")
|
| 48 |
+
st.video(video_path) # Örnek video
|
| 49 |
+
|
| 50 |
+
# Logoyu videoya eklemek için CompositeVideoClip kullanma
|
| 51 |
+
final_clip = CompositeVideoClip([video_clip, logo_clip])
|
| 52 |
+
|
| 53 |
+
if st.button("Videoyu İşle ve İndir"):
|
| 54 |
# Sonuç videosunu geçici olarak kaydetme
|
| 55 |
output_path = os.path.join(tempfile.gettempdir(), "output.mp4")
|
| 56 |
+
final_clip.write_videofile(output_path, codec="libx264", threads=4)
|
| 57 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
# Kullanıcıya video indir butonu
|
| 59 |
with open(output_path, "rb") as output_file:
|
| 60 |
st.download_button(label="Videoyu İndir", data=output_file, file_name="video_with_logo.mp4", mime="video/mp4")
|
| 61 |
|
|
|
|
|
|
|
|
|
|
| 62 |
else:
|
| 63 |
st.write("Lütfen bir video ve logo dosyası yükleyin.")
|