typed-ffmpeg
typed-ffmpeg copied to clipboard
Add Smart -map Option Generator for FFmpeg Command Builder
✅ Auto-add -map in these scenarios:
- Multiple inputs • If user adds more than one input file (e.g., video.mp4 and audio.mp3) • You should explicitly map video and audio to avoid unpredictable behavior. Example:
-map 0:v -map 1:a
User wants specific tracks • If the user selects a specific audio language, subtitle, or stream index. • You need -map to extract that particular stream.
User wants to copy streams (-c copy) • FFmpeg won’t transcode, so it needs to know exactly which streams to copy. • Always add -map when using -c copy.
Combining media (muxing) • E.g., overlaying external audio on video. • Mapping is necessary to ensure the right streams get merged.
User excludes certain streams • If they say “no subtitles” or “just video, no audio,” you need -map to enforce it.
⸻
🚫 Skip -map when:
Single input file • User does not specify any preferences. • Let FFmpeg’s default selection pick first video/audio/subtitle.
Transcoding with defaults • E.g., just compressing a file without altering streams:
ffmpeg -i input.mp4 -c:v libx264 output.mp4
⸻
🤖 Builder Rule of Thumb
Here’s a simple logic for your builder:
if len(inputs) > 1 or stream_selection_explicit or copy_mode: generate_map_commands() else: skip_map()
Originally posted by @lucemia in #138