[solved] libVLC QT Framework, sometimes video has only sound

This forum is about all development around libVLC.
chris_g
Blank Cone
Blank Cone
Posts: 12
Joined: 12 Nov 2009 10:51

[solved] libVLC QT Framework, sometimes video has only sound

Postby chris_g » 02 Dec 2009 15:18

Hi,

we have built a QT-Framework which plays videos with libvlc and our own custom controlls.
Sometimes instead of the video a white or yellow rectangle is shown. The sound is always there.
The Backgroundcolor of the QWidget is black.

Setup: Windows Vista, VLC 1.0.3 built from source, QT 4.5.3 built from source.

It seems to work fine on a XP System.

Regards
Chris
Last edited by chris_g on 11 Dec 2009 15:04, edited 5 times in total.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: libVLC, QT Framework, sometimes video has only sound

Postby Jean-Baptiste Kempf » 03 Dec 2009 12:01

How do you set the video to play on the QWidget?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

chris_g
Blank Cone
Blank Cone
Posts: 12
Joined: 12 Nov 2009 10:51

Re: libVLC, QT Framework, sometimes video has only sound

Postby chris_g » 03 Dec 2009 12:24

Here some snippets of the code.

VLCPlayer Constructor:

Code: Select all

VLCPlayer::VLCPlayer(QWidget *parent, QRect *_vidRect, bool _fullscreen, int _controllerHeight, int _movieWidth, int _movieHeight, int _trackNumber, bool prevBtn, bool nextBtn, float appVol, float appSavedVol, bool mute) : QWidget(parent) { ... //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 "--no-video-title-show", audioTrack, "--no-plugins-cache", #if defined(Q_OS_WIN) "--plugin-path=.\\plugins" #elif defined(Q_OS_MAC) "--plugin-path=./plugins" #elif // Linux "--plugin-path=./plugins" #endif }; QDesktopWidget *desktop = QApplication::desktop(); QRect screenRect = desktop->screenGeometry(desktop->primaryScreen()); this->screenWidth = screenRect.width(); this->screenHeight = screenRect.height(); this->movieWidth = _movieWidth; this->movieHeight = _movieHeight; this->fullScreen = _fullscreen; this->vidRect = *_vidRect; this->controllerHeight = _controllerHeight; this->screenRatio = screenWidth/screenHeight; _m = NULL; // libvlc_media_player_t *_mp; _mp = NULL; // libvlc_media_t *_m; this->_videoWidget=new QFrame(this); layout = new QVBoxLayout; layout->addWidget(_videoWidget); layout->setMargin(0); layout->setSpacing(0); setLayout(layout); ... //Initialize an instance of vlc //a structure for the exception is neede for this initalization libvlc_exception_init(&_vlcexcep); //create a new libvlc instance _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args,&_vlcexcep); //tricky calculation of the char space used vlcraise (&_vlcexcep); // Create a media player playing environement _mp = libvlc_media_player_new(_vlcinstance, &_vlcexcep); vlcraise(&_vlcexcep); // Calculate the rectangle for the video playerRect = this->calcPlayerRect(*_vidRect, (double)16/(double)9 ); this->setGeometry(playerRect.x(), playerRect.y(), playerRect.width(), playerRect.height()); /* Attach event to the media player */ libvlc_event_manager_t* em_mp; em_mp = libvlc_media_player_event_manager (_mp, &_vlcexcep); vlcraise (&_vlcexcep); libvlc_event_attach (em_mp, libvlc_MediaPlayerEndReached, callbacks, this, &_vlcexcep); vlcraise (&_vlcexcep); ... }
VLCPlayer playFile:

Code: Select all

VLCPlayer::playFile(QString file) { QCursor myCrsr(Qt::WaitCursor); _videoPath = file; if (_m) { libvlc_media_release(_m); } /* Create a new LibVLC media descriptor */ _m = libvlc_media_new(_vlcinstance, file.toAscii(), &_vlcexcep); vlcraise(&_vlcexcep); libvlc_media_player_set_media (_mp, _m, &_vlcexcep); vlcraise(&_vlcexcep); // /!\ 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 /* Get our media instance to use our window */ #if defined(Q_OS_WIN) libvlc_media_player_set_drawable(_mp, reinterpret_cast<unsigned int>(_videoWidget->winId()), &_vlcexcep ); //libvlc_media_player_set_hwnd(_mp, _videoWidget->winId(), &_vlcexcep ); // for vlc 1.0 #elif defined(Q_OS_MAC) libvlc_media_player_set_drawable(_mp, _videoWidget->winId(), &_vlcexcep ); //libvlc_media_player_set_agl (_mp, _videoWidget->winId(), &_vlcexcep); // for vlc 1.0 #else //Linux libvlc_media_player_set_drawable(_mp, _videoWidget->winId(), &_vlcexcep ); //libvlc_media_player_set_xwindow(_mp, _videoWidget->winId(), &_vlcexcep ); // for vlc 1.0 #endif vlcraise(&_vlcexcep); myCrsr.setShape(Qt::ArrowCursor); ... this->play(); ... }
playFile() is called from the parentWidget. I tried to call it with a delay, but this did not help.

As I said before it works fine on XP and about 7 of 10 Times on Vista.

Regards
Chris

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: libVLC, QT Framework, sometimes video has only sound

Postby Jean-Baptiste Kempf » 03 Dec 2009 14:08

Does the reinterpret_cast fail sometime?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

chris_g
Blank Cone
Blank Cone
Posts: 12
Joined: 12 Nov 2009 10:51

Re: libVLC, QT Framework, sometimes video has only sound

Postby chris_g » 03 Dec 2009 14:47

I just gave it a try, but the reinterpret_cast shows a valid uint , although the VideoRect is white or yellow.

Using libvlc_media_player_set_hwnd(_mp, _videoWidget->winId(), &_vlcexcep ) results in the same error.

chris_g
Blank Cone
Blank Cone
Posts: 12
Joined: 12 Nov 2009 10:51

Re: libVLC, QT Framework, sometimes video has only sound

Postby chris_g » 09 Dec 2009 00:21

Found no solution yet. Installed QT 4.6 but this does not solve the problem.

chris_g
Blank Cone
Blank Cone
Posts: 12
Joined: 12 Nov 2009 10:51

Re: libVLC, QT Framework, sometimes video has only sound

Postby chris_g » 09 Dec 2009 23:56

Ok it´s solved. We used VLC 1.0.2. After building a new libvlc.lib from 1.0.3, replace dlls and plugins it works on Vista as well.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: [solved] libVLC QT Framework, sometimes video has only sound

Postby Jean-Baptiste Kempf » 11 Dec 2009 08:59

1.0.3 works but not 1.0.2 ?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

chris_g
Blank Cone
Blank Cone
Posts: 12
Joined: 12 Nov 2009 10:51

libVLC QT Framework, sometimes video has only sound

Postby chris_g » 11 Dec 2009 14:31

Yes. Without any changes in the code.

EDIT 1:

But I just have seen that it still appaers sometimes, but not that often anymore. Not good.

EDIT 2:

Ok it works and I think I could isolate the Error. I must have been one of the plugins. On my PC everything worked fine with 1.0.3 but from the Server I still got this error. I detected that I still used the old plugin versions (1.0.2) at the server. When I changed them to the new ones (1.0.3) it works from server as well.

The plugins we use are:

libmp4_plugin.dll --> We play HD-mp4
libaccess_file_plugin.dll
libavcodec_plugin.dll
libdirac_plugin.dll
libdrawable_plugin.dll
libfaad_plugin.dll
libfloat32_mixer_plugin.dll
libugly_resampler_plugin.dll
libvout_directx_plugin.dll
libwaveout_plugin.dll

That´s all we have in the pluginsfolder. We replaced all the others.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 47 guests