Page 1 of 1

vlcj Save rtsp stream to file.

Posted: 21 Dec 2012 01:08
by the_man
Just started using vlcj and I'm trying to save an rtsp stream to file.

Have been looking at the example http://code.google.com/p/vlcj/source/br ... java?r=992 and trying to modify it so instead of forwarding the stream it saves it to a file.

I'm not sure what to change the "options" in "mediaPlayer.playMedia(media, options)" to.

The options from the sample code are: ":sout=#rtp{sdp=rtsp://@127.0.0.1:5555/demo}:no-sout-rtp-sap:no-sout-standard-sap:sout-all:sout-keep"

I changed these to: ":sout=file/ps:stream.mpg:no-sout-rtp-sap:no-sout-standard-sap:sout-all:sout-keep" trying to follow this website http://tldp.org/HOWTO/VideoLAN-HOWTO/x585.html, but that gives the error:

[04ceae18] mux_ps mux: Open
[04ceae18] main mux error: cannot add this stream
[04d9c098] main decoder error: cannot create packetizer output (h263)

I've been looking online, but haven't been able to find any documentation for these options. Does anyone know where I can find some documentation? Or better, what I need to change in the options so the stream is saved to a file?

Thanks in advance!

Re: vlcj Save rtsp stream to file.

Posted: 21 Dec 2012 18:17
by sherington
The example in the link you posted is for an RTSP server, not client. I'm assuming you want your *client* to save the stream.

Here is an example that transcodes and saves an RTSP stream to a file (I used vlc itself to serve the RTSP stream):

Code: Select all

public class SaveStream { public static void main(String[] args) throws Exception { MediaPlayerFactory factory = new MediaPlayerFactory(); MediaPlayer player = factory.newHeadlessMediaPlayer(); String mrl = "rtsp://@127.0.0.1:5555/demo"; String options = ":sout=#transcode{vcodec=h264,venc=x264{cfr=16},scale=1,acodec=mp4a,ab=160,channels=2,samplerate=44100}:file{dst=/home/wibble/test.mp4}"; player.playMedia(mrl, options); Thread.sleep(20000); // <--- sleep for 20 seconds, you should use events - but this is just a demo player.stop(); player.release(); factory.release(); } }
This works for me - it generates a local file that can be played back successfully.

As to what the options should be, well that depends on what you want to do - there's no universal answer.

Re: vlcj Save rtsp stream to file.

Posted: 24 Dec 2012 05:54
by the_man
Awesome! Thank you very much sherington! That works brilliantly :)

A few related questions:
1. Do you know of any documentation for the options?
2. My video file has no sound. How can I get sound as well?
3. I get the warning "x264 [warning]: invalid DTS: PTS is less than DTS". How can I fix this?

Thanks again for your help sherington!

Re: vlcj Save rtsp stream to file.

Posted: 08 Feb 2017 01:37
by hsc160030
Hi,

I am getting below error when I am using the above code for streaming rtsp.

000000001d1f7630] live555 demux error: Failed to connect with rtsp://192.168.0.100:10554/tcp/av0_1
[000000001d18a9d0] core input error: open of `rtsp://192.168.0.100:10554/tcp/av0_1' failed
[000000001d18a9d0] core input error: Your input can't be opened
[000000001d18a9d0] core input error: VLC is unable to open the MRL 'rtsp://192.168.0.100:10554/tcp/av0_1'. Check the log for details.


Can you please help?

Thanks
Harprit