使用 ffMpeg 转换 Azure Webjob 中的视频文件

Converting Video files in a Azure Webjob with ffMpeg

我在 Azure 网络作业中使用 ffMpeg 时遇到问题。

我找到了以下文章 (How to call ffmpeg.exe to convert audio files on Windows Azure?),这正是我想要做的,但是,我无法让 ffMpeg 执行,而且它没有给出任何错误消息。

为了诊断问题,我通过将 ffMpeg、要转换的视频文件和批处理文件上传到 运行 来归结为它的要点:

run.cmd中的脚本很简单:

del output.mp4
ffmpeg -i screencast.wmv -c:v libx264 -r 15 output.mp4

这适用于我的个人计算机,但 运行 作为网络作业,我得到以下结果。

[12/08/2015 15:42:39 > bf9dd6: SYS INFO] Status changed to Initializing
[12/08/2015 15:42:39 > bf9dd6: SYS INFO] Job directory change detected: Job file 'ffmpegtest\output.mp4' exists in source directory but not in working directory.
[12/08/2015 15:42:47 > bf9dd6: SYS INFO] Run script 'run.cmd' with script host - 'WindowsScriptHost'
[12/08/2015 15:42:48 > bf9dd6: SYS INFO] Status changed to Running<br />
[12/08/2015 15:42:48 > bf9dd6: INFO] 
[12/08/2015 15:42:48 > bf9dd6: INFO] D:\local\Temp\jobs\triggered\ffMpeg\y1bdnb1e.03k\ffmpegtest>del output.mp4 
[12/08/2015 15:42:48 > bf9dd6: INFO] 
[12/08/2015 15:42:48 > bf9dd6: INFO] D:\local\Temp\jobs\triggered\ffMpeg\y1bdnb1e.03k\ffmpegtest>ffmpeg -i screencast.wmv -c:v libx264 -r 15 output.mp4 
[12/08/2015 15:42:49 > bf9dd6: SYS INFO] Status changed to Failed
[12/08/2015 15:42:49 > bf9dd6: SYS ERR ] Job failed due to exit code -1073741515

编辑: 此外,有人建议我 运行 使用 Kudu 控制台。仍然没有运气:

解决方案:
我最终需要 运行 32 位版本的 ffMpeg 而不是 64 位。非常感谢@mathewc!

您的问题是您需要在 run.cmd 文件中用引号将 input/output 文件名括起来,以便它们正确扩展。

ffmpeg -i "screencast.wmv" -c:v libx264 -r 15 "output.mp4"

将来,诊断此类问题的最佳方法是 运行 在您的 Kudu Console 中执行您的命令,以从您的 exe 中获取详细的输出信息。这使您可以像在本地一样进行测试,并解决在 Azure 环境中 运行ning 时可能存在的任何细微差异。

您可能 运行 进入某些 sandbox restrictions. To help isolate, I suggest trying to run your command directly from Kudu Console 以将 WebJobs 部分排除在等式之外。