"""
Basic video operations examples using FMUS-VID.
"""

import fmusvid
from pathlib import Path

def basic_transformations():
    """Basic video transformations example."""
    # Memuat video
    video = fmusvid.load("input.mp4")

    # Melakukan transformasi dasar
    processed = (video
        .trim(start=5, end=15)        # Memotong 10 detik
        .resize(width=1280)           # Mengubah ukuran dengan aspect ratio
        .rotate(90)                   # Memutar 90 derajat
        .grayscale()                  # Mengubah ke grayscale
    )

    # Menyimpan hasil
    processed.save("output.mp4")

def audio_operations():
    """Audio manipulation example."""
    video = fmusvid.load("input.mp4")

    # Memanipulasi audio
    processed = (video
        .volume(0.5)                  # Mengurangi volume ke 50%
        .add_audio(
            "music.mp3",
            start=5.0,                # Mulai pada detik ke-5
            volume=0.3                # Volume background music 30%
        )
    )

    processed.save("output_with_audio.mp4")

def batch_processing():
    """Batch processing example."""
    # Memproses multiple video
    input_dir = Path("input_videos")
    output_dir = Path("output_videos")
    output_dir.mkdir(exist_ok=True)

    for video_path in input_dir.glob("*.mp4"):
        video = fmusvid.load(video_path)

        # Memproses setiap video
        processed = (video
            .resize(height=720)       # Mengubah ukuran ke 720p
            .brightness(1.2)          # Meningkatkan brightness
            .contrast(1.1)            # Menyesuaikan contrast
        )

        # Menyimpan dengan nama yang sama di output_dir
        output_path = output_dir / video_path.name
        processed.save(output_path)

if __name__ == "__main__":
    basic_transformations()
    audio_operations()
    batch_processing()
