Spaces:
Sleeping
Sleeping
File size: 2,379 Bytes
9180eb5 29c1346 ccfdd77 9180eb5 ccfdd77 9bff52e 9180eb5 ccfdd77 482f9ee 9180eb5 1349cb4 9180eb5 1349cb4 9180eb5 6b1a989 1349cb4 6b1a989 9bff52e 1349cb4 482f9ee 1349cb4 9bff52e 1349cb4 482f9ee 1349cb4 6b1a989 1349cb4 482f9ee 6b1a989 1349cb4 6b1a989 9bff52e 6b1a989 9180eb5 1349cb4 6b1a989 ccfdd77 9180eb5 482f9ee 9180eb5 482f9ee | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 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.")
|