rosenbjerg/FFMpegCore

I need a sample how to add subtitles to video

vshapenko opened this issue · 1 comments

Is there any example how to add srt file to input video?

Here's an example:

await FFMpegArguments
    .FromFileInput(videoInputPath)
    .AddFileInput(audioPath)
    .OutputToFile(videoOutputPath, true, (options) =>
    {
        options.WithDuration(audioDuration);

        options.WithVideoCodec(VideoCodec.LibX264);   // Re-encode video using x264 codec
        options.WithAudioCodec(AudioCodec.Aac);       // Re-encode audio to AAC
        options.WithSpeedPreset(Speed.VeryFast);
        options.UsingShortest(true);

        options.WithVideoFilters((videoOptions) =>
        {
            videoOptions.HardBurnSubtitle(SubtitleHardBurnOptions.Create(subtitlesPath));
        });
    })
    .ProcessAsynchronously();