import streamlit as st from moviepy.editor import VideoFileClip, CompositeVideoClip, ImageClip from PIL import Image import tempfile import os # Streamlit başlığı st.title("Add Watermark on your video for FREE") # Video ve logo dosyasını yükleme video_file = st.file_uploader("Upload a video file", type=["mp4", "mov", "avi"]) logo_file = st.file_uploader("Upload a logo file", type=["png", "jpg", "jpeg"]) # Ekran ayarları if video_file and logo_file: # Geçici dosyalar with tempfile.NamedTemporaryFile(delete=False) as tmp_video: tmp_video.write(video_file.read()) video_path = tmp_video.name with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp_logo: tmp_logo.write(logo_file.read()) logo_path = tmp_logo.name # Logoyu yükle ve boyutlandırma ayarlarını göster video_clip = VideoFileClip(video_path) logo_clip = ImageClip(logo_path).set_duration(video_clip.duration) st.sidebar.header("Logo Settings") # Logonun boyutu logo_height = st.sidebar.slider("Logo size (pixel). (It proportions width and height of your logo", min_value=50, max_value=500, value=150) # Logonun konumu position_options = { "Left Top": ("left", "top"), "Right Top": ("right", "top"), "Left Bottom": ("left", "bottom"), "Right Bottom": ("right", "bottom") } logo_position = st.sidebar.selectbox("Position of Logo", options=list(position_options.keys())) position = position_options[logo_position] # Logoyu boyutlandırma ve yerleştirme logo_clip = logo_clip.resize(height=logo_height).set_position(position) st.header("Sample") st.video(video_path) # Örnek video # Logoyu videoya eklemek için CompositeVideoClip kullanma final_clip = CompositeVideoClip([video_clip, logo_clip]) if st.button("Process and Download"): # Sonuç videosunu geçici olarak kaydetme output_path = os.path.join(tempfile.gettempdir(), "output.mp4") final_clip.write_videofile(output_path, codec="libx264", threads=4) # Kullanıcıya video indir butonu with open(output_path, "rb") as output_file: st.download_button(label="Download Video", data=output_file, file_name="video_with_logo.mp4", mime="video/mp4") else: st.write("Please upload a video and logo.")