#!/usr/bin/env python3 """ Auto-generated Python script to download and cut YouTube video Clip ID: 9 Title: Inside BRAVE CF 100 | Muhammad Mokaev Finally Becomes A World Champion Viral Score: 18/100 Requirements: pip install yt-dlp moviepy """ import os import subprocess from moviepy.editor import VideoFileClip # Configuration VIDEO_URL = 'https://www.youtube.com/watch?v=cyGH88lofSw' START_TIME = 0 END_TIME = 60 OUTPUT_FILE = 'clip_9.mp4' SHORTS_FILE = 'shorts_clip_9.mp4' def download_video(): print('Downloading video from YouTube...') cmd = ['yt-dlp', '-f', 'best[ext=mp4]', '-o', 'temp_video.mp4', VIDEO_URL] subprocess.run(cmd, check=True) print('Download complete!') def cut_video(): print(f'Cutting video from {START_TIME}s to {END_TIME}s...') video = VideoFileClip('temp_video.mp4') cut = video.subclip(START_TIME, END_TIME) cut.write_videofile(OUTPUT_FILE, codec='libx264', audio_codec='aac') video.close() print('Cutting complete!') def convert_to_shorts(): print('Converting to YouTube Shorts format (9:16)...') video = VideoFileClip(OUTPUT_FILE) # Calculate new dimensions (9:16 ratio) target_width = 1080 target_height = 1920 # Resize and add padding cmd = [ 'ffmpeg', '-i', OUTPUT_FILE, '-vf', f'scale={target_width}:{target_height}:force_original_aspect_ratio=decrease,pad={target_width}:{target_height}:(ow-iw)/2:(oh-ih)/2:black', '-c:v', 'libx264', '-preset', 'fast', '-c:a', 'aac', SHORTS_FILE ] subprocess.run(cmd, check=True) video.close() print('Conversion complete!') def cleanup(): print('Cleaning up temporary files...') if os.path.exists('temp_video.mp4'): os.remove('temp_video.mp4') if os.path.exists(OUTPUT_FILE): os.remove(OUTPUT_FILE) if __name__ == '__main__': try: download_video() cut_video() convert_to_shorts() cleanup() print(f'\nSuccess! Video saved as: {SHORTS_FILE}') print('This video is ready to upload to YouTube Shorts!') except Exception as e: print(f'Error: {e}') cleanup()