Add subtitles

There are two ways to add subtitles into video. The first one is to burn it into video. The next one is to add new stream with subtitles, as in .mkv format.

Burning subtitles

IVideoStream allows to burn subtitle into video:

IMediaInfo inputFile = await FFmpeg.GetMediaInfo(Resources.MkvWithAudio);
string outputPath = Path.ChangeExtension(Path.GetTempFileName(), ".mp4");

IVideoStream videoStream = inputFile.VideoStreams.First().AddSubtitles(Resources.SubtitleSrt);

IConversionResult conversionResult = await FFmpeg.Conversions.New()

Add subtitles

Subtitles are streams too so could be added to conversion like other streams:

IMediaInfo mediaInfo = await FFmpeg.GetMediaInfo(inputPath);
IMediaInfo subtitleInfo = await FFmpeg.GetMediaInfo(subtitlePath);

ISubtitleStream subtitleStream = subtitleInfo.SubtitleStreams.First()

return New()

or easier using FFmpeg.Conversions.FromSnippet.AddSubtitle

string output = Path.ChangeExtension(Path.GetTempFileName(), ".mkv");

IConversion conversion = await FFmpeg.Conversions.FromSnippet.AddSubtitle(Resources.MkvWithAudio, output, Resources.SubtitleSrt);
IConversionResult result = await conversion.Start();