dshow demux error: can't open video device
Posted: 05 Dec 2013 13:15
I have the following code to play video camera but always paint the black screen...
I can read this in console:
[0000000000408050] dshow demux error: can't open video device
Code: Select all
package foo;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.player.embedded.DefaultFullScreenStrategy;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
import uk.co.caprica.vlcj.player.embedded.FullScreenStrategy;
import uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface;
import com.sun.jna.NativeLibrary;
public class RoboControlStart1 {
//construct the aplication
public RoboControlStart1() {
Canvas canvas = new Canvas();
canvas.setBackground(Color.black);
JPanel contentPane = new JPanel();
contentPane.setBackground(Color.black);
contentPane.setLayout(new BorderLayout());
contentPane.add(canvas, BorderLayout.CENTER);
JFrame frame = new JFrame("Capture");
frame.add(contentPane, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocation(50, 50);
frame.setSize(800, 600);
// Set some options for libvlc
String[] libvlcArgs = {};
// Create a factory
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(libvlcArgs);
// Create a full-screen strategy
FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(frame);
// Create a media player instance (in this example an embedded media player)
EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(fullScreenStrategy);
// Set standard options as needed to be applied to all subsequently played media items
String[] standardMediaOptions = {};
mediaPlayer.setStandardMediaOptions(standardMediaOptions);
CanvasVideoSurface videoSurface = mediaPlayerFactory.newVideoSurface(canvas);
mediaPlayer.setVideoSurface(videoSurface);
// Play a particular item, with options if necessary
String mediaPath = "dshow://";
String[] mediaOptions = {" :dshow-vdev=HP HD Webcam [Fixed] :dshow-adev= :dshow-aspect-ratio=4\\:3 :dshow-chroma= :dshow-fps=0 :no-dshow-config :no-dshow-tuner :dshow-tuner-channel=0 :dshow-tuner-frequency=0 :dshow-tuner-country=0 :dshow-tuner-standard=0 :dshow-tuner-input=0 :dshow-video-input=-1 :dshow-video-output=-1 :dshow-audio-input=-1 :dshow-audio-output=-1 :dshow-amtuner-mode=1 :dshow-audio-channels=0 :dshow-audio-samplerate=0 :dshow-audio-bitspersample=0 :live-caching=300"};
frame.setVisible(true);
mediaPlayer.prepareMedia(mediaPath, mediaOptions);
mediaPlayer.play();
}
public static void main(String[] args) {
NativeLibrary.addSearchPath("libvlc", "C:/Program Files/VideoLAN/VLC");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new RoboControlStart1();
}
}
[0000000000408050] dshow demux error: can't open video device
vlcj: (Info.java:70) | INFO | vlcj: 2.4.0
vlcj: (Info.java:71) | INFO | java: 1.7.0_21 Oracle Corporation
vlcj: (Info.java:72) | INFO | java home: C:\Program Files\Java\jdk1.7.0_21\jre
vlcj: (Info.java:73) | INFO | os: Windows 7 6.1 amd64
vlcj: (LibVlcFactory.java:164) | INFO | vlc: 2.1.1 Rincewind, changeset 2.1.1-0-g89db9aa
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@1717829632>,libvlcArgs=[])
vlcj: (MediaPlayerFactory.java:238) | DEBUG | jna.library.path=null
vlcj: (MediaPlayerFactory.java:261) | DEBUG | instance=native@0x46c340 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@46c340)
vlcj: (DefaultFullScreenStrategy.java:57) | DEBUG | DefaultFullScreenStrategy(window=javax.swing.JFrame[frame0,50,50,800x600,invalid,hidden,layout=java.awt.BorderLayout,title=Capture,resizable,normal,defaultCloseOperation=EXIT_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true])
vlcj: (MediaPlayerFactory.java:482) | DEBUG | newEmbeddedMediaPlayer(fullScreenStrategy=uk.co.caprica.vlcj.player.embedded.DefaultFullScreenStrategy@7cc88805)
vlcj: (DefaultMediaPlayer.java:176) | DEBUG | DefaultMediaPlayer(libvlc=Proxy interface to Native Library <C:\Program Files\VideoLAN\VLC\libvlc.dll@1717829632>, instance=native@0x46c340 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@46c340))
vlcj: (DefaultMediaPlayer.java:1695) | DEBUG | createInstance()
vlcj: (DefaultMediaPlayer.java:1698) | DEBUG | mediaPlayerInstance=native@0x386940 (uk.co.caprica.vlcj.binding.internal.libvlc_media_player_t@386940)
vlcj: (DefaultMediaPlayer.java:1701) | DEBUG | mediaPlayerEventManager=native@0x12818e30 (uk.co.caprica.vlcj.binding.internal.libvlc_event_manager_t@12818e30)
vlcj: (DefaultMediaPlayer.java:1748) | DEBUG | registerEventListener()
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerMediaChanged
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerNothingSpecial
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerOpening
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerBuffering
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerPlaying
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerPaused
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerStopped
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerForward
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerBackward
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerEndReached
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerEncounteredError
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerTimeChanged
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerPositionChanged
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerSeekableChanged
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerPausableChanged
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerTitleChanged
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerSnapshotTaken
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerLengthChanged
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1752) | DEBUG | event=libvlc_MediaPlayerVout
vlcj: (DefaultMediaPlayer.java:1754) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:202) | DEBUG | setStandardMediaOptions(options=[])
vlcj: (MediaPlayerFactory.java:581) | DEBUG | newVideoSurface(canvas=java.awt.Canvas[canvas0,0,0,0x0,invalid])
vlcj: (MediaPlayerFactory.java:596) | DEBUG | videoSurface=uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface@7c4ba386
vlcj: (DefaultEmbeddedMediaPlayer.java:142) | DEBUG | setVideoSurface(videoSurface=uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface@7c4ba386)
vlcj: (DefaultMediaPlayer.java:222) | DEBUG | prepareMedia(mrl=dshow://,mediaOptions=[ :dshow-vdev=HP HD Webcam [Fixed] :dshow-adev= :dshow-aspect-ratio=4\:3 :dshow-chroma= :dshow-fps=0 :no-dshow-config :no-dshow-tuner :dshow-tuner-channel=0 :dshow-tuner-frequency=0 :dshow-tuner-country=0 :dshow-tuner-standard=0 :dshow-tuner-input=0 :dshow-video-input=-1 :dshow-video-output=-1 :dshow-audio-input=-1 :dshow-audio-output=-1 :dshow-amtuner-mode=1 :dshow-audio-channels=0 :dshow-audio-samplerate=0 :dshow-audio-bitspersample=0 :live-caching=300])
vlcj: (DefaultMediaPlayer.java:1833) | DEBUG | setMedia(media=dshow://,mediaOptions=[ :dshow-vdev=HP HD Webcam [Fixed] :dshow-adev= :dshow-aspect-ratio=4\:3 :dshow-chroma= :dshow-fps=0 :no-dshow-config :no-dshow-tuner :dshow-tuner-channel=0 :dshow-tuner-frequency=0 :dshow-tuner-country=0 :dshow-tuner-standard=0 :dshow-tuner-input=0 :dshow-video-input=-1 :dshow-video-output=-1 :dshow-audio-input=-1 :dshow-audio-output=-1 :dshow-amtuner-mode=1 :dshow-audio-channels=0 :dshow-audio-samplerate=0 :dshow-audio-bitspersample=0 :live-caching=300])
vlcj: (MediaResourceLocator.java:83) | DEBUG | encodeMrl(mrl=dshow://)
vlcj: (MediaResourceLocator.java:110) | DEBUG | MRL does contain any Unicode characters
vlcj: (MediaResourceLocator.java:112) | DEBUG | result=dshow://
vlcj: (DefaultMediaPlayer.java:1848) | DEBUG | Treating mrl as a location
vlcj: (DefaultMediaPlayer.java:1855) | DEBUG | mediaInstance=native@0x12818f50 (uk.co.caprica.vlcj.binding.internal.libvlc_media_t@12818f50)
vlcj: (DefaultMediaPlayer.java:1867) | DEBUG | mediaOption= :dshow-vdev=HP HD Webcam [Fixed] :dshow-adev= :dshow-aspect-ratio=4\:3 :dshow-chroma= :dshow-fps=0 :no-dshow-config :no-dshow-tuner :dshow-tuner-channel=0 :dshow-tuner-frequency=0 :dshow-tuner-country=0 :dshow-tuner-standard=0 :dshow-tuner-input=0 :dshow-video-input=-1 :dshow-video-output=-1 :dshow-audio-input=-1 :dshow-audio-output=-1 :dshow-amtuner-mode=1 :dshow-audio-channels=0 :dshow-audio-samplerate=0 :dshow-audio-bitspersample=0 :live-caching=300
vlcj: (DefaultMediaPlayer.java:1779) | DEBUG | registerMediaEventListener()
vlcj: (DefaultMediaPlayer.java:1785) | DEBUG | event=libvlc_MediaMetaChanged
vlcj: (DefaultMediaPlayer.java:1787) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1785) | DEBUG | event=libvlc_MediaSubItemAdded
vlcj: (DefaultMediaPlayer.java:1787) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1785) | DEBUG | event=libvlc_MediaDurationChanged
vlcj: (DefaultMediaPlayer.java:1787) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1785) | DEBUG | event=libvlc_MediaParsedChanged
vlcj: (DefaultMediaPlayer.java:1787) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1785) | DEBUG | event=libvlc_MediaFreed
vlcj: (DefaultMediaPlayer.java:1787) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1785) | DEBUG | event=libvlc_MediaStateChanged
vlcj: (DefaultMediaPlayer.java:1787) | DEBUG | result=0
vlcj: (DefaultMediaPlayer.java:1647) | DEBUG | mrl(mediaInstance=native@0x12818f50 (uk.co.caprica.vlcj.binding.internal.libvlc_media_t@12818f50))
vlcj: (DefaultMediaPlayer.java:694) | DEBUG | play()
vlcj: (DefaultEmbeddedMediaPlayer.java:314) | DEBUG | onBeforePlay()
vlcj: (DefaultEmbeddedMediaPlayer.java:151) | DEBUG | attachVideoSurface()
vlcj: (CanvasVideoSurface.java:67) | DEBUG | attach()
vlcj: (CanvasVideoSurface.java:70) | DEBUG | componentId=592966
vlcj: (WindowsVideoSurfaceAdapter.java:41) | DEBUG | attach(componentId=592966)
vlcj: (CanvasVideoSurface.java:72) | DEBUG | video surface attached
vlcj: (DefaultMediaPlayer.java:2002) | DEBUG | mediaChanged(mediaPlayer=uk.co.caprica.vlcj.player.embedded.DefaultEmbeddedMediaPlayer@1f39a367,media=native@0x12818f50 (uk.co.caprica.vlcj.binding.internal.libvlc_media_t@12818f50),mrl=dshow://)
vlcj: (DefaultMediaPlayer.java:2006) | DEBUG | Raising event for new media
vlcj: (DefaultMediaPlayer.java:697) | DEBUG | after play
[0000000000408050] dshow demux error: can't open video device
[00000000003c7fe0] main input error: Invalid PCR value in ES_OUT_SET_(GROUP_)PCR !