如何使用ffmpeg为所有视频文件生成缩略图?

3

我使用ffmpeg成功为一个视频文件生成了缩略图,现在我想为目录中的每个视频创建缩略图。我该如何读取目录中的所有视频文件并使用ffmpeg为每个视频生成缩略图?

2个回答

2

DirectoryIntoThumbNails(@"C:\VideoFolder", "*.mpg")

这段代码是用来将指定文件夹中的所有符合条件(以 .mpg 结尾)的视频文件转换为缩略图。
void DirectoryIntoThumbNails(string sDir, string extension) 
{
    try 
    {
       foreach (string d in Directory.GetDirectories(sDir)) 
       {
        foreach (string f in Directory.GetFiles(d, extension)) 
        {
           SystemDiagnostics.Process.Start(@"C:\Ffmpeg.exe " + f + commandYouUsedSuccessfullyOnOneFile)
        }
        //Uncomment this if you want it to be recursive - all sub folders
        //DirSearch(d, extension);
       }
    }
    catch (System.Exception excpt) 
    {
        Console.WriteLine(excpt.Message);
    }
}

0

试试这个

using System.IO;

string[] filePaths = Directory.GetFiles(@"c:\MyDir\");

点击此链接从目录获取文件
现在操作数组filePaths并为视频生成缩略图...

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接