我正在研究一个解决方案,在我的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-sout-standard-sap :ttl=1 :sout-keep我的源码是一个简单的RTSP URL rtsp://Username:Password@IP/axis-media/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();
}
}}
所以问题是,代码转换字符串在VLC中工作得很好,但在Java中却会显示出这个错误。我确保此时没有其他VLC流在运行。我不知道为什么它在其中一个中可以完美地工作,而在另一个中却不能。以下错误:
000001bbede1d960主流输出错误:` `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‘000001bb96c930d0主输入错误:无法启动流输出实例,正在中止
发布于 2020-04-18 16:00:41
在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);https://stackoverflow.com/questions/61280575
复制相似问题