2
votes

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

1

1 Answers

1
votes

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