Spaces:
Sleeping

shortV / clipper.py
404chain's picture
Create clipper.py
8a38914 verified
Raw History Blame Contribute Delete
725 Bytes
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
import os
def cut_video(input_path, start_time, end_time, output_path="viral_clip_ready.mp4"):
"""Fungsi untuk memotong video berdasarkan instruksi detik dari AI"""
try:
# Menghapus klip lama jika ada agar tidak bentrok
if os.path.exists(output_path):
os.remove(output_path)
# Mengeksekusi pemotongan video (Cepat, tanpa render ulang)
ffmpeg_extract_subclip(input_path, start_time, end_time, targetname=output_path)
return output_path, "✅ Video berhasil dipotong sesuai instruksi AI."
except Exception as e:
return None, f"❌ Gagal memotong video: {str(e)}"