FFmpeg使用(一)

FFmpeg编译好的库,资源下载:https://download.csdn.net/download/bigtree_mfc/13713908

里面包括32位和64位

  • Static :静态库版本,Static里面只有3个应用程序:ffmpeg.exe(用于转码的应用程序),ffplay.exe(用于播放的应用程序),ffprobe.exe(用于查看文件格式的应用程序),
  • Shared:动态库版本
  • Dev:提供给开发者用的lib文件

 

我的版本是Qt5.9.0,MinGW是32位,ffmpeg库我选择的是32位

 

1、自己创建一个新的项目,流程略

 

具体代码:

.pro中

#-------------------------------------------------
#
# Project created by QtCreator 2020-12-15T15:02:32
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Myffmpeg
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


include(modules/FFmpeg.pri)

SOURCES += \
        main.cpp \
        mainwindow.cpp
HEADERS += \
        mainwindow.h

FORMS += \
        mainwindow.ui


INCLUDEPATH += $$PWD/modules/include
LIBS += -L$$PWD/modules/lib/    -lavcodec  \
        -L$$PWD/modules/lib/    -lavdevice  \
        -L$$PWD/modules/lib/    -lavfilter  \
        -L$$PWD/modules/lib/    -lavformat  \
        -L$$PWD/modules/lib/    -lavutil  \
        -L$$PWD/modules/lib/    -lpostproc  \
        -L$$PWD/modules/lib/    -lswresample  \
        -L$$PWD/modules/lib/    -lswscale  \


DISTFILES += \
    modules/FFmpeg.pri

FFmpeg.pri

HEADERS += \
    $$PWD/ffmpeg.h

SOURCES += \
    $$PWD/ffmpeg.cpp

DISTFILES +=

ffmpeg.h

#ifndef MYFFMPEG_H
#define MYFFMPEG_H

#include <qDebug>

extern "C"
{
    #include "include/libavcodec/avcodec.h"
    #include "include/libavformat/avformat.h"
    #include "include/libswscale/swscale.h"
    #include "include/libavdevice/avdevice.h"
    #include "include/libavformat/version.h"
    #include "include/libavutil/time.h"
    #include "include/libavutil/mathematics.h"
}


class FFmpeg
{
public:
    FFmpeg();
};

#endif // MYFFMPEG_H

ffmpeg.cpp

#include "ffmpeg.h"

FFmpeg::FFmpeg()
{
    qDebug() << "Test FFmpeg!";

    av_register_all();
    unsigned version = avcodec_version();
    qDebug() << "version :" << version;
}

mainwindows.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "modules/ffmpeg.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();


    FFmpeg *m_myffmpeg;//
private:
    Ui::MainWindow *ui;


};

#endif // MAINWINDOW_H

mainwindows.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    m_myffmpeg = new FFmpeg();

}

MainWindow::~MainWindow()
{
    delete ui;
}

2、文件

其中include和lib为32位dev解压出来的文件,其中shared/bin所有的文件都放在debug文件,如果正式打包发布,需要和软件exe放在一起

3、运行

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值