I have deployed a C# azure function with ffmpeg.exe (using FFMpegCore nuget). The function adds audio and srt/ass subtitles to a video.
When I test locally this code works (running on azurite). But, when I deploy the azure function, the audio is added to the video but the subtitles don’t show up.
At the begining I thought it was an issue with the Fonts because I was using ASS File for subtitles but then I switched to SRT and still is not working.
I’ve tried with both SRT and ASS but they both don’t work using this code:
await FFMpegArguments
.FromFileInput(videoInputPath, true, options =>
{
options.WithCustomArgument("-stream_loop -1");
})
.AddFileInput(audioPath, true)
.OutputToFile(videoOutputPath, true, (options) =>
{
options.WithDuration(thread.AudioData.TotalAudioDuration);
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(subtitlesFile));
});
}).ProcessAsynchronously();
Here’s the command it creates on Azure function:
ffmpeg -stream_loop -1 -i "C:\local\Temp\videoTempPath.mp4" -i "C:\local\Temp\audioTempPath.mp3" -t 00:00:22.8160000 -c:v libx264 -c:a aac -preset veryfast -shortest -vf "subtitles="C\:\\local\\Temp\\subtitles.srt"" "C:\local\Temp\output.mp4" -y