从视频中截取图片--直接调用ffmpeg

        直接调用ffmpeg ,没用到ffmpeg 编程知识。

    (1)所需的头文件

#include <Windows.h>
#include <ShellAPI.h>
#include <QTextCodec>
#include <string>
using namespace std;

    (2)所需的库 shell32.lib

   

void FFmpegDemo::on_pictureBtn_clicked()
{
//D:\Demo\FFmpegDemo\Win32\Debug > ffmpeg - i D : \Demo\FFmpegDemo\FFmpegDemo\1.mp4 - r
//    1 - ss 00:00 : 26 - t 00 : 00 : 07 % 03d.png
    /*
    ffmpeg -y -framerate 10 -start_number 1 -i E:\Image\Image_%d.bmp  E:\test.mp4
    -y              表示输出时覆盖输出目录已存在的同名文件
    -framerate 10         表示视频帧率
    -start_number 1         表示图片序号从1开始
    -i E:\Image\Image_%d.bmp 表示图片输入流格式
    */
    QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
    QString path = QApplication::applicationDirPath();
//    QString paramter = QString("%1/ffmpeg.exe -i %1/1.mp4  -r 1 -ss 00:02:00 -t 00:01:07  %1/Image/Image_%d.bmp ").arg(path);
    QString paramter = QString("-i %1/1.mp4 -y -framerate 10 -start_number 100 -r 1 -ss 00:02:00 -t 00:01:07  %1/Image/Image_%d.bmp ").arg(path);
    QString file = path + "/ffmpeg.exe";
    wstring sFile = file.toStdWString();
    wstring sParamter = paramter.toStdWString();
    

    SHELLEXECUTEINFO ShExecInfo = { 0 };
    ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
    ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
    ShExecInfo.hwnd = NULL;

    ShExecInfo.lpVerb = L"open";
    //ShExecInfo.lpFile = L"ffmpeg.exe";
    ShExecInfo.lpFile = sFile.c_str();
    //ShExecInfo.lpParameters = L"ffmpeg.exe -y -framerate 10 -start_number 1 -i E:\Image\Image_%d.bmp  E:\test.mp4";
    ShExecInfo.lpParameters = sParamter.c_str();

    ShExecInfo.lpDirectory = NULL;
    ShExecInfo.nShow = SW_HIDE;//窗口状态为隐藏
    ShExecInfo.hInstApp = NULL;
    if (ShellExecuteEx(&ShExecInfo))
    {
        if (ShExecInfo.hProcess)
        {
            WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
        }
    }
}

 

(3)具体代码

 

上一篇:第一个FFMPEG程序


下一篇:ffmpeg学习笔记_打印音视频Meta信息