gpt4 book ai didi

c# - 如何在 C# 中使用 ffmpeg 将视频转换为图像文件?

转载 作者:太空宇宙 更新时间:2023-11-03 16:54:06 24 4
gpt4 key购买 nike

        string inputpath = strFileNamePath;
string outputpath = "C:\\Image\\";
//for (int iIndex = 0; iIndex < 1000; iIndex++)
//{
//string fileargs = "-i" + " " + inputpath + " -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv " + outputpath + "SRT.flv";
string fileargs = "-i" + " " + inputpath + " " + outputpath + "image.jpg";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "C:\\Documents and Settings\\Badr\\My Documents\\Visual Studio 2008\\Projects\\Video2image2video.\\ffmpeg\\ffmpeg.exe";
p.StartInfo.Arguments = fileargs;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start();

我有这段代码,它只创建了 1 个视频图像,我应用了一个循环,但我重复生成了初始图像,我怎样才能获得所有视频的图像

提前致谢

最佳答案

来自documentation of ffmpeg :

You can extract images from a video, or create a video from many images:

For extracting images from a video:

ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg

This will extract one video frame per second from the video and will output them in files named foo-001.jpeg',
foo-002.jpeg', etc. Images will be rescaled to fit the new WxH values.

因此,只需更改传递给 ffmpeg 的参数,您就应该启动并运行了。

关于c# - 如何在 C# 中使用 ffmpeg 将视频转换为图像文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2857064/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com