Download Jar. Transpiled version (8024L) is out of date.
// 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); } }
Began life as a copy of #1033431
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033432 |
Snippet name: | Screenshotting with VLCJ!! (30 fps) |
Eternal ID of this version: | #1033432/20 |
Text MD5: | 36369065dab9824dae54d269fa114b33 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-27 14:17:57 |
Source code size: | 2565 bytes / 82 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 237 / 979 |
Version history: | 19 change(s) |
Referenced in: | -