|
|
|
|
#ifndef FFMPEGINCLUDE_H
|
|
|
|
|
#define FFMPEGINCLUDE_H
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
|
#include <libavutil/channel_layout.h>
|
|
|
|
|
#include <libavutil/common.h>
|
|
|
|
|
#include <libavutil/frame.h>
|
|
|
|
|
#include <libavutil/imgutils.h>
|
|
|
|
|
#include <libavutil/mem.h>
|
|
|
|
|
#include <libavutil/opt.h>
|
|
|
|
|
#include <libavutil/parseutils.h>
|
|
|
|
|
#include <libavutil/samplefmt.h>
|
|
|
|
|
#include <libavutil/time.h>
|
|
|
|
|
#include <libswscale/swscale.h>
|
|
|
|
|
|
|
|
|
|
#include "libavcodec/avcodec.h"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
|
#include <QEventLoop>
|
|
|
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
|
|
#define PRINT_LOG 1
|
|
|
|
|
#define ERROR_LEN 1024 // 异常信息数组长度
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 显示ffmpeg函数调用异常信息
|
|
|
|
|
* @param err
|
|
|
|
|
*/
|
|
|
|
|
inline void showError(int err) {
|
|
|
|
|
char *m_error = new char[ERROR_LEN]; // 保存异常信息
|
|
|
|
|
#if PRINT_LOG
|
|
|
|
|
memset(m_error, 0, ERROR_LEN); // 将数组置零
|
|
|
|
|
av_strerror(err, m_error, ERROR_LEN);
|
|
|
|
|
qWarning() << "DecodeVideo Error:" << m_error;
|
|
|
|
|
#else
|
|
|
|
|
Q_UNUSED(err)
|
|
|
|
|
#endif
|
|
|
|
|
delete[] m_error; // 释放内存
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// void highPrecisionSleep(qint64 microseconds) {
|
|
|
|
|
// QElapsedTimer timer;
|
|
|
|
|
// timer.start();
|
|
|
|
|
|
|
|
|
|
// QEventLoop loop;
|
|
|
|
|
// while (timer.nsecsElapsed() < microseconds * 1000) {
|
|
|
|
|
// QCoreApplication::processEvents(QEventLoop::AllEvents,
|
|
|
|
|
// 1); // 处理事件并短暂阻塞
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
#endif // FFMPEGINCLUDE_H
|