1 提取视频帧
Process ffmpeg = new Process();
ffmpeg.StartInfo.Arguments = " -i " + videoFilePath + " -r 1 -q:v 2 -f image2 " + @imagePath + "\\%6d.jpeg";
ffmpeg.StartInfo.FileName = Folder + "ffmpeg.exe";
ffmpeg.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
ffmpeg.Start();
ffmpeg.WaitForExit();
ffmpeg.Close();
ffmpeg.Dispose();
-videoFilePath : 视频文件路径
-imagePath : 存放图片路径
-r : 每s取一帧
-q:v:图片质量等
-%6d:图片名称000001.jpg......
2 多张图片合成视频
Process ffmpeg = new Process();
ffmpeg.StartInfo.Arguments = "-r 25 -i " + imagespath + "\\pic-%6d.jpeg " + VideoPath + "\\" + videoName + ".mp4";
ffmpeg.StartInfo.FileName = Folder + "ffmpeg.exe";
ffmpeg.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
ffmpeg.Start();
ffmpeg.WaitForExit();
ffmpeg.Close();
ffmpeg.Dispose();
-r : 每秒多少帧
- imagespath : 存放图片的文件夹路径
-videopath : 存放视频的路径
3 c#获取文件名的方式
string filename = System.IO.Path.GetFileName(fullPath);//文件名全称 image.jpg
string extension = System.IO.Path.GetExtension(fullPath);//文件名后缀 jpg
string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(fullPath); //文件名不带后缀 image
4 其他ffmpeg相关功能应用
#时间间隔 ffmpeg -i <input> -filter:v "select=(gte(t\,120))*(isnan(prev_selected_t)+gte(t-prev_selected_t\,120))" -frames:v 1 -y tile.png
视频帧提取与合成技术
本文详细介绍使用ffmpeg进行视频帧的提取及多张图片合成视频的过程。包括代码示例及参数说明,如帧率设置、图片质量控制及路径配置。同时,提供了C#中获取文件名的方法。
4243

被折叠的 条评论
为什么被折叠?



