I wanted to stream the screen using VLCJ through HTTP. I am able to do the video streaming with the webcam but when I tried stream my screen It gives me following output and the application stops:
Java Result: -1073741676
This is the code which I am using:
public class StreamHttp extends VlcjTest {
static MediaPlayerFactory mediaPlayerFactory;
public static void main(String[] args) throws Exception {
new NativeDiscovery().discover();
String options = formatHttpStream("127.0.0.1", 5555);
mediaPlayerFactory = new MediaPlayerFactory(args);
HeadlessMediaPlayer mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer();
mediaPlayer.playMedia("screen://", options);
Thread.currentThread().join();
}
private static String formatHttpStream(String serverAddress, int serverPort) {
StringBuilder sb = new StringBuilder(60);
sb.append(":sout=#transcode{vcodec=mp4v,vb=800,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:duplicate{dst=std{access=http,mux=ts,");
sb.append("dst=");
sb.append(serverAddress);
sb.append(':');
sb.append(serverPort);
sb.append("}}");
return sb.toString();
}
}
Kinldy help!!
Okay so after some struggle and searching I found that there was an issue with VLC player 2.2.4 which is the latest release. I switched to VLC 2.1.3 and everything was perfect. Got to know that they are working to fix it. So no issue with the code.