2

I am working on a solution to display IP camera in a HTML component in my react app. I am transcoding the live RTSP video feed using VLC to OGG and my app can successfully find and display the video. I use this stream output string in VLC to do so:

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

My source is a simple RTSP URL rtsp://Username:Password@IP/axis-media/media.amp?videocodec=h264

The problem comes since now I need to do it in java. Below is the full code for a completely stripped down server that it supposed to start the VLC transcoding using VLCJ:

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();
    }
}

}

So the problem is that the transcoding string works perfectly in VLC but spits out this error in Java. I make sure no other VLC streams are running at the time. I don't know why it would work flawlessly in one but not the other. Error below:

[000001bbede1d960] main stream output error: stream chain failed for `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] main input error: cannot start stream output instance, aborting

macmeyers50
  • 309
  • 2
  • 15

1 Answers1

1

Where you have spaces in your sout string, those are actually separate options - so something like this instead:

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
  • 3,902
  • 4
  • 19
  • 39
  • Really appreciate the help, cool to see Caprica all over these threads supporting devs. Thank you. – macmeyers50 Apr 20 '20 at 12:16
  • Are you familiar with these errors? [00000288d8908150] live555 demux error: Failed to connect with rtsp://[IP removed for privacy]/axis-media/media.amp?videocodec=h264 [00000288d8908150] live555 demux error: Failed to connect with rtsp://IP removed for privacy]/axis-media/media.amp?videocodec=h264 [00000288d8a5ece0] satip stream error: Failed to connect to RTSP server IP removed for privacy]:554 [00000288d8a5ece0] satip stream error: Failed to connect to RTSP server IP removed for privacy]:554 [00000288d8a5ece0] access_realrtsp stream error: cannot connect to IP removed for privacy]:554 – macmeyers50 Apr 20 '20 at 13:18
  • I opened the ticket at https://github.com/caprica/vlcj/issues/943 so I can close and continue there, still experiencing demux failures. – macmeyers50 Apr 20 '20 at 14:27