Spaces:
Running
Running
Commit
·
29bd116
1
Parent(s):
06c6f39
Fix: Extrapolate video to match audio duration using tpad filter
Browse files- mcp_servers/renderer.py +10 -1
mcp_servers/renderer.py
CHANGED
|
@@ -1352,14 +1352,23 @@ async def merge_video_audio(arguments: Dict[str, Any]) -> CallToolResult:
|
|
| 1352 |
Path(output_file).parent.mkdir(parents=True, exist_ok=True)
|
| 1353 |
|
| 1354 |
# Build FFmpeg merge command
|
|
|
|
|
|
|
|
|
|
| 1355 |
cmd = [
|
| 1356 |
"ffmpeg",
|
| 1357 |
"-i",
|
| 1358 |
video_file,
|
| 1359 |
"-i",
|
| 1360 |
audio_file,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1361 |
"-c:v",
|
| 1362 |
-
"
|
| 1363 |
"-c:a",
|
| 1364 |
"aac",
|
| 1365 |
"-shortest",
|
|
|
|
| 1352 |
Path(output_file).parent.mkdir(parents=True, exist_ok=True)
|
| 1353 |
|
| 1354 |
# Build FFmpeg merge command
|
| 1355 |
+
# Build FFmpeg merge command
|
| 1356 |
+
# Use tpad to extend the video stream to match audio duration (hold last frame)
|
| 1357 |
+
# Then use -shortest to cut at the end of the audio
|
| 1358 |
cmd = [
|
| 1359 |
"ffmpeg",
|
| 1360 |
"-i",
|
| 1361 |
video_file,
|
| 1362 |
"-i",
|
| 1363 |
audio_file,
|
| 1364 |
+
"-filter_complex",
|
| 1365 |
+
"[0:v]tpad=stop_mode=clone:stop_duration=-1[v]",
|
| 1366 |
+
"-map",
|
| 1367 |
+
"[v]",
|
| 1368 |
+
"-map",
|
| 1369 |
+
"1:a",
|
| 1370 |
"-c:v",
|
| 1371 |
+
"libx264", # Must re-encode to extend video
|
| 1372 |
"-c:a",
|
| 1373 |
"aac",
|
| 1374 |
"-shortest",
|