caprica / vlcj

Java framework for the vlc media player
http://www.capricasoftware.co.uk/projects/vlcj
1.13k stars 259 forks source link

Unable to play Videos using vlcj on linux box #206

Closed Vishwaksena closed 11 years ago

Vishwaksena commented 11 years ago

Hi

I wanted to play videos using vlcj without installing vlc on linux box. So I have created the jar file with the required libraries and plugins and extracting them to known location and loading the libraries in the java code using jna.

To create a jar file I have taken the entire folder of usr/lib/vlc and also libraries(libvlc.so and libvlccore.so) as well but still I am unable to see the video output though video is playing.

Can you please tell me what could be the problem and how can I solve this issue. Am I missing any other required library in the jar.

P.S: If I am installing vlc everything is working as expected.

caprica commented 11 years ago

Well, you need to post logs. Start your JVM with -Dvlcj.log=debug, and create your MediaPlayerFactory with "-vvv".

Otherwise there's simply not enough information to help you.

Vishwaksena commented 11 years ago

This is what I am getting in the console. If this is not sufficient I can post the required information.

vlcj: (Info.java:103)                                | INFO  | vlcj: 2.1.0
vlcj: (Info.java:104)                                | INFO  | java: 1.7.0_40 Oracle Corporation
vlcj: (Info.java:105)                                | INFO  | java home: /usr/local/java/jre1.7.0_40
vlcj: (Info.java:106)                                | INFO  | os: Linux 3.5.0-23-generic amd64
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /tmp/jna1582736575358305810.tmp which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.0.5 Twoflower, changeset 2.0.5-0-g1661b7d
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: /tmp/Common/vlc/libvlc.so.5.3.1
vlcj: (MediaPlayerFactory.java:189)                  | DEBUG | MediaPlayerFactory(libvlc=Proxy interface to Native Library </tmp/Common/vlc/libvlc.so.5.3.1@140230549323280>,libvlcArgs=[--no-plugins-cache, --no-video-title-show, --no-snapshot-preview, --quiet, --quiet-synchro, --intf, dummy])
vlcj: (MediaPlayerFactory.java:191)                  | DEBUG | jna.library.path=/tmp/Common/vlc
vlcj: (MediaPlayerFactory.java:214)                  | DEBUG | instance=uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@f81a8d99
vlcj: (MediaPlayerFactory.java:413)                  | DEBUG | newEmbeddedMediaPlayer(fullScreenStrategy=null)
vlcj: (DefaultMediaPlayer.java:167)                  | DEBUG | DefaultMediaPlayer(libvlc=Proxy interface to Native Library </tmp/Common/vlc/libvlc.so.5.3.1@140230549323280>, instance=uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@f81a8d99)
vlcj: (DefaultMediaPlayer.java:1500)                 | DEBUG | createInstance()
vlcj: (DefaultMediaPlayer.java:1503)                 | DEBUG | mediaPlayerInstance=uk.co.caprica.vlcj.binding.internal.libvlc_media_player_t@f81c5771
vlcj: (DefaultMediaPlayer.java:1506)                 | DEBUG | mediaPlayerEventManager=uk.co.caprica.vlcj.binding.internal.libvlc_event_manager_t@f81e3ba9
vlcj: (DefaultMediaPlayer.java:1553)                 | DEBUG | registerEventListener()
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerMediaChanged
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerNothingSpecial
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerOpening
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerBuffering
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerPlaying
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerPaused
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerStopped
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerForward
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerBackward
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerEndReached
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerEncounteredError
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerTimeChanged
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerPositionChanged
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerSeekableChanged
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerPausableChanged
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerTitleChanged
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerSnapshotTaken
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerLengthChanged
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1557)                 | DEBUG | event=libvlc_MediaPlayerVout
vlcj: (DefaultMediaPlayer.java:1559)                 | DEBUG | result=0
vlcj: (MediaPlayerFactory.java:482)                  | DEBUG | newVideoSurface(canvas=java.awt.Canvas[canvas0,0,0,0x0,invalid])
vlcj: (MediaPlayerFactory.java:497)                  | DEBUG | videoSurface=uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface@352a1062
vlcj: (DefaultEmbeddedMediaPlayer.java:142)          | DEBUG | setVideoSurface(videoSurface=uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface@352a1062)
vlcj: (DefaultMediaPlayer.java:173)                  | DEBUG | addMediaPlayerEventListener(listener=uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent[panel0,0,0,0x0,invalid,layout=java.awt.BorderLayout])
vlcj: (DefaultEmbeddedMediaPlayer.java:222)          | DEBUG | setOverlay(overlay=null)
vlcj: (DefaultEmbeddedMediaPlayer.java:238)          | DEBUG | enableOverlay(enable=false)
vlcj: (DefaultEmbeddedMediaPlayer.java:304)          | DEBUG | removeOverlay()
vlcj: (DefaultEmbeddedMediaPlayer.java:284)          | DEBUG | addOverlay(overlay=null)
vlcj: (DefaultMediaPlayer.java:1294)                 | DEBUG | enableMarquee(enable=true)
vlcj: (DefaultEmbeddedMediaPlayer.java:151)          | DEBUG | attachVideoSurface()
vlcj: (CanvasVideoSurface.java:67)                   | DEBUG | attach()
vlcj: (LinuxVideoSurfaceAdapter.java:39)             | DEBUG | attach(componentId=67109022)
vlcj: (DefaultMediaPlayer.java:199)                  | DEBUG | playMedia(mrl=http://ipaddress/xxx.wmv,mediaOptions=[% vlc -vvv input_stream --sout '#standard{access=http,mux=ogg,dst=server.example.org:8080}'])
vlcj: (DefaultMediaPlayer.java:213)                  | DEBUG | prepareMedia(mrl=http://ipaddress/xxx.wmv,mediaOptions=[% vlc -vvv input_stream --sout '#standard{access=http,mux=ogg,dst=server.example.org:8080}'])
vlcj: (DefaultMediaPlayer.java:1638)                 | DEBUG | setMedia(media=http://ipaddress/xxx.wmv,mediaOptions=[% vlc -vvv input_stream --sout '#standard{access=http,mux=ogg,dst=server.example.org:8080}'])
vlcj: (DefaultMediaPlayer.java:1651)                 | DEBUG | mediaInstance=uk.co.caprica.vlcj.binding.internal.libvlc_media_t@f81e8f69
vlcj: (DefaultMediaPlayer.java:1663)                 | DEBUG | mediaOption=% vlc -vvv input_stream --sout '#standard{access=http,mux=ogg,dst=server.example.org:8080}'
vlcj: (DefaultMediaPlayer.java:1584)                 | DEBUG | registerMediaEventListener()
vlcj: (DefaultMediaPlayer.java:1590)                 | DEBUG | event=libvlc_MediaMetaChanged
vlcj: (DefaultMediaPlayer.java:1592)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1590)                 | DEBUG | event=libvlc_MediaSubItemAdded
vlcj: (DefaultMediaPlayer.java:1592)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1590)                 | DEBUG | event=libvlc_MediaDurationChanged
vlcj: (DefaultMediaPlayer.java:1592)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1590)                 | DEBUG | event=libvlc_MediaParsedChanged
vlcj: (DefaultMediaPlayer.java:1592)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1590)                 | DEBUG | event=libvlc_MediaFreed
vlcj: (DefaultMediaPlayer.java:1592)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1590)                 | DEBUG | event=libvlc_MediaStateChanged
vlcj: (DefaultMediaPlayer.java:1592)                 | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1452)                 | DEBUG | mrl(mediaInstance=uk.co.caprica.vlcj.binding.internal.libvlc_media_t@f81e8f69)
vlcj: (DefaultMediaPlayer.java:664)                  | DEBUG | play()
vlcj: (DefaultEmbeddedMediaPlayer.java:314)          | DEBUG | onBeforePlay()
vlcj: (DefaultEmbeddedMediaPlayer.java:151)          | DEBUG | attachVideoSurface()
vlcj: (CanvasVideoSurface.java:67)                   | DEBUG | attach()
vlcj: (DefaultMediaPlayer.java:1796)                 | DEBUG | mediaChanged(mediaPlayer=uk.co.caprica.vlcj.player.embedded.DefaultEmbeddedMediaPlayer@23daa4fe,media=uk.co.caprica.vlcj.binding.internal.libvlc_media_t@f81e8f69,mrl=http://ipaddress/xxx.wmv)
vlcj: (DefaultMediaPlayer.java:1800)                 | DEBUG | Raising event for new media
vlcj: (LinuxVideoSurfaceAdapter.java:39)             | DEBUG | attach(componentId=67109022)
vlcj: (DefaultMediaPlayer.java:173)                  | DEBUG | addMediaPlayerEventListener(listener=accdesktop.common.components.MediaFrame$2@29c06a2b)
../../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.
../../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.
vlcj: (DefaultMediaPlayer.java:688)                  | DEBUG | pause()
vlcj: (DefaultMediaPlayer.java:664)                  | DEBUG | play()
vlcj: (DefaultEmbeddedMediaPlayer.java:314)          | DEBUG | onBeforePlay()
vlcj: (DefaultEmbeddedMediaPlayer.java:151)          | DEBUG | attachVideoSurface()
vlcj: (CanvasVideoSurface.java:67)                   | DEBUG | attach()
vlcj: (LinuxVideoSurfaceAdapter.java:39)             | DEBUG | attach(componentId=67109022)
vlcj: (DefaultMediaPlayer.java:676)                  | DEBUG | stop()
caprica commented 11 years ago

From this log, this should NOT be happening:

../../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.
../../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.

Apart from that it looks like it should be working.

vlcj: (DefaultEmbeddedMediaPlayer.java:314)          | DEBUG | onBeforePlay()
vlcj: (DefaultEmbeddedMediaPlayer.java:151)          | DEBUG | attachVideoSurface()
vlcj: (CanvasVideoSurface.java:67)                   | DEBUG | attach()
vlcj: (LinuxVideoSurfaceAdapter.java:39)             | DEBUG | attach(componentId=67109022)
vlcj: (DefaultMediaPlayer.java:676)                  | DEBUG | stop()

So did you press stop here?

caprica commented 11 years ago

This also looks wrong:

mediaOption=% vlc -vvv input_stream --sout '#standard{access=http,mux=ogg,dst=server.example.org:8080}
Vishwaksena commented 11 years ago

What is wrong in that? How should I give media options? Media is playing but unable to see the image(i.e. video output) and able to hear the sound and pause the video. Yes I have pressed stop. One more thing I forgot to tell you that I have observed that some of the libraries are at usr/i386-linux-gnu while installing vlc but in the jar file just considered the files at /usr/lib/vlc. Later I have realized that those libraries are required to get the sound and output. So I have packaged them in the jar and tried but no luck. May be that libraries should be there at usr/i386-linux-gnu and missing symbolic links? So I have installed the libavcodec.so, libavformat.so,libva.so and libva-x11.so using packagemanager seperately but not solved.

caprica commented 11 years ago

Does your application actually play video if vlc is already installed?

I am sceptical about that because of the media options I see in your log. Media options are not the same as the string you pass to vlc on the command line.

There are examples of correct media options use in the vlcj examples, but just putting a bunch of command-line switches in a single string - I'm certain that is wrong.

The xlib errors in the log usually come about because you are attempting to reenter vlc and this is unreliable - I have only seen it happen if you have multiple concurrent media players in the same application. Is that the case for you?

When I package vlc shared objects like you are trying, I simply jar up the entire vlc installation directory.

Your problems are not really related to vlcj, since your media in fact does seem to be playing.

At least confirm whether or not your application works properly if vlc is already installed.

caprica commented 11 years ago

Ah I see you already confirmed it is working with vlc installed...

Not sure what else I can add then.

Vishwaksena commented 11 years ago

I don't have multiple concurrent media players. Simply jar up the entire vlc installation directory in the sense /usr/lib/vlc?(for ubuntu if I have installed at default location)

caprica commented 11 years ago

If you don't have multiple concurrent media players something else is being done incorrectly because of those xlib errors.

On jarring up the vlc installation directory: I build vlc from source and you end up with an "install" directory. That's what I jar up.

Vishwaksena commented 11 years ago

After installing vlc if I check by the command "whereis vlc" in the terminal then I'm getting vlc: /usr/bin/vlc /etc/vlc /usr/lib/vlc /usr/bin/X11/vlc /usr/share/vlc /usr/share/man/man1/vlc.1.gz In those I'm considering only "/usr/lib/vlc, libvlc.so and libvlccore.so" while packaging the jar file. Kindly let me know is that sufficient?

caprica commented 11 years ago

I can't say if it's sufficient or not, it looks like it's not sufficient because it's not working...

Like I said before, this isn't really a vlcj issue and I'm not sure how I can usefully help.

Try "-vvv" when you create your media player factory and inspect the logs that vlc produces.