C.W.K.
Stream
Lesson 07 of 10 · published

Stream과 Stream Specifier

~10 min · streams, selectors, mapping

Level 0Viewer
0 XP0/73 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

한 파일, 많은 stream

미디어 container 는 stream 을 담아: 보통 video 1, audio 1, 가끔 subtitle track, 드물게 'data' stream (timecode, metadata). Blu-ray rip 이면 video 1 + audio 4 (다른 언어들) + subtitle 8 도 있을 수 있어.

FFmpeg 은 stream specifier 로 특정 stream 을 가리켜. 문법은 작지만 계속 부딪쳐.

문법

  • v = video, a = audio, s = subtitle, d = data, t = attachment.
  • v:0 = 첫 video stream. a:1 = 두 번째 audio stream.
  • 0:v:0 = input #0의 첫 video stream (input 여러 개일 때).
  • -map 0:a:1 = input #0의 audio stream #1 가져와서 output에 박아.
  • -c:v libx264 = output의 모든 video stream에 libx264 사용.
  • -c:a:0 copy -c:a:1 aac = 첫 audio stream copy, 두 번째는 AAC로 re-encode.

아무 -map 안 하면 FFmpeg이 'best' video와 'best' audio 골라 (가장 높은 bitrate / 선호 언어). multi-track 파일 다룰 땐 명시적으로 — auto-pick은 세상 절반의 '잘못된 audio 언어' 버그의 source 야.

Code

stream list, 그 다음 명시적 map·bash
# 이 파일에 어떤 stream이 있나?
ffprobe -v error -show_entries stream=index,codec_type,codec_name,channels,channel_layout \
  -of csv=p=0 input.mkv

# 출력 (예시):
# 0,video,h264,,
# 1,audio,ac3,6,5.1
# 2,audio,aac,2,stereo
# 3,subtitle,subrip,,
# 4,subtitle,subrip,,

# video 가져가고, 두 번째 audio (stereo AAC), 첫 번째 subtitle 가져가
ffmpeg -i input.mkv \
  -map 0:v:0 -map 0:a:1 -map 0:s:0 \
  -c copy output.mkv
stream 별 encoding 선택·bash
# Video는 H.265로 re-encode, audio는 그대로, subtitle drop
ffmpeg -i input.mkv \
  -map 0:v -map 0:a \
  -c:v libx265 -crf 22 \
  -c:a copy \
  output.mkv

External links

Exercise

audio track 여러 개 있는 MKV 찾거나 다운로드 (Blu-ray rip, 애니 release, 다국어 YouTube download). ffprobe 로 stream list. 그 다음 ffmpeg 명령 작성: video copy, English audio 만, subtitle 없이 새 MP4. 출력에 ffprobe 다시 돌려 검증.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.