我想通过HTTP使用VLCJ流式传输屏幕。我能够使用网络摄像头进行视频流传输,但是当我尝试流式传输屏幕时,它给了我以下输出,应用程序停止:
Java 结果: -1073741676
这是我正在使用的代码:
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();
}
}
金尔迪救命!!
好的,
经过一些挣扎和搜索,我发现最新版本的VLC播放器2.2.4存在问题。我切换到VLC 2.1.3,一切都很完美。知道他们正在努力修复它。所以代码没有问题。