手机网页抓取视频( 帧资讯:如何用一个工具ffmpeg())

优采云 发布时间: 2021-09-18 18:18

  手机网页抓取视频(

帧资讯:如何用一个工具ffmpeg())

  截取上传视频的第一帧作为封面的方法

  一,。我们需要一个工具ffmpeg()

  二,。截取第一帧的方法

   ///

/// 从视频中截取img格式图片

///

/// ffmpeg.exe文件路径

/// 视频文件路径(带文件名)

/// 生成img图片路径(带文件名)

private void ConverToImg(string applicationPath, string fileNamePath, string targetImgNamePath)

{

//string c = applicationPath + @"\ffmpeg.exe -i" + fileNamePath + targetImgNamePath+"-ss 00:00:05 -r 1 -vframes 1 -an -vcodec mjpeg " ;

string c = applicationPath + @"\ffmpeg.exe -ss 00:00:05 -i" + " " + fileNamePath + " " + targetImgNamePath + " " + "-r 1 -vframes 1 -an -vcodec mjpeg ";//速度快

Cmd(c);

//-i:设定输入文件名

//-r:设定帧 此处设为1帧

//-f:设定输出格式

//-ss 从指定时间截图

//-vcodec:设定影像*敏*感*词*,没有输入时为文件原来相同的*敏*感*词*

//-vframes 设置转换多少桢(frame)的视频

//-an 不处理声音

}

   ///

/// 程序中调用CMD.exe程序,并且不显示命令行窗口界面

///

/// 执行的cmd命令

private void Cmd(string c)

{

try

{

System.Diagnostics.Process process = new System.Diagnostics.Process();

process.StartInfo.CreateNoWindow = true; //不显示程序窗口

process.StartInfo.FileName = "cmd.exe";//要执行的程序名称

process.StartInfo.UseShellExecute = false;

//process.StartInfo.RedirectStandardError = true;

process.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息

process.StartInfo.RedirectStandardInput = true; //可能接受来自调用程序的输入信息

process.Start();//启动程序

process.StandardInput.WriteLine(c);

process.StandardInput.AutoFlush = true;

process.StandardInput.WriteLine("exit");

}

catch { }

}

  本文版权归作者和博客园所有。欢迎您转载,但此声明需要在未经作者同意的情况下保留,原创链接在文章页面的明显位置

0 个评论

要回复文章请先登录注册


官方客服QQ群

微信人工客服

QQ人工客服


线