// https://stackoverflow.com/a/48214101 // sudo apt install vlc-plugin-access-extra !!! !7 lib 1400526 // vlcj player (stable version for VLCJ 3) lib 1400527 // vlcj 3 lib 1400528 lib 1400529 // jna sS megaLibID = #1400525; import uk.co.caprica.vlcj.player.*; import uk.co.caprica.vlcj.player.direct.*; import uk.co.caprica.vlcj.player.direct.format.*; static BufferedImage image; static MediaPlayerFactory factory; static DirectMediaPlayer mediaPlayer; static int width, height; static FPSCounter fps; p { pnl(pairToList(addMegaLibrary(myClassLoader(), megaLibID))); fixContextClassLoader(); width = screenWidth(); height = screenHeight(); print(width + "/" + height); 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=" + width, ":screen-height=" + height, ":screen-left=0", ":screen-top=0" }; pnl(options); 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) { if (fps == null) fps = new FPSCounter; fps.inc(); print("Got image data (" + n2(l(data)) + ") - " + fps! + " fps"); // 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); } }