Embedding multiple subtitles to video using FFMPEG

Aug 24, 2020 21:33

There are 2 ways to do this:-
Method 1: Lump the commands together.
Method 2: Embed the subtitle one at one time command executed.

Method 1:-
Command lines: ffmpeg -i video_input -i "subtitle_file_1" -i "subtitle_file_2" -map 0:v -map 0:a -map 1 -map 2 -c:v copy -c:a copy -c:s ass -metadata:s:s:0 language=eng -metadata:s:s:1 language=jpn -qscale 0 output_video.mkv
Example:- ffmpeg -i "Pareto no Gosan S01E01 HDTV 720p AAC H.264-NSBC.mkv" -i "Pareto Gosan~#01.ass" -i "パレートの誤算~ケース・ワーカー殺人事件~#01.ass" -map 0:v -map 0:a -map 1 -map 2 -c:v copy -c:a copy -c:s ass -metadata:s:s:0 language=eng -metadata:s:s:1 language=jpn -qscale 0 pg1.mkv

Notes:
1) For metadata:s:s:0 language=xxx (xxx code can be referred in https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
2) for srt subtitle type, -c:s srt

Method 2:-
Command lines:  ffmpeg -i video_input -i "subtitle_file_1" -map 0:v -map 0:a -map 1 -c:v copy -c:a copy -c:s ass -metadata:s:s:0 language=eng -qscale 0 output_video.mkv
Example:- ffmpeg -i "Pareto no Gosan S01E01 HDTV 720p AAC H.264-NSBC.mkv" -i "Pareto Gosan~#01.ass" -map 0:v -map 0:a -map 1 -c:v copy -c:a copy -c:s ass -metadata:s:s:0 language=eng -qscale 0 pg1.mkv

Notes:
1. Repeat above to embed another subtitle.

SPECIAL CASE: Video source already have other subtitles embedded.

Command lines: ffmpeg -i video_input -i "subtitle_file_2" -i "subtitle_file_3" -map 0:v -map 0:a -map 0:s:0 -map 1 -map 2 -c copy -c:s srt -metadata:s:s:1 language=chi -metadata:s:s:2 language=msa -qscale 0 output_video.mkv
Example:- ffmpeg -i "Manchester.by.the.Sea.2016.BluRay.1080p.DTS-HD.MA.5.1.AVC.REMUX-FraMeSToR.mkv" -i "Manchester by the Sea 2016 1080p BluRay x264 DTS-JYK.srt" -i "Manchester by the Sea 2016 BR -MSC-.srt" -map 0:v -map 0:a -map 0:s:0 -map 1 -map 2 -c copy -c:s srt -metadata:s:s:1 language=chi -metadata:s:s:2 language=msa -qscale 0 "Manchester by the Sea 2016 1080p BluRay x264 DTS-JYK.mkv"

Notes: Pay attention to -map 0:s:0 and -metadata specification.
Instead of -metadata:s:s:0 and -metadata:s:s:1, the 2 newly added subtitles language specification will be assigned to next designated numbers because -metadata:s:s:0 already designated for the existing subtitle.

Once finish, you can select which subtitles to view from subtitle selection in your video player.

ffmpeg: subtitle, ffmpeg: embedded subtitle

Previous post Next post
Up