feat: preserve multi-track audio in clip extraction

SKILL.md:
- Step 6: two clip modes — video-only (frame extraction) vs all-streams (editor use)
- Pitfall #10: warn about dropping audio tracks with default -map 0:v:0
- Note on keyframe accuracy vs frame-exact re-encode

extract_frames.py:
- New --all-streams flag on clip subcommand
- -map 0 preserves video + all audio tracks + subtitles
- Default remains -map 0:v:0 for fast frame extraction
This commit is contained in:
2026-07-14 12:16:17 +08:00
parent 5f9e96de19
commit 8fbb7f176e
2 changed files with 22 additions and 1 deletions
+9 -1
View File
@@ -65,13 +65,19 @@ def cmd_clip(args: argparse.Namespace) -> None:
if not video.exists():
sys.exit(f"Video not found: {video}")
# Build stream mapping: video-only for frame extraction, or all streams for editor use
if args.all_streams:
stream_map = ["-map", "0"] # all streams (video + all audio + subtitles)
else:
stream_map = ["-map", "0:v:0"] # video only (faster, smaller for frame extraction)
cmd = [
"ffmpeg", "-hide_banner", "-y",
"-ss", str(args.start),
"-to", str(args.end),
"-i", str(video),
"-c", "copy",
"-map", "0:v:0",
*stream_map,
str(output),
]
@@ -192,6 +198,8 @@ def main() -> None:
p_clip.add_argument("--start", required=True, type=float, help="Start time in seconds")
p_clip.add_argument("--end", required=True, type=float, help="End time in seconds")
p_clip.add_argument("--output", required=True, help="Output clip path")
p_clip.add_argument("--all-streams", action="store_true", default=False,
help="Preserve all streams (video + all audio tracks + subtitles). Default: video only (for frame extraction)")
# frames
p_frames = sub.add_parser("frames", help="Extract frames from a video/clip")