superbrain-server 1.0.36 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -85,20 +85,22 @@ def _unique_folder(base: pathlib.Path, name: str) -> pathlib.Path:
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
def extract_audio_from_video(video_path: str, audio_path: str) -> bool:
|
|
88
|
-
"""Extract audio track from a video file
|
|
89
|
-
|
|
90
|
-
print(" ⚠ moviepy not installed — skipping audio extraction")
|
|
91
|
-
return False
|
|
88
|
+
"""Extract audio track from a video file using ffmpeg to save memory and time."""
|
|
89
|
+
import subprocess
|
|
92
90
|
try:
|
|
93
|
-
print(" Extracting audio...")
|
|
94
|
-
video
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
print(" Extracting audio via ffmpeg...")
|
|
92
|
+
# Extract audio track to MP3, skip video, use low bitrate since we only need Shazam/Whisper
|
|
93
|
+
proc = subprocess.run([
|
|
94
|
+
"ffmpeg", "-y", "-i", video_path,
|
|
95
|
+
"-vn", "-acodec", "libmp3lame", "-q:a", "3",
|
|
96
|
+
audio_path
|
|
97
|
+
], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, text=True)
|
|
98
|
+
|
|
99
|
+
if proc.returncode == 0 and os.path.exists(audio_path) and os.path.getsize(audio_path) > 1024:
|
|
98
100
|
print(f" ✓ Audio saved: {os.path.basename(audio_path)}")
|
|
99
101
|
return True
|
|
100
|
-
|
|
101
|
-
print("
|
|
102
|
+
|
|
103
|
+
print(f" ⚠️ No audio track found or ffmpeg failed (code: {proc.returncode})")
|
|
102
104
|
return False
|
|
103
105
|
except Exception as e:
|
|
104
106
|
print(f" ⚠ Audio extraction failed: {e}")
|