Qt播放音视频文件

 

使用QMediaPlayer和QVideoWidget

         QHBoxLayout  *m_layout=newQHBoxLayout(this);

 
 
    QMediaPlayer *m_player = new QMediaPlayer(this);
    m_player->setMedia(QUrl::fromLocalFile(QString::fromLocal8Bit("d:/QtTest/111.mp4")));
 
 
    QVideoWidget *m_videoW = new QVideoWidget(this);
    m_layout->addWidget(m_videoW);
    this->setLayout(m_layout);
 
 
    m_player->setVideoOutput(m_videoW);
    m_videoW->show();
 
 
    m_player->play();
 
代码写起来很简单,编译也能通过,但是运行就会出错

DirectShowPlayerService::doRender: Unresolved error code 0x80040266

 

如果文件路径不对或者文件名是中文的,则会显示如下错误:

DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80004005 ()

 

 

网上查了下,

Qt 中的多媒体播放,底层是使用DirectShowPlayerService,所以安装一个DirectShow解码器,例如LAV Filters,就可以解决运行出错问题

相关帖子 
http://bbs.csdn.NET/topics/391040873
https://github.com/qyvlik/Flat.qml/issues/4

 

下载LAV Filters地址

http://forum.doom9.org/showthread.php?t=156191  里的

Binaries for the most recent version are available here:
Version 0.68.1: Installer (both x86/x64) -- Zips: 32-bit & 64-bit
Download 3D Plugin: 32-bit & 64-bit

选择32bit或者64bit下

下载完安装后,再运行程序,运行无错误,能够正常播放视频。


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值