Sunday, July 24, 2022

ffmpeg reminder

Personal reminder:

Download latest:
Run ffmpeg -i MyMovie.mkv and look for stream info, e.g.:

Stream #0:0: Video: h264 (High), yuv420p(tv, bt709/unknown/unknown, progressive), 1920x800, SAR 1:1 DAR 12:5, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0:1(dut): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
      title           : Dutch
Stream #0:2(dut): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
      title           : Flemish
Stream #0:3(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
      title           : English
Stream #0:4(dut): Subtitle: subrip (default) (forced)
Stream #0:5(dut): Subtitle: subrip
Stream #0:6(eng): Subtitle: subrip

Say, I would like to have the video with the Flemish audio and all the subtitles (since they don’t take that much space)

ffmpeg -i MyMovie_2160p.mkv -vf scale=640:-2 -ac 2 -af "pan=stereo|FL=FC+0.30*FL+0.30*BL|FR=FC+0.30*FR+0.30*BR" -map 0:v:0 -map 0:a:1 -map 0:s MyMovie_640p_2ch.mkv
-vf scale=640:-2	= video filter: 640p, -2 means keep aspect ratio for vertical pixels
-ac 2			= (convert to) 2 audio channels
-af "pan=......		= audio filter: copy multichannel audio without losing center channel (dialogs)
-map 0:v:0		= copy first (0) video stream
-map 0:a:1		= copy second (1) audio stream (Start from 0. So 0 would be Dutch, 1 Flemish, 2 English)
-map 0:s		= copy all subtitles 
but if you have non-convertible subtitles (bitmapped), then first map the desired sub and copy, e.g.: -map 0:s:3 -c:s copy