Java 将RTSP转换为HTTP OGG格式时发生VLCJ错误
我正在开发一个解决方案,在我的react应用程序的HTML组件中显示IP摄像头。我正在使用VLC将实时RTSP视频源转码到OGG,我的应用程序可以成功找到并显示视频。我在VLC中使用此流输出字符串来执行此操作:Java 将RTSP转换为HTTP OGG格式时发生VLCJ错误,java,vlc,rtsp,vlcj,transcoding,Java,Vlc,Rtsp,Vlcj,Transcoding,我正在开发一个解决方案,在我的react应用程序的HTML组件中显示IP摄像头。我正在使用VLC将实时RTSP视频源转码到OGG,我的应用程序可以成功找到并显示视频。我在VLC中使用此流输出字符串来执行此操作: sout=#transcode{vcodec=theo,vb=800,scale=1,width=600,height=480,acodec=mp3}:http{mux=ogg,dst=127.0.0.1:8080/stream.ogg} :no-sout-rtp-sap :no-sou
sout=#transcode{vcodec=theo,vb=800,scale=1,width=600,height=480,acodec=mp3}:http{mux=ogg,dst=127.0.0.1:8080/stream.ogg} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep
我的源代码是一个简单的RTSP URLrtsp://Username:Password@IP/axis媒体/media.amp?videocodec=h264
问题来了,因为现在我需要用java来做。下面是一个完全精简的服务器的完整代码,它应该使用VLCJ启动VLC转码:
public static void main(String[] args) {
//if (args.length < 1) return;
int connectionCount = 0;
MediaPlayerFactory mFactory;
MediaPlayer mPlayer;
try (ServerSocket serverSocket = new ServerSocket(0)) {
System.out.println("Server is listening on port " + serverSocket.getLocalPort());
while (true && connectionCount == 0) {
Socket socket = serverSocket.accept();
System.out.println("New client connected");
connectionCount++;
System.out.println("Current connection count: " + Integer.toString(connectionCount));
mFactory = new MediaPlayerFactory();
mPlayer = mFactory.mediaPlayers().newMediaPlayer();
String mrl = "LEFT OFF FOR PRIVACY BUT A FUNCTIONAL RTSP LINK";
String options = "sout=#transcode{vcodec=theo,vb=800,scale=1,width=600,height=480,acodec=mp3}:http{mux=ogg,dst=127.0.0.1:8080/desktop.ogg} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep";
mPlayer.media().play(mrl, options);
new ServerThread(socket, mPlayer).start();
}
} catch (IOException ex) {
System.out.println("Server exception: " + ex.getMessage());
ex.printStackTrace();
}
}
publicstaticvoidmain(字符串[]args){
//如果(args.length<1)返回;
int connectionCount=0;
MediaPlayerFactory制造厂;
媒体播放器mPlayer;
try(ServerSocket-ServerSocket=newserversocket(0)){
System.out.println(“服务器正在侦听端口”+serverSocket.getLocalPort());
while(true&&connectionCount==0){
Socket=serverSocket.accept();
System.out.println(“新客户端连接”);
connectionCount++;
System.out.println(“当前连接计数:”+Integer.toString(connectionCount));
MFFactory=新的MediaPlayerFactory();
mPlayer=mFactory.mediaPlayers().newMediaPlayer();
String mrl=“出于隐私考虑,保留一个功能性RTSP链接”;
String options=“sout=#transcode{vcodec=theo,vb=800,scale=1,width=600,height=480,acodec=mp3}:http{mux=ogg,dst=127.0.0.1:8080/desktop.ogg}:no-sout-rtp-sap:no-sout-standard-sap:ttl=1:sout-keep”;
mPlayer.media().play(mrl,选项);
新的ServerThread(套接字,mPlayer).start();
}
}捕获(IOEX异常){
System.out.println(“服务器异常:+ex.getMessage());
例如printStackTrace();
}
}
}
所以问题是,代码转换字符串在VLC中工作得很好,但在Java中却出现了这个错误。我确保当时没有其他VLC流在运行。我不知道为什么它会在其中一个中完美地工作,而在另一个中却不能。错误如下:
[00000 1BBEEDE1D960]主流输出错误:“transcode{vcodec=theo,vb=800,scale=1,width=600,height=480,acodec=mp3}:http{mux=ogg,dst=127.0.0.1:8080/desktop.ogg}:无源rtp sap:无源标准sap:ttl=1:sout keep”
[00000 1BB96C930D0]主要输入错误:无法启动流输出实例,中止如果sout字符串中有空格,则这些实际上是单独的选项-因此类似以下内容:
String[] options = {
"sout=#transcode{vcodec=theo,vb=800,scale=1,width=600,height=480,acodec=mp3}:http{mux=ogg,dst=127.0.0.1:8080/desktop.ogg}",
":no-sout-rtp-sap",
":no-sout-standard-sap",
":ttl=1",
":sout-keep"
};
mPlayer.media().play(mrl, options);
非常感谢您的帮助,很高兴看到Caprica在这些线程中支持开发人员。谢谢。您熟悉这些错误吗?[00000 288D8908150]live555解复用错误:无法连接rtsp://[IP已删除以保护隐私]/axis media/media.amp?videocodec=h264[00000 288D8908150]live555解复用错误:无法连接rtsprtsp://IP 出于隐私考虑删除]/axis media/media.amp?videocodec=h264[00000 288D8A5ECE0]satip流错误:无法连接到RTSP服务器IP出于隐私被删除]:554[00000 288D8A5ECE0]satip流错误:无法连接到RTSP服务器IP出于隐私被删除]:554[00000 288D8A5ECE0]访问\u realrtsp流错误:无法连接到出于隐私被删除的IP]:554我在打开了票证,以便可以关闭并继续那里,仍在经历解复用故障。