forked from Kazuhito00/Image-Processing-Node-Editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsegmenter.py
More file actions
35 lines (32 loc) · 1.12 KB
/
Copy pathsegmenter.py
File metadata and controls
35 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import subprocess
import os
from node.InputNode.streaming.downloader import fallback_recording
from node.InputNode.streaming.utils import is_valid_video
def download_segments(manifest_url, output_pattern="chunk_%03d.mp4", segment_time=30):
if not manifest_url:
print("🚫 URL de stream invalide.")
return
cmd = [
"ffmpeg",
"-hide_banner",
"-loglevel", "info",
"-reconnect", "1",
"-reconnect_streamed", "1",
"-reconnect_delay_max", "5",
"-i", manifest_url,
"-c:v", "libx264",
"-preset", "veryfast",
"-crf", "25",
"-c:a", "pcm_s16le", # WAV codec for efficient spectrogram conversion
"-f", "segment",
"-segment_time", str(segment_time),
"-reset_timestamps", "1",
output_pattern
]
print("🚀 Lancement de ffmpeg en mode segmenté...")
try:
subprocess.run(cmd, check=True)
print("✅ Téléchargement terminé")
except subprocess.CalledProcessError as e:
print(f"❌ Erreur ffmpeg : {e}")
fallback_recording(manifest_url, output_pattern, segment_time)