Spaces:
Running
Running
Create normalizer.py
Browse files- ingestion/normalizer.py +24 -0
ingestion/normalizer.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import uuid
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
def normalize_video(path):
|
| 6 |
+
|
| 7 |
+
output = f"jobs/norm_{uuid.uuid4()}.mp4"
|
| 8 |
+
|
| 9 |
+
cmd = [
|
| 10 |
+
"ffmpeg",
|
| 11 |
+
"-y",
|
| 12 |
+
"-i", path,
|
| 13 |
+
"-vf", "scale=1080:-2",
|
| 14 |
+
"-c:v", "libx264",
|
| 15 |
+
"-preset", "veryfast",
|
| 16 |
+
"-crf", "23",
|
| 17 |
+
"-c:a", "aac",
|
| 18 |
+
"-movflags", "+faststart",
|
| 19 |
+
output,
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
subprocess.run(cmd, check=True)
|
| 23 |
+
|
| 24 |
+
return output
|