Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mahuifa
QMDemo
提交
10859cba
Q
QMDemo
项目概览
mahuifa
/
QMDemo
通知
1
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
QMDemo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
10859cba
编写于
9月 16, 2022
作者:
mahuifa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:创建所有需要用到的函数
上级
7c5606b3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
169 addition
and
1 deletion
+169
-1
FFmpegDemo/VideoPlay/VideoPlay/readthread.cpp
FFmpegDemo/VideoPlay/VideoPlay/readthread.cpp
+30
-0
FFmpegDemo/VideoPlay/VideoPlay/readthread.h
FFmpegDemo/VideoPlay/VideoPlay/readthread.h
+28
-1
FFmpegDemo/VideoPlay/VideoPlay/videodecode.cpp
FFmpegDemo/VideoPlay/VideoPlay/videodecode.cpp
+55
-0
FFmpegDemo/VideoPlay/VideoPlay/videodecode.h
FFmpegDemo/VideoPlay/VideoPlay/videodecode.h
+24
-0
FFmpegDemo/VideoPlay/widget.cpp
FFmpegDemo/VideoPlay/widget.cpp
+20
-0
FFmpegDemo/VideoPlay/widget.h
FFmpegDemo/VideoPlay/widget.h
+12
-0
未找到文件。
FFmpegDemo/VideoPlay/VideoPlay/readthread.cpp
浏览文件 @
10859cba
...
...
@@ -4,3 +4,33 @@ ReadThread::ReadThread(QObject *parent) : QThread(parent)
{
}
ReadThread
::~
ReadThread
()
{
}
void
ReadThread
::
open
(
const
QString
&
url
)
{
}
void
ReadThread
::
pause
(
bool
flag
)
{
}
void
ReadThread
::
close
()
{
}
const
QString
&
ReadThread
::
url
()
{
}
void
ReadThread
::
run
()
{
}
FFmpegDemo/VideoPlay/VideoPlay/readthread.h
浏览文件 @
10859cba
...
...
@@ -10,17 +10,44 @@
#ifndef READTHREAD_H
#define READTHREAD_H
#include <QElapsedTimer>
#include <QThread>
#include <QTime>
class
VideoDecode
;
class
ReadThread
:
public
QThread
{
Q_OBJECT
public:
enum
PlayState
// 视频播放状态
{
play
,
end
};
public:
explicit
ReadThread
(
QObject
*
parent
=
nullptr
);
~
ReadThread
()
override
;
void
open
(
const
QString
&
url
=
QString
());
// 打开视频
void
pause
(
bool
flag
);
// 暂停视频
void
close
();
// 关闭视频
const
QString
&
url
();
// 获取打开的视频地址
protected:
void
run
()
override
;
signals:
void
updateImage
(
const
QImage
&
image
);
// 将读取到的视频图像发送出去
void
playState
(
PlayState
state
);
// 视频播放状态发送改变时触发
public
slots
:
private:
VideoDecode
*
m_videoDecode
=
nullptr
;
// 视频解码类
QString
m_url
;
// 打开的视频地址
bool
m_play
=
false
;
// 播放控制
bool
m_pause
=
false
;
// 暂停控制
QElapsedTimer
m_etime1
;
// 控制视频播放速度(更精确,但不支持视频后退)
QTime
m_etime2
;
// 控制视频播放速度(支持视频后退)
};
#endif // READTHREAD_H
FFmpegDemo/VideoPlay/VideoPlay/videodecode.cpp
浏览文件 @
10859cba
...
...
@@ -4,3 +4,58 @@ VideoDecode::VideoDecode()
{
}
VideoDecode
::~
VideoDecode
()
{
}
bool
VideoDecode
::
open
(
const
QString
&
url
)
{
}
QImage
*
VideoDecode
::
read
()
{
}
void
VideoDecode
::
close
()
{
}
bool
VideoDecode
::
isEnd
()
{
}
const
qint64
&
VideoDecode
::
pts
()
{
}
void
VideoDecode
::
initFFmpeg
()
{
}
void
VideoDecode
::
showError
(
int
err
)
{
}
qreal
VideoDecode
::
rationalToDouble
(
AVRational
rational
)
{
}
void
VideoDecode
::
clear
()
{
}
void
VideoDecode
::
free
()
{
}
FFmpegDemo/VideoPlay/VideoPlay/videodecode.h
浏览文件 @
10859cba
...
...
@@ -10,11 +10,35 @@
#ifndef VIDEODECODE_H
#define VIDEODECODE_H
#include <QString>
struct
AVFormatContext
;
struct
AVCodecContext
;
struct
AVRational
;
struct
AVPacket
;
struct
AVFrame
;
struct
SwsContext
;
struct
AVBufferRef
;
class
QImage
;
class
VideoDecode
{
public:
VideoDecode
();
~
VideoDecode
();
bool
open
(
const
QString
&
url
=
QString
());
// 打开媒体文件,或者流媒体rtmp、strp、http
QImage
*
read
();
// 读取视频图像
void
close
();
// 关闭
bool
isEnd
();
// 是否读取完成
const
qint64
&
pts
();
// 获取当前帧显示时间
private:
void
initFFmpeg
();
// 初始化ffmpeg库(整个程序中只需加载一次)
void
showError
(
int
err
);
// 显示ffmpeg执行错误时的错误信息
qreal
rationalToDouble
(
AVRational
rational
);
// 将AVRational转换为double
void
clear
();
// 清空读取缓冲
void
free
();
// 释放
};
#endif // VIDEODECODE_H
FFmpegDemo/VideoPlay/widget.cpp
浏览文件 @
10859cba
...
...
@@ -15,3 +15,23 @@ Widget::~Widget()
delete
ui
;
}
void
Widget
::
on_but_file_clicked
()
{
}
void
Widget
::
on_but_open_clicked
()
{
}
void
Widget
::
on_but_pause_clicked
()
{
}
void
Widget
::
on_playState
(
ReadThread
::
PlayState
state
)
{
}
FFmpegDemo/VideoPlay/widget.h
浏览文件 @
10859cba
...
...
@@ -2,6 +2,7 @@
#define WIDGET_H
#include <QWidget>
#include "readthread.h"
QT_BEGIN_NAMESPACE
namespace
Ui
{
class
Widget
;
}
...
...
@@ -15,7 +16,18 @@ public:
Widget
(
QWidget
*
parent
=
nullptr
);
~
Widget
();
private
slots
:
void
on_but_file_clicked
();
void
on_but_open_clicked
();
void
on_but_pause_clicked
();
void
on_playState
(
ReadThread
::
PlayState
state
);
private:
Ui
::
Widget
*
ui
;
ReadThread
*
m_readThread
=
nullptr
;
};
#endif // WIDGET_H
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录