0

如何向 ffmpeg 提供用户名和密码以使其能够将数据写入 ftp 服务器中的某个文件夹?该文件夹受密码保护,如果可能的话,我不想删除该密码。那么,我可以简单地将密码传递给ffmpeg吗?还是有其他解决方案?

从视频文件创建缩略图的 ffmpeg 进程示例

string thumbpath, thumbname, videofile;
videofile = "Video Source path";
thumbpath = "thumbnail path";
thumbname = thumbpath + "20120910160600.mjpeg";

string thumbargs = "-i \"" + videofile + "\" -vframes 1 -s 60*30 -ss 00:00:00 -f image2 \"" + thumbname + "\"";

Process process = new Process();

process.StartInfo.FileName = Server.MapPath("~\\ffmpeg\\bin\\ffmpeg.exe");
process.StartInfo.Arguments = thumbargs;

process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

新手,请指导我......

4

1 回答 1

1

如果您可以对要让 ffmpeg 写入的文件夹设置权限,则可以设置运行 ASP.NET 进程的帐户以具有写入权限。您可以通过配置应用程序池或使用模拟来控制在哪个帐户下运行 ASP.NET 。这是最简单的方法。

应用程序级别的模拟是通过将其放入 web.config 来完成的:

<identity impersonate="true" userName="accountname" password="password" />

这将导致 Web 应用程序始终以提供的用户身份运行。

如果要加强安全性,可以只让运行 ffmpeg 的进程在具有写入权限的用户下运行。您可以使用代码级模拟来实现这一点(如上面的模拟链接中所述)。

无论采用何种方法,ffmpeg 都不需要知道它以哪个用户身份运行。

于 2012-09-11T17:21:42.973 回答