|
import gradio as gr |
|
|
|
def greet(name): |
|
return "Hello " + name + "!!" |
|
|
|
demo = gr.Interface(fn=greet, inputs="text", outputs="text") |
|
demo.launch() |
|
import os |
|
from moviepy.editor import VideoFileClip, concatenate_videoclips |
|
from transformers import VideoProcessor, VideoModel |
|
|
|
|
|
def load_model(model_name): |
|
try: |
|
model = VideoModel.from_pretrained(model_name) |
|
processor = VideoProcessor.from_pretrained(model_name) |
|
return model, processor |
|
except Exception as e: |
|
print(f"Error loading model: {e}") |
|
return None, None |
|
|
|
|
|
def generate_crossover_video(video1_path, video2_path, output_path): |
|
if not os.path.isfile(video1_path): |
|
print(f"Error: {video1_path} does not exist.") |
|
return |
|
print(f"Processing Video 1: {video1_path}") |
|
|
|
if not os.path.isfile(video2_path): |
|
print(f"Error: {video2_path} does not exist.") |
|
return |
|
print(f"Processing Video 2: {video2_path}") |
|
|
|
|
|
clip1 = VideoFileClip(video1_path) |
|
clip2 = VideoFileClip(video2_path) |
|
|
|
|
|
final_clip = concatenate_videoclips([clip1, clip2]) |
|
|
|
|
|
final_clip.write_videofile(output_path, codec='libx264') |
|
print(f"Crossover video saved to {output_path}") |
|
|
|
def main(): |
|
video1_path = input("Enter the path to the first video: ") |
|
video2_path = input("Enter the path to the second video: ") |
|
output_path = input("Enter the output file path (e.g., crossover_output.mp4): ") |
|
|
|
model_name = "your_model_name" |
|
model, processor = load_model(model_name) |
|
|
|
if model is None or processor is None: |
|
print("Model loading failed. Exiting the application.") |
|
return |
|
|
|
generate_crossover_video(video1_path, video2_path, output_path) |
|
|
|
if __name__ == "__main__": |
|
main() |