当前位置:网站首页>【MLT】MLT多媒体框架生产消费架构解析(一)
【MLT】MLT多媒体框架生产消费架构解析(一)
2022-08-02 04:29:00 【一二三o-0-O】
MLT多媒体框架生产消费架构解析
通过本文可以获取什么?
- 了解LGPL多媒体框架MLT的核心C++类封装的层级关系
- 了解MLT的生产消费者架构
- demon演示生产-消费的使用
核心类层级关系
MLT官方有为MLT库提供C++包装,根据MLT的设计梳理了核心类的层级关系,如下图:
如上图可见:整个封装分为4个层级,简单介绍一下关键类的功能:
- Properties:这个基类提供了后续所有派生类属性的序列化与反序列化能力。
- Service:这个服务类将会提供给消费者与生产者连接的能力、滤镜的订阅与反订阅能力等功能。
- Producer:生产者类,所有剪辑处理的最小单位。
- Playlist:生产者的容器。
生产消费者架构
生产消费基础流程图如下:
生产者初始化
// 默认视频图像制式设置是dv_pal(PAL特点:每秒钟有25帧,奇数场,主要应用在中国、香港、中东地区和欧洲一带,视频输出常用格式是PAL制式)
Profile profile;
// 根据profile配置与媒体资源初始化生产者
Producer producer(profile, filename);
消费者初始化
// 默认初始化为sdl
Consumer consumer(profile);
// 防止缩小到 profile 配置的尺寸.
// 让 sdl consumer 做所有的缩放.
consumer.set("rescale", "none");
// 在文件结束时自动退出.
consumer.set("terminate_on_pause", 1);
生产消费关联启动
// 从Service继承的关联消费者的能力
consumer.connect(producer);
// 启动
consumer.run();
consumer.stop();
demon展示
使用Consumer(sdl)消费Producer(mp4)效果

代码
void play(const char *filename)
{
qDebug() << filename;
Profile profile; // defaults to dv_pal
Producer producer(profile, filename);
Consumer consumer(profile); // defaults to sdl
// Prevent scaling to the profile size.
// Let the sdl consumer do all scaling.
consumer.set("rescale", "none");
// Automatically exit at end of file.
// consumer.set("terminate_on_pause", 1);
consumer.connect(producer);
consumer.run();
consumer.stop();
}
void func1()
{
Factory::init();
play("D:\\msys64\\home\\Administrator\\mltDemon\\qianyuqianxunKTV.mp4");// 替换自己本地的资源路径
Factory::close();
}
附属代码下载链接
参考资料
【1】MLT github链接
【2】官方代码示例
边栏推荐
猜你喜欢
随机推荐
【云原生】DevOps 新纪元 | 史前的惨淡现实
压缩包密码如何快速删除?
【云原生】什么是CI/CD? | CI/CD 带来的好处
Deep blue college - handwritten VIO operations - the first chapter
CubeSat Light-1
A practice arrangement about map GIS (below) GIS practice of Redis
棋盘问题(DAY 94)
How to decrypt worksheet protection in Excel
洗牌(DAY 100)
力扣练习——33 原子的数量
Minecraft 1.18.1, 1.18.2 module development 23.3D animation armor production
开放原子开源峰会落幕,百度超级链牵头成立XuperCore开源工作组
MES如何做好生产过程监控,本文给出了详细解答
HSCTF2022-re题解
UE4 蓝图实现AI随机移动
来自雪域高原的馈赠——大凉山高原生态糖心苹果
2022-08-01:以下go语言代码输出什么?A:panic;B:5;C:6;D:编译错误。 package main import ( “fmt“ ) func main() {
UE4 创建暂停和结束游戏UI
Crawler_crawl wasde monthly supply and demand balance table (example)
AFMG SysTune1.3.7使用图解








