You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Function中使用FFMpegCore添加字幕失效问题排查

问题:Azure Function中FFmpeg硬烧录字幕失败(本地正常)

我部署了一个搭载ffmpeg.exe的C# Azure Function,使用FFMpegCore NuGet包实现为视频添加音频及SRT/ASS字幕的功能。本地通过Azurite测试时代码运行正常,但部署到Azure Function后,音频可成功添加,字幕却无法显示。最初我认为是ASS字幕的字体问题,切换为SRT后问题仍未解决,两种格式都试过,用以下代码无法实现预期效果:

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);   // 用x264编码重编码视频
     options.WithAudioCodec(AudioCodec.Aac);       // 将音频重编码为AAC
     options.WithSpeedPreset(Speed.VeryFast);
     options.UsingShortest(true);

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

Azure Function上生成的FFmpeg命令如下:

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

内容的提问来源于stack exchange,提问作者Skerdi Berberi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 22:05:32