// https://stackoverflow.com/a/48214101 !7 lib 1400526 // vlcj player (stable version for VLCJ 3) lib 1400527 // vlcj 3 sS megaLibID = #1400525; import uk.co.caprica.vlcj.player.*; import uk.co.caprica.vlcj.player.direct.*; static BufferedImage image; static MediaPlayerFactory factory; static DirectMediaPlayer mediaPlayer; p { pnl(addMegaLib(myClassLoader(), megaLibID)); fixContextClassLoader(); image = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(width, height); image.setAccelerationPriority(1.0f); String mrl = "screen://"; String[] options = { ":screen-fps=30", ":live-caching=0", ":screen-width=1920", ":screen-height=1080", ":screen-left=0", ":screen-top=0" }; factory = new MediaPlayerFactory(); mediaPlayer = factory.newDirectMediaPlayer(new TestBufferFormatCallback(), new TestRenderCallback()); mediaPlayer.playMedia(mrl, options); } // Callbacks are required. sclass TestRenderCallback extends RenderCallbackAdapter { public TestRenderCallback() { super(((DataBufferInt) image.getRaster().getDataBuffer()).getData()); } @Override public void onDisplay(DirectMediaPlayer mediaPlayer, int[] data) { // The image data could be manipulated here... /* RGB to GRAYScale conversion example */ // for(int i=0; i < data.length; i++){ // int argb = data[i]; // int b = (argb & 0xFF); // int g = ((argb >> 8 ) & 0xFF); // int r = ((argb >> 16 ) & 0xFF); // int grey = (r + g + b + g) >> 2 ; //performance optimized - not real grey! // data[i] = (grey << 16) + (grey << 8) + grey; // } // imagePane.repaint(); } } sclass TestBufferFormatCallback implements BufferFormatCallback { @Override public BufferFormat getBufferFormat(int sourceWidth, int sourceHeight) { return new RV32BufferFormat(width, height); } }