import os
import subprocess
from django.conf import settings

def resize_video(video_path, output_path=None):
    """Resize video to 1920x1080 max resolution"""
    if not output_path:
        filename, ext = os.path.splitext(video_path)
        output_path = f"{filename}_resized{ext}"
    
    ffmpeg_cmd = [
        'ffmpeg', '-i', video_path,
        '-vf', 'scale=min(1920,iw):min(1080,ih)',
        '-c:v', 'libx264', '-preset', 'medium',
        '-c:a', 'aac', '-b:a', '128k',
        output_path
    ]
    
    subprocess.run(ffmpeg_cmd)
    return output_path