• 8975阅读
  • 3回复

求教Qt调用vlc中video output的api端口函数 [复制链接]

上一主题 下一主题
离线lgcocpp
 
只看楼主 倒序阅读 楼主  发表于: 2012-09-14
小生昨天在fedora14上源码安装了vlc-1.1.11
安装好后发现一放视频就死机,后面在网上查询发现
将tool->preferences->video->output中的default修改成X11 video output就行了
现在小生要在Qt中嵌入vlc的播放器,嵌入后vlc在上面那个选项中还是默认default

小生现在的问题是找不到调用tool->preferences->video->output的函数

昨天在libvlc中的video control库里找了半天还是没找到
希望哪位熟悉vlc的大大解惑
离线lgcocpp
只看该作者 1楼 发表于: 2012-09-19
没有人在Qt上镶嵌vlc吗?
小生这几天在网上查了下,在wiki上有一个示范代码

http://wiki.videolan.org/LibVLC_SampleCode_Qt

其中在Qt里面用到的放视频的容器用到了QX11EmbedContainer函数库
在函数库中可以将容器定义为x11,这样output上应该就是x11输出了
但是还是一样的放视频就死机,现在怀疑是有些库没有配置好(比如说是GTK)
也有可能QX11EmbedContainer函数库调用的方式没理解透

都做了一个星期了,要崩溃的感觉,谁做过vlc求帮忙啊
离线lgcocpp
只看该作者 2楼 发表于: 2012-10-16
问题已经解决

#include "vlc_on_qt.h"

#include <QX11EmbedContainer>
#include <QVBoxLayout>
#include <QPushButton>
#include <QSlider>
#include <QTimer>
#include <QFrame>

Player::Player()
: QWidget()
{
    //preparation of the vlc command
    const char * const vlc_args[] = {
              "-I", "dummy", /* Don't use any interface */
              "--ignore-config", /* Don't use VLC's config */
              "--extraintf=logger", //log anything
              "--verbose=2", //be much more verbose then normal for debugging purpose
              "--plugin-path=/home/gppran/workplace/vlc-1.1.11/modules",
              "--vout=x11"};

#ifdef Q_WS_X11
    _videoWidget=new QX11EmbedContainer(this);
#else
    _videoWidget=new QFrame(this);
#endif
    // [20101215 JG] If KDE is used like unique desktop environment, only use _videoWidget=new QFrame(this);

    _volumeSlider=new QSlider(Qt::Horizontal,this);
    _volumeSlider->setMaximum(100); //the volume is between 0 and 100
    _volumeSlider->setToolTip("Audio slider");

    // Note: if you use streaming, there is no ability to use the position slider
    _positionSlider=new QSlider(Qt::Horizontal,this);
    _positionSlider->setMaximum(POSITION_RESOLUTION);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(_videoWidget);
    layout->addWidget(_positionSlider);
    layout->addWidget(_volumeSlider);
    setLayout(layout);

    _isPlaying=false;
    poller=new QTimer(this);

    //Initialize an instance of vlc
    //a structure for the exception is neede for this initalization
    //libvlc_exception_init(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    //create a new libvlc instance
    _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);  //tricky calculation of the char space used
    //_vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args,&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise (&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    // Create a media player playing environement
    _mp = libvlc_media_player_new (_vlcinstance);
    //_mp = libvlc_media_player_new (_vlcinstance, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise (&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    //connect the two sliders to the corresponding slots (uses Qt's signal / slots technology)
    connect(poller, SIGNAL(timeout()), this, SLOT(updateInterface()));
    connect(_positionSlider, SIGNAL(sliderMoved(int)), this, SLOT(changePosition(int)));
    connect(_volumeSlider, SIGNAL(sliderMoved(int)), this, SLOT(changeVolume(int)));

    poller->start(100); //start timer to trigger every 100 ms the updateInterface slot
}

//desctructor
Player::~Player()
{
    /* Stop playing */
    libvlc_media_player_stop (_mp);
    //libvlc_media_player_stop (_mp, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    /* Free the media_player */
    libvlc_media_player_release (_mp);

    libvlc_release (_vlcinstance);
    //raise (&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
}

void Player::playFile(QString file)
{
    //the file has to be in one of the following formats /perhaps a little bit outdated)
    /*
    [file://]filename              Plain media file
    http://ip:port/file            HTTP URL
    ftp://ip:port/file             FTP URL
    mms://ip:port/file             MMS URL
    screen://                      Screen capture
    [dvd://][device][@raw_device]  DVD device
    [vcd://][device]               VCD device
    [cdda://][device]              Audio CD device
    udp:[[<source address>]@[<bind address>][:<bind port>]]
    */

    /* Create a new LibVLC media descriptor */
    _m = libvlc_media_new_path(_vlcinstance, file.toAscii());
    //_m = libvlc_media_new (_vlcinstance, file.toAscii(), &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    libvlc_media_player_set_media (_mp, _m);
    //libvlc_media_player_set_media (_mp, _m, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    // /!\ Please note /!\
    //
    // passing the widget to the lib shows vlc at which position it should show up
    // vlc automatically resizes the video to the ?given size of the widget
    // and it even resizes it, if the size changes at the playing

        int windid = _videoWidget->winId();
        libvlc_media_player_set_xwindow (_mp, windid );
        //libvlc_media_player_set_xwindow (_mp, 75 );

    //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    /* Play */
    libvlc_media_player_play (_mp);
    //libvlc_media_player_play (_mp, &_vlcexcep ); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.

    _isPlaying=true;
}

void Player::changeVolume(int newVolume)
{
    //libvlc_exception_clear(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    libvlc_audio_set_volume (_mp,newVolume);
    //libvlc_audio_set_volume (_vlcinstance,newVolume , &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
}

void Player::changePosition(int newPosition)
{
    //libvlc_exception_clear(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    // It's possible that the vlc doesn't play anything
    // so check before
    libvlc_media_t *curMedia = libvlc_media_player_get_media (_mp);
    //libvlc_media_t *curMedia = libvlc_media_player_get_media (_mp, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //libvlc_exception_clear(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    if (curMedia == NULL)
        return;

    float pos=(float)(newPosition)/(float)POSITION_RESOLUTION;
    libvlc_media_player_set_position (_mp, pos);
    //libvlc_media_player_set_position (_mp, pos, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
}

void Player::updateInterface()
{
    if(!_isPlaying)
        return;

    // It's possible that the vlc doesn't play anything
    // so check before
    libvlc_media_t *curMedia = libvlc_media_player_get_media (_mp);
    //libvlc_media_t *curMedia = libvlc_media_player_get_media (_mp, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    //libvlc_exception_clear(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    if (curMedia == NULL)
        return;

    float pos=libvlc_media_player_get_position (_mp);
    //float pos=libvlc_media_player_get_position (_mp, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    int siderPos=(int)(pos*(float)(POSITION_RESOLUTION));
    _positionSlider->setValue(siderPos);
    int volume=libvlc_audio_get_volume (_mp);
    //int volume=libvlc_audio_get_volume (_vlcinstance,&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0.
    _volumeSlider->setValue(volume);
}


在const char * const vlc_args[]里面插入"--vout=x11"就行了
离线foxgod

只看该作者 3楼 发表于: 2014-05-23
回 lgcocpp 的帖子
lgcocpp:问题已经解决
#include "vlc_on_qt.h"
#include <QX11EmbedContainer>
....... (2012-10-16 09:18) 

为什么我运行VLC程序的时候,总是提示
main libvlc warning: cannot find plug-in entry point in C:\mycode5.2.1\build-music-Desktop_Qt_5_2_1_MinGW_32bit-Debug\debug\plugins\visualization\libgoom_plugin.dll

就是VLC下面的pluginS,总是找不到呢??
快速回复
限100 字节
 
上一个 下一个