#@title 🎬 AI Film Studio Pro (Complete Working Version) import gradio as gr import numpy as np import torch import random from diffusers import DiffusionPipeline from PIL import Image, ImageDraw, ImageFont # ===== CONFIG ===== SUPPORTERS = random.randint(50, 200) KO_FI_LINK = "https://ko-fi.com/fecolywill" GA_TRACKING_ID = "G-XXXXXXXXXX" # Replace with your Google Analytics ID # ===== WATERMARKER ===== class Watermarker: def __init__(self): self.font = ImageFont.load_default() self.color = (255, 255, 255, 128) # White with 50% opacity self.position = "bottom-right" self.text = "Made with AI Film Studio" def apply(self, frames): watermarked_frames = [] for frame in frames: img = Image.fromarray(frame) draw = ImageDraw.Draw(img, "RGBA") text_width = draw.textlength(self.text, font=self.font) if self.position == "bottom-right": x = img.width - text_width - 20 y = img.height - 30 elif self.position == "top-left": x, y = 20, 20 else: # center x = (img.width - text_width) // 2 y = (img.height - 30) // 2 draw.text((x, y), self.text, fill=self.color, font=self.font) watermarked_frames.append(np.array(img)) return np.stack(watermarked_frames) watermarker = Watermarker() # ===== VIDEO GENERATION ===== def generate_video(prompt): # Initialize pipeline (cached after first run) pipe = DiffusionPipeline.from_pretrained( "cerspense/zeroscope_v2_576w", torch_dtype=torch.float16 ) # Generate frames (24 frames at 576x320) frames = pipe( prompt, num_frames=24, height=320, width=576 ).frames # Apply watermark and return as numpy array return (np.stack(watermarker.apply(frames))), 12 # (frames, fps) # ===== ANALYTICS ===== analytics_js = f""" """ # ===== SUPPORT SECTION ===== support_html = f"""

❤️ Support This Project

Enjoying this free tool? Help me add more features!

☕ Buy Me a Coffee

🎉 {SUPPORTERS}+ creators have supported!

""" # ===== MAIN APP ===== with gr.Blocks(theme=gr.themes.Soft(), title="AI Film Studio Pro") as app: # Google Analytics gr.HTML(analytics_js) # Header gr.Markdown("# 🎬 AI Film Studio Pro") gr.Markdown("Generate professional videos with AI - **no experience needed!**") # Video Generation UI with gr.Tab("🎥 Video Creator"): with gr.Row(): prompt = gr.Textbox( label="Describe Your Scene", placeholder="A cyberpunk detective chases an android through neon streets...", lines=3 ) style = gr.Dropdown( ["Cinematic", "Anime", "Noir", "Cyberpunk"], label="Visual Style", value="Cinematic" ) generate_btn = gr.Button("✨ Generate Video", variant="primary") # Video output with download tracking video = gr.Video( label="Your Generated Video", show_download_button=True, interactive=False ) # Download tracking download_js = """ """ gr.HTML(download_js) # Watermark Customization with gr.Accordion("⚙️ Watermark Settings", open=False): watermark_text = gr.Textbox( label="Watermark Text", value="Made with AI Film Studio" ) watermark_color = gr.ColorPicker( label="Color", value="#ffffff" ) watermark_opacity = gr.Slider( 0, 100, value=50, label="Opacity (%)" ) watermark_position = gr.Dropdown( ["bottom-right", "top-left", "center"], label="Position", value="bottom-right" ) def update_watermark(text, color, opacity, position): r, g, b = tuple(int(color.lstrip('#')[i:i+2], 16) for i in (0, 2, 4)) watermarker.text = text watermarker.color = (r, g, b, int(255 * (opacity/100))) watermarker.position = position return "Watermark settings updated!" update_btn = gr.Button("Update Watermark") update_btn.click( fn=update_watermark, inputs=[watermark_text, watermark_color, watermark_opacity, watermark_position], outputs=gr.Textbox(visible=False) ) # Support Footer gr.HTML(support_html) # Generation function generate_btn.click( fn=generate_video, inputs=[prompt], outputs=video ).then( lambda: gr.HTML(""), outputs=None ) # ===== DEPLOYMENT ===== if __name__ == "__main__": app.launch(debug=True)