|
import os |
|
import requests |
|
import gradio as gr |
|
from moviepy.editor import (ImageClip, TextClip, CompositeVideoClip, |
|
concatenate_videoclips, AudioFileClip) |
|
|
|
|
|
def download_file(url, filename): |
|
response = requests.get(url) |
|
with open(filename, 'wb') as f: |
|
f.write(response.content) |
|
return filename |
|
|
|
def generate_video(): |
|
|
|
scene1_url = "https://api.deepai.org/job-view-file/1584dd41-22dc-42af-a53a-921cf005842d/outputs/output.jpg" |
|
scene2_url = "https://api.deepai.org/job-view-file/d211f739-cfc3-4605-8991-1812621ca20a/outputs/output.jpg" |
|
scene3_url = "https://api.deepai.org/job-view-file/e1f56cf2-906d-4e29-a76b-07a321892f11/outputs/output.jpg" |
|
|
|
|
|
glitch_url = "https://i.giphy.com/l378vMZ1IbLcmj3H2.webp" |
|
|
|
|
|
sound_url = "https://www.myinstants.com/media/sounds/five-nights-at-freddys-2-full-scream-sound.mp3" |
|
|
|
|
|
scene1_file = download_file(scene1_url, "scene1.jpg") |
|
scene2_file = download_file(scene2_url, "scene2.jpg") |
|
scene3_file = download_file(scene3_url, "scene3.jpg") |
|
glitch_file = download_file(glitch_url, "glitch.webp") |
|
sound_file = download_file(sound_url, "jumpscare.mp3") |
|
|
|
|
|
duration1 = 10 |
|
duration2 = 10 |
|
duration3 = 10 |
|
|
|
|
|
clip1 = ImageClip(scene1_file).set_duration(duration1).resize((640, 480)) |
|
clip2 = ImageClip(scene2_file).set_duration(duration2).resize((640, 480)) |
|
clip3 = ImageClip(scene3_file).set_duration(duration3).resize((640, 480)) |
|
|
|
|
|
text1 = TextClip("Scene 1", fontsize=40, color='white', bg_color='black')\ |
|
.set_duration(duration1).set_position('bottom') |
|
text2 = TextClip("Scene 2", fontsize=40, color='white', bg_color='black')\ |
|
.set_duration(duration2).set_position('bottom') |
|
text3 = TextClip("Scene 3", fontsize=40, color='white', bg_color='black')\ |
|
.set_duration(duration3).set_position('bottom') |
|
|
|
|
|
scene1 = CompositeVideoClip([clip1, text1]) |
|
scene2 = CompositeVideoClip([clip2, text2]) |
|
scene3 = CompositeVideoClip([clip3, text3]) |
|
|
|
|
|
base_video = concatenate_videoclips([scene1, scene2, scene3], method="compose") |
|
|
|
|
|
glitch_clip = ImageClip(glitch_file).set_duration(base_video.duration)\ |
|
.resize((640, 480)).set_opacity(0.3) |
|
video_with_glitch = CompositeVideoClip([base_video, glitch_clip]) |
|
|
|
|
|
audio_clip = AudioFileClip(sound_file) |
|
final_video = video_with_glitch.set_audio(audio_clip) |
|
|
|
|
|
output_filename = "analog_horror_video.mp4" |
|
final_video.write_videofile(output_filename, codec="libx264", fps=24) |
|
|
|
|
|
return output_filename |
|
|
|
|
|
iface = gr.Interface( |
|
fn=generate_video, |
|
inputs=[], |
|
outputs=gr.Video(label="Analog Horror Video"), |
|
title="Analog Horror Video Generator", |
|
description="Generates an analog horror video with glitch effects and jumpscare sound." |
|
) |
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|