berkaydun commited on
Commit
1349cb4
·
verified ·
1 Parent(s): 44bf667

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -26
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
- # İlerleme çubuğu
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
- # İlerleme çubuğu
25
- progress_bar = st.progress(0)
26
- progress_text = st.empty()
27
-
28
- # Video işlemi başlıyor
29
- try:
30
- # Video ve logo dosyasını yükleme
31
- video_clip = VideoFileClip(video_path)
32
- logo_clip = ImageClip(logo_path).set_duration(video_clip.duration)
33
-
34
- # Logoyu boyutlandırma ve yerleştirme
35
- logo_clip = logo_clip.resize(height=250).set_position(("left", "top"))
36
-
37
- # Logoyu videoya eklemek için CompositeVideoClip kullanma
38
- final_clip = CompositeVideoClip([video_clip, logo_clip])
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.")