Download clipper.py from 404chain/shortV: direct link, hf CLI and curl.
- Browser
- Download file 725 Bytes
-
https://huggingface.co/spaces/404chain/shortV/resolve/main/clipper.py
- Command line
-
hf download hf://spaces/404chain/shortV/clipper.py
-
curl -L -o clipper.py https://huggingface.co/spaces/404chain/shortV/resolve/main/clipper.py
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)}" |