Bug 351774 - --no-xlib" to libvlc_new() error when watching tv
Summary: --no-xlib" to libvlc_new() error when watching tv
Status: RESOLVED FIXED
Alias: None
Product: kaffeine
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR major
Target Milestone: ---
Assignee: Mauro Carvalho Chehab
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-26 00:59 UTC by g9426562
Modified: 2017-03-20 21:33 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
adding XInitThreads(), #include <X11/Xlib.h> and a link to X11 library (1.25 KB, patch)
2015-09-01 17:21 UTC, Potomac
Details
example of .m2t stream that won't play (3.15 MB, application/octet-stream)
2015-09-05 11:14 UTC, g9426562
Details

Note You need to log in before you can comment on or make changes to this bug.
Description g9426562 2015-08-26 00:59:39 UTC
after upgrading from kaffeine-1.2.2-4-x86_64 to kaffeine-1.3-1-x86_64, tv capture has broken. it will display one frame and no audio. reverting to kaffeine-1.2.2-4-x86_64 fixes the problem.

"tv" is australian dvb-t and i'm using a winfast dtv1000t.

this seems to be the problem:
This process is probably using LibVLC incorrectly.
Pass "--no-xlib" to libvlc_new() to fix this.


starting up kaffeine:
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
[0000000001cb2f88] pulse audio output error: PulseAudio server connection failure: Connection refused
Object::connect: No such signal MediaWidget::playlistPrevious()
Object::connect: No such signal MediaWidget::playlistPlay()
Object::connect: No such signal MediaWidget::playlistNext()
Object::connect: No such signal MediaWidget::playlistTrackLengthChanged(int)
Object::connect: No such signal MediaWidget::playlistTrackMetadataChanged(QMap<MediaWidget::MetadataType,QString>)
20:27:20 DvbManager::loadDeviceManager: using built-in dvb device manager
20:27:20 DvbLinuxDevice::startDevice: found dvb device "P14f18802107d665f" 47 "Conexant CX22702 DVB-T"
QSystemTrayIcon::setVisible: No Icon set

clicking the tv button:
20:27:55 DvbDevice::frontendEvent: tuning succeeded
20:27:55 DvbSectionFilterInternal::processSections: short section
../../../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
This process is probably using LibVLC incorrectly.
Pass "--no-xlib" to libvlc_new() to fix this.
[00007fd8e0000958] vdpau_avcodec generic error: Xlib not initialized for threads
[00007fd8e0000958] vdpau_avcodec generic error: Xlib is required for VDPAU
../../../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
This process is probably using LibVLC incorrectly.
Pass "--no-xlib" to libvlc_new() to fix this.
[00007fd8d0001268] vdpau_display vout display error: Xlib not initialized for threads
[00007fd8f4016188] core decoder error: Could not convert timestamp 0

closing kaffeine:
20:28:23 DvbEpgModel::~DvbEpgModel: filter list not empty
[00007fd8f4016188] core decoder error: Could not convert timestamp 0
[00007fd8f4016188] core decoder error: Could not get display date for timestamp 0
[00007fd8f4016188] core decoder error: Could not get display date for timestamp 0
[00007fd8f4016188] core decoder error: Could not get display date for timestamp 0
[00007fd8f4016188] core decoder error: Could not get display date for timestamp 0
[00007fd8f4016188] core decoder error: Could not get display date for timestamp 0
[00007fd8f4016188] core decoder error: Could not get display date for timestamp 0
[00007fd8f40840d8] core decoder error: Could not convert timestamp 0

Reproducible: Always

Steps to Reproduce:
1. open kaffeine
2. click tv button

Actual Results:  
one frame of video and no audio at all.

Expected Results:  
video and audio streaming normally.
Comment 1 lasse.k.lindqvist 2015-08-27 18:03:29 UTC
What version of VLC are you using? Works at least for me with VLC 2.1.6.
Comment 2 g9426562 2015-08-28 00:28:53 UTC
vlc 2.2.1 (revision 2.2.1-0-ga425c42)
Comment 3 g9426562 2015-08-30 01:20:35 UTC
been a little bit of progress on this. turns out i can watch half of the available channels here but not the other half. all work fine in kaffeine-1.2.2-4-x86_64.

here's the bug in the arch bug tracker:
https://bugs.archlinux.org/task/46100

quick recap:
nvidia gtx970. tested with both prop and open source drivers.
tried swapping out my aerial.

audio only "radio" style channels will play, but hiccup every second and output this:
[0000000000c1e5a8] core input error: ES_OUT_RESET_PCR called
[0000000000c1e5a8] core input error: ES_OUT_SET_(GROUP_)PCR is called too late (pts_delay increased to 526 ms)
[0000000000c1e5a8] core input error: ES_OUT_RESET_PCR called
[0000000000c1e5a8] core input error: ES_OUT_SET_(GROUP_)PCR is called too late (pts_delay increased to 531 ms)


and of the providers we have here (melbourne, australia):
7 network: all works.
sbs network: all works, but audio only channels hiccup
channel 31 community tv: works.

9 network: won't play.
10 network: won't play.
abc network: won't play.
Comment 4 lasse.k.lindqvist 2015-08-30 09:02:50 UTC
https://github.com/caprica/vlcj/issues/293 is related.
Comment 5 Potomac 2015-08-31 13:22:38 UTC
I have also this error message in the console :

19:09:36 DvbDevice::frontendEvent: tuning succeeded
../../../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
This process is probably using LibVLC incorrectly.
Pass "--no-xlib" to libvlc_new() to fix this.
[00007f301c05f888] vdpau_avcodec generic error: Xlib not initialized for threads
[00007f301c05f888] vdpau_avcodec generic error: Xlib is required for VDPAU
../../../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
This process is probably using LibVLC incorrectly.
Pass "--no-xlib" to libvlc_new() to fix this.
[00007f3014001268] vdpau_display vout display error: Xlib not initialized for threads

something is wrong in kaffeine 1.3 about libVLC/Xlib, because of this error the vdpau feature can not be used, which means that kaffeine 1.3 has a very high CPU usage ( 56% with my pentium dual core 3.3 Ghz ),

I will do a "git bisect" in order to find what went wrong in kaffeine 1.3
Comment 6 Potomac 2015-08-31 23:53:44 UTC
(In reply to lasse.k.lindqvist from comment #4)
> https://github.com/caprica/vlcj/issues/293 is related.

how can we apply the workaround related to your link ?

they said "LibXUtil.initialise()" is a workaround , but I don't know in which files I should add this statement,

I did the git-bisect, the problem starts with commit e31652b06cc46dde488804b09205487d8036114f

Author: Christoph Pfister <christophpfister@gmail.com>
Date:   Sat Apr 30 18:48:07 2011 +0200

    switch from (lib-)xine to (lib-)vlc
Comment 7 Potomac 2015-09-01 00:04:03 UTC
more details about commit e31652b06cc46dde488804b09205487d8036114f :

http://commit-digest.org/issues/2011-05-01/moreinfo/e31652b06cc46dde488804b09205487d8036114f/
Comment 8 lasse.k.lindqvist 2015-09-01 04:58:52 UTC
You can find the file here (https://github.com/caprica/vlcj/blob/master/src/main/java/uk/co/caprica/vlcj/runtime/x/LibXUtil.java) It uses LibX11.INSTANCE.XInitThreads(); with a try-catch. INSTANCE is LibX11 INSTANCE = (LibX11)Native.loadLibrary(Platform.isWindows() ? "libX11" : "X11", LibX11.class);

Of course the call in our case is a bit different.

Where to call: init method in vlcmediawidget.cpp should work.
Comment 9 lasse.k.lindqvist 2015-09-01 15:37:06 UTC
adding the following to vlcmediawidget.cpp should work

#include <X11/Xlib.h>

and 

XInitThreads();

in the VlcMediaWidget::init()-method.

If you could let me know if that works for you and also if you encounter "undefined reference" mentioned in (http://stackoverflow.com/questions/23585435/cannot-call-xinitthreads)
Comment 10 Potomac 2015-09-01 17:21:36 UTC
Created attachment 94325 [details]
adding XInitThreads(), #include <X11/Xlib.h> and a link to X11 library

I did your modifications ( adding XInitThreads(), #include <X11/Xlib.h> ), I had to add a link to X11 library in /src/kaffeine/src/CMakeLists.txt,

I put these modification in a patch ( see the attachment ),

it solves the error message related to libvlc, but there are some problems :

- at start I can see the image for a channel,
- but it's impossible to change a channel, I get a black screen,
- randomly the CPU usage can be very high ( 56% instead of 5% )
- when I close kaffeine I get a crash, a segmentation error :

Application: Kaffeine (kaffeine), signal: Segmentation fault
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[Current thread is 1 (Thread 0x7fb761d6d780 (LWP 5157))]

Thread 2 (Thread 0x7fb74c3c2700 (LWP 5160)):
#0  0x00007fb75d99518d in poll () from /usr/lib/libc.so.6
#1  0x00007fb75a00ec7c in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007fb75a00ed8c in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3  0x00007fb75f3fb876 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#4  0x00007fb75f3c9dd1 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#5  0x00007fb75f3ca145 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#6  0x00007fb75f2b8849 in QThread::exec() () from /usr/lib/libQtCore.so.4
#7  0x00007fb75f3a9f23 in ?? () from /usr/lib/libQtCore.so.4
#8  0x00007fb75f2bb13c in ?? () from /usr/lib/libQtCore.so.4
#9  0x00007fb75f0194a4 in start_thread () from /usr/lib/libpthread.so.0
#10 0x00007fb75d99e12d in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7fb761d6d780 (LWP 5157)):
[KCrash Handler]
#6  0x00007fb75f01bac4 in pthread_mutex_lock () from /usr/lib/libpthread.so.0
#7  0x00007fb7607e09e7 in XrmDestroyDatabase () from /usr/lib/libX11.so.6
#8  0x00007fb7607c80ef in _XFreeDisplayStructure () from /usr/lib/libX11.so.6
#9  0x00007fb7607b5c8f in XCloseDisplay () from /usr/lib/libX11.so.6
#10 0x00007fb75e54d58a in ?? () from /usr/lib/libQtGui.so.4
#11 0x00007fb75e4dc46f in QApplication::~QApplication() () from /usr/lib/libQtGui.so.4
#12 0x000000000042256e in ?? ()
#13 0x00007fb75d8d5610 in __libc_start_main () from /usr/lib/libc.so.6
#14 0x0000000000422659 in _start ()
Comment 11 Potomac 2015-09-01 18:35:30 UTC
Is it possible to configure the video driver in kaffeine 1.3 with libvlc ?

with the previous version of kaffeine ( 1.2 ) the xine lib was used and we had a way to configure some options about xine in a file xine-config located in ~/.kde4/share/apps/kaffeine/,

but with kaffeine 1.3 there is no way to configure the video driver, by default kaffeine will try to use VDPAU driver which can be a bad choice if libvlc has some bugs about VDPAU driver,

in VLC I notice that I have a much more stability if I use "Video decoding VA-API via X11" option in VLC,

VDPAU works in VLC but it's not very stable ( I get black screen sometimes when I switch TV channels in VLC ),

VDPAU works very well only if I use mplayer, in mplayer it's very stable, but in VLC there are some black screen with VDPAU driver,

so it will be great if we can select the video driver ( VDPAU, XV video, VA-API via X11 ) in kaffeine 1.3, it would solve the black screen issue
Comment 12 lasse.k.lindqvist 2015-09-02 18:38:13 UTC
XInitThreads() causes problems with my VLC, too. If possible, I would like to see if you tried to use libvlc-dev-2.1.6. It is the default for at least Ubuntu at the moment. I will try to reproduce this error.

If this causes too much trouble, I'll have to think about reverting to Xine (which causes many problems of its own).

Anyway, 1.2.2 can always be used.
Comment 13 Potomac 2015-09-02 21:39:03 UTC
I use archlinux, there is no separate package for libvlc, all libs related to libvlc are provided by vlc package (  vlc 2.2.1-6 in archlinux )

archlinux is a rolling release distro, so it's always the most recent versions of libs and softwares that we have
Comment 14 g9426562 2015-09-05 11:14:36 UTC
Created attachment 94409 [details]
example of .m2t stream that won't play
Comment 15 g9426562 2015-09-05 11:23:35 UTC
just added a .m2t that won't play in kaffeine-1.3-1-x86_64 (recorded in kaffeine-1.2.2-4-x86_64).

if I split the file up (using ProjectX: http://sourceforge.net/projects/project-x/) I can play the .m2v and .ac3 files in kaffeine-1.3-1-x86_64. Still get the vlc xlib error messages, but, each file will play. this is the same whether the tv channel uses .ac3 or .mp2.

trying to play the .m2t gives:
../../../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
This process is probably using LibVLC incorrectly.
Pass "--no-xlib" to libvlc_new() to fix this.
[00007ffb90000958] vdpau_avcodec generic error: Xlib not initialized for threads
[00007ffb90000958] vdpau_avcodec generic error: Xlib is required for VDPAU
No accelerated IMDCT transform found
../../../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
This process is probably using LibVLC incorrectly.
Pass "--no-xlib" to libvlc_new() to fix this.
[00007ffb80001268] vdpau_display vout display error: Xlib not initialized for threads
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba4016848] core decoder error: Could not get display date for timestamp 0
[00007ffba40849f8] core decoder error: Could not convert timestamp 0
Comment 16 Victor 2015-11-01 16:43:46 UTC
I can confirm this bug on a fresh Manjaro KDE install.
High CPU usage on kaffeine 1.3 when playing back DVB-S2 streams (720p), the previous version using xine/mplayer worked fine with vdpau.
No problem with VLC itself.
I also like Potomac's idea to include a configuration setting in kaffeine to configure the output.
Unfortunately I can't help you fixing this bug, but at least it's confirmed and hopefully being looked at.
Comment 17 Potomac 2016-06-02 18:39:52 UTC
I still have the same bug with the 2.0.1 version : too much high CPU usage when I watch TV ( 100% CPU usage ),

the main problem is the VLC backend, kaffeine 2.0.1 seems to use it badly, and we don't have a way to configure vlc backend inside kaffeine ( for example VDPAU, xv, x11 for the video output ), that's why there is a high CPU usage if the default settings choosen by kaffeine is not suitable for the graphic driver,

and I discover another bug : when I click on "file-> exit" kaffeine 2.0.1 is still running ( the GUI disapears but kaffeine process is still running, I had to kill the process )
Comment 18 boris64 2016-06-03 21:36:53 UTC
(In reply to Potomac from comment #17)
> I still have the same bug with the 2.0.1 version : too much high CPU usage
> when I watch TV ( 100% CPU usage ),
> 
> the main problem is the VLC backend, kaffeine 2.0.1 seems to use it badly,
> and we don't have a way to configure vlc backend inside kaffeine ( for
> example VDPAU, xv, x11 for the video output ), that's why there is a high
> CPU usage if the default settings choosen by kaffeine is not suitable for
> the graphic driver,
> 
> and I discover another bug : when I click on "file-> exit" kaffeine 2.0.1 is
> still running ( the GUI disapears but kaffeine process is still running, I
> had to kill the process )

I second that. We really need to be able to do some configuration.
Plus the kaffeine process is still running after exit (dvb sound keeps playing without video).
AH, and the "prev/next channel"-shortcuts  aren't working anymore.

PS: Finally updates, very cool. Yeah! ;)
Comment 19 Mauro Carvalho Chehab 2016-06-08 16:58:24 UTC
Git commit 89486d8d7c2bbdf1a55ca72d882efae0e5ebf897 by Mauro Carvalho Chehab.
Committed on 08/06/2016 at 16:57.
Pushed by mauroc into branch 'master'.

configuration: add support to setup the arguments for libVLC

Sometimes, passing different command line options to libVLC
may help to solve some troubles on some special setups. So,
add an option to allow changing the libVLC parameters.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

M  +32   -2    src/backend-vlc/vlcmediawidget.cpp
M  +10   -0    src/configuration.cpp
M  +9    -0    src/configuration.h
M  +22   -0    src/configurationdialog.cpp
M  +2    -0    src/configurationdialog.h

http://commits.kde.org/kaffeine/89486d8d7c2bbdf1a55ca72d882efae0e5ebf897
Comment 20 Potomac 2016-06-13 14:31:08 UTC
 @Mauro Carvalho Chehab : do you have an example of command line for libVLC if we want to setup the video output ?

I don't find help about libVLC and parameters
Comment 21 Mauro Carvalho Chehab 2016-06-13 17:03:20 UTC
(In reply to Potomac from comment #20)
>  @Mauro Carvalho Chehab : do you have an example of command line for libVLC
> if we want to setup the video output ?
> 
> I don't find help about libVLC and parameters

We're still creating a documentation file for Kaffeine. The README.md explains something:

Remote Access and Kaffeine
==========================

Accessing Kaffeine remotely via X11/ssh/vnc can be a problem, as Qt5 will,
by default, use hardware acceleration and DRI3.

There is a known bug, present on Fedora 23/24, and likely on other distros,
at mesa-libGL/dri-drivers that cause it to wait forever when it is started
from a X11 section. Such bug causes Kaffeine windows to not open:

* <https://bugzilla.redhat.com/show_bug.cgi?id=1174257>

A workaround is to start Kaffeine with:

	LIBGL_DRI3_DISABLE=1 kaffeine

Another solution is to use a vnc server.

Still, libVLC will try to use hardware acceleration on the machine with
Kaffeine, with obviously with won't work via the X11 protocol. For such
scenarios, you may try to change the arguments passed to libVLC via the
"Settings" -->  "Configure Kaffeine" -->  "libVLC", changing the libVLC
arguments to:

	--no-video-title-show -V xcb_glx
or:

	--no-video-title-show -V xcb_xv

and re-start Kaffeine.
Comment 22 Potomac 2016-06-15 20:03:24 UTC
(In reply to Mauro Carvalho Chehab from comment #21)
> 
> 	--no-video-title-show -V xcb_glx
> or:
> 
> 	--no-video-title-show -V xcb_xv
> 
> and re-start Kaffeine.

these settings doesn't solve the problem, I always have this high CPU usage, this bug occurs when I switch the TV channel, with the first channel ( when kaffeine starts ) the CPU usage is Ok ( 15% ), but when I change the channel the CPU usage randomly becomes very high,

in console I can read this :
[00007f5e580c5d58] avcodec decoder: Using G3DVL VDPAU Driver Shared Library version 1.0 for hardware decoding.

the switching seems to trigger the bug, maybe kaffeine should reset something in libVLC when the user changes the TV channel,  in order to be sure that correct parameters will be used