Display the Video from RTSP URL by using VLCJ

This forum is about all development around libVLC.
simsiongpo
New Cone
New Cone
Posts: 1
Joined: 21 Apr 2015 10:26

Display the Video from RTSP URL by using VLCJ

Postby simsiongpo » 21 Apr 2015 10:34

Hi,

I am having problem to play the video from RTSP URL by using VLCJ.
I able to play it by using VLC player by Open Network Stream.
I had tried to play the local video file and it works as well.

Below is my code and the DEBUG log.

Please help and advise.


Code:
import java.awt.BorderLayout;
import java.io.File;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.sun.jna.NativeLibrary;

import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;

public class MediaPlayer extends JPanel {

// Declares our media player component
private EmbeddedMediaPlayerComponent mediaplayer;
// This string holds the media URL path
private static String mediapath;
private JPanel panel;

public MediaPlayer() {
String projectPath = System.getProperty("user.dir");
//String vlcpath = projectPath;
String vlcpath = "C:/Program Files/VideoLAN/VLC/";
//mediapath = projectPath + "\\sample_mpeg42.mp4";
mediapath = "rtsp://admin:admin@192.168.1.100:554/media/video1";
// Check if the .dll is correct
File f = new File(vlcpath + "/libvlc.dll");
System.out.println("VLC PATH CORRECT: " + f.exists());

System.out.println("vlcpath = " +vlcpath);
System.out.println("mediapath = " +mediapath);
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), vlcpath);
mediaplayer = new EmbeddedMediaPlayerComponent();

panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(mediaplayer, BorderLayout.CENTER);
setLayout(new BorderLayout());
add(mediaplayer, BorderLayout.CENTER);
}

public void play() {
mediaplayer.getMediaPlayer().playMedia(mediapath);
}

public static void main(String[] args) {
MediaPlayer mediaplayer = new MediaPlayer();
JFrame ourframe = new JFrame();
ourframe.setContentPane(mediaplayer);
ourframe.setSize(720, 560);
ourframe.setVisible(true);
mediaplayer.play();
ourframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}


DEBUG LOG:

VLC PATH CORRECT: true
vlcpath = C:/Program Files/VideoLAN/VLC/
mediapath = rtsp://admin:admin@192.168.1.100:554/media/video1
vlcj: (Info.java:70) | INFO | vlcj: 2.4.1
vlcj: (Info.java:71) | INFO | java: 1.6.0_30 Sun Microsystems Inc.
vlcj: (Info.java:72) | INFO | java home: C:\Java\jre6_x64
vlcj: (Info.java:73) | INFO | os: Windows NT (unknown) 6.2 amd64
vlcj: (LibVlcFactory.java:164) | INFO | vlc: 2.2.1 Terry Pratchett (Weatherwax), changeset 2.2.1-0-ga425c42
vlcj: (LibVlcFactory.java:165) | INFO | libvlc: C:\Program Files\VideoLAN\VLC\libvlc.dll
vlcj: (MediaPlayerFactory.java:236) | DEBUG | MediaPlayerFactory(libvlc=Proxy interface to Native Library <C:\Program Files\VideoLAN\VLC\libvlc.dll@1681719296>,libvlcArgs=[--ignore-config, --video-title=vlcj video output, --no-plugins-cache, --no-video-title-show, --no-snapshot-preview, --quiet, --quiet-synchro, --sub-filter=logo:marq, --intf=dummy])
vlcj: (MediaPlayerFactory.java:238) | DEBUG | jna.library.path=null
vlcj: (MediaPlayerFactory.java:261) | DEBUG | instance=native@0x59b550 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@59b550)
vlcj: (MediaPlayerFactory.java:498) | DEBUG | newEmbeddedMediaPlayer(fullScreenStrategy=null)
vlcj: (DefaultMediaPlayer.java:177) | DEBUG | DefaultMediaPlayer(libvlc=Proxy interface to Native Library <C:\Program Files\VideoLAN\VLC\libvlc.dll@1681719296>, instance=native@0x59b550 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@59b550))
vlcj: (DefaultMediaPlayer.java:1709) | DEBUG | createInstance()
vlcj: (DefaultMediaPlayer.java:1712) | DEBUG | mediaPlayerInstance=native@0x7a712f0 (uk.co.caprica.vlcj.binding.internal.libvlc_media_player_t@7a712f0)
vlcj: (DefaultMediaPlayer.java:1715) | DEBUG | mediaPlayerEventManager=native@0x7bdf660 (uk.co.caprica.vlcj.binding.internal.libvlc_event_manager_t@7bdf660)
vlcj: (DefaultMediaPlayer.java:1762) | DEBUG | registerEventListener()
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerMediaChanged
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerNothingSpecial
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerOpening
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerBuffering
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerPlaying
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerPaused
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerStopped
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerForward
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerBackward
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerEndReached
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerEncounteredError
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerTimeChanged
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerPositionChanged
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerSeekableChanged
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerPausableChanged
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerTitleChanged
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerSnapshotTaken
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerLengthChanged
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1766) | DEBUG | event=libvlc_MediaPlayerVout
vlcj: (DefaultMediaPlayer.java:1768) | DEBUG | result=0
vlcj: (MediaPlayerFactory.java:597) | DEBUG | newVideoSurface(canvas=java.awt.Canvas[canvas0,0,0,0x0,invalid])
vlcj: (MediaPlayerFactory.java:612) | DEBUG | videoSurface=uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface@571a75a2
vlcj: (DefaultEmbeddedMediaPlayer.java:142) | DEBUG | setVideoSurface(videoSurface=uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface@571a75a2)
vlcj: (DefaultMediaPlayer.java:183) | 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:209) | DEBUG | playMedia(mrl=rtsp://admin:admin@192.168.1.100:554/media/video1,mediaOptions=[])
vlcj: (DefaultMediaPlayer.java:223) | DEBUG | prepareMedia(mrl=rtsp://admin:admin@192.168.1.100:554/media/video1,mediaOptions=[])
vlcj: (DefaultMediaPlayer.java:1847) | DEBUG | setMedia(media=rtsp://admin:admin@192.168.1.100:554/media/video1,mediaOptions=[])
vlcj: (MediaResourceLocator.java:83) | DEBUG | encodeMrl(mrl=rtsp://admin:admin@192.168.1.100:554/media/video1)
vlcj: (MediaResourceLocator.java:110) | DEBUG | MRL does not contain any Unicode characters
vlcj: (MediaResourceLocator.java:112) | DEBUG | result=rtsp://admin:admin@192.168.1.100:554/media/video1
vlcj: (DefaultMediaPlayer.java:1862) | DEBUG | Treating mrl as a location
vlcj: (DefaultMediaPlayer.java:1869) | DEBUG | mediaInstance=native@0x7be0aa0 (uk.co.caprica.vlcj.binding.internal.libvlc_media_t@7be0aa0)
vlcj: (DefaultMediaPlayer.java:1793) | DEBUG | registerMediaEventListener()
vlcj: (DefaultMediaPlayer.java:1799) | DEBUG | event=libvlc_MediaMetaChanged
vlcj: (DefaultMediaPlayer.java:1801) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1799) | DEBUG | event=libvlc_MediaSubItemAdded
vlcj: (DefaultMediaPlayer.java:1801) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1799) | DEBUG | event=libvlc_MediaDurationChanged
vlcj: (DefaultMediaPlayer.java:1801) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1799) | DEBUG | event=libvlc_MediaParsedChanged
vlcj: (DefaultMediaPlayer.java:1801) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1799) | DEBUG | event=libvlc_MediaFreed
vlcj: (DefaultMediaPlayer.java:1801) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1799) | DEBUG | event=libvlc_MediaStateChanged
vlcj: (DefaultMediaPlayer.java:1801) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1661) | DEBUG | mrl(mediaInstance=native@0x7be0aa0 (uk.co.caprica.vlcj.binding.internal.libvlc_media_t@7be0aa0))
vlcj: (DefaultMediaPlayer.java:2016) | DEBUG | mediaChanged(mediaPlayer=uk.co.caprica.vlcj.player.embedded.DefaultEmbeddedMediaPlayer@4090c06f,media=native@0x7be0aa0 (uk.co.caprica.vlcj.binding.internal.libvlc_media_t@7be0aa0),mrl=rtsp://admin:admin@192.168.1.100:554/media/video1)
vlcj: (DefaultMediaPlayer.java:695) | DEBUG | play()
vlcj: (DefaultEmbeddedMediaPlayer.java:314) | DEBUG | onBeforePlay()
vlcj: (DefaultMediaPlayer.java:2020) | DEBUG | Raising event for new media
vlcj: (DefaultEmbeddedMediaPlayer.java:151) | DEBUG | attachVideoSurface()
vlcj: (CanvasVideoSurface.java:67) | DEBUG | attach()
vlcj: (CanvasVideoSurface.java:70) | DEBUG | componentId=725580
vlcj: (WindowsVideoSurfaceAdapter.java:41) | DEBUG | attach(componentId=725580)
vlcj: (CanvasVideoSurface.java:72) | DEBUG | video surface attached
vlcj: (DefaultMediaPlayer.java:698) | DEBUG | after play



Regards,
Sim

Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 34 guests