vlcj Save rtsp stream to file.

This forum is about all development around libVLC.
the_man
New Cone
New Cone
Posts: 7
Joined: 21 Dec 2012 00:46

vlcj Save rtsp stream to file.

Postby the_man » 21 Dec 2012 01:08

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!

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcj Save rtsp stream to file.

Postby sherington » 21 Dec 2012 18:17

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.

the_man
New Cone
New Cone
Posts: 7
Joined: 21 Dec 2012 00:46

Re: vlcj Save rtsp stream to file.

Postby the_man » 24 Dec 2012 05:54

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!

hsc160030
New Cone
New Cone
Posts: 1
Joined: 08 Feb 2017 01:36

Re: vlcj Save rtsp stream to file.

Postby hsc160030 » 08 Feb 2017 01:37

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


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 10 guests