typed-ffmpeg icon indicating copy to clipboard operation
typed-ffmpeg copied to clipboard

Add Smart -map Option Generator for FFmpeg Command Builder

Open lucemia opened this issue 6 months ago • 0 comments
trafficstars

✅ Auto-add -map in these scenarios:

  1. 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

  1. User wants specific tracks • If the user selects a specific audio language, subtitle, or stream index. • You need -map to extract that particular stream.

  2. 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.

  3. Combining media (muxing) • E.g., overlaying external audio on video. • Mapping is necessary to ensure the right streams get merged.

  4. User excludes certain streams • If they say “no subtitles” or “just video, no audio,” you need -map to enforce it.

🚫 Skip -map when:

  1. Single input file • User does not specify any preferences. • Let FFmpeg’s default selection pick first video/audio/subtitle.

  2. 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

lucemia avatar Apr 22 '25 16:04 lucemia