Posts

Showing posts with the label netcat

Play H.264 Encoded Stream in JavaFX

Play H.264 Encoded Stream in JavaFX I have a Raspberry Pi getting video data from raspivid and piping that to netcat , which sends it to my PC where I can read each frame like this: raspivid netcat ServerSocketChannel serverChannel = ServerSocketChannel.open(); serverChannel.socket().bind(new InetSocketAddress(Main.config.getInt("VIDEO_STREAM_PORT"))); serverChannel.configureBlocking(true); SocketChannel channel = serverChannel.accept(); InetSocketAddress remoteAddress = (InetSocketAddress) channel.getRemoteAddress(); int BUFFER_SIZE = 2 << 16 - 1; ByteBuffer buff = ByteBuffer.allocate(BUFFER_SIZE); while (channel.read(buff) != -1) { buff.flip(); if (buff.hasRemaining()) { buff.compact(); } else { buff.clear(); } } What is the optimal way of playing these frames as video in JavaFX? Is there any way to do it besides decoding each frame as a BufferedImage and rendering that? Or is there another approach altogether that I'm missing? On Linux yo...