Search code examples
vlcsdprtsp-client

Use VLC to fetch SDP file once using RTSP


Context

  • Most RTP streams (from e.g. an IP camera) need some information from a SDP to be able to decode them.
  • SDP is usually fetched just in time, usually from a RTSP URL but other means are possible (e.g. HTTP).

Specific case

We have a situation where an RTP stream (from a camera, UDP sent at all time whether anyone listens or not) will be played using VLC, but providing VLC an RTSP URL to fetch SDP just in time is not an option.

There is a RTSP service yet we need to query it in advance and dump the resulting SDP file to feed it to VLC later. Doing a RTSP query just-in-time is useless anyway since the stream exists at all times.

How to do that with VLC?

Search before you post

Of course I've been searching Google, videolan wiki and StackExchange.

Information is difficult to find because when people talk about streaming, RTSP, RTP, they are generally usig VLC to generate a RTP stream, or output a SDP that VLC generates because it does the encoding, etc. It's not the case here. The SDP to dump comes from the serveur with a single RTSP query.

Question

Basically, I'm looking for a command-line like:

vlc --sout...something...rtsp://sourceIP:Port/...something...out...myfile.sdp

That would dump the SDP in myfile.sdp.

Then, later, running vlc with the myfile.sdp as argument is expected to play the stream.


Solution

  • We did not find a solution using VLC alone (I even looked a little at the VLC source code). So we used a somehow "brute force" solution but hey, it works.

    What we do at configure time is ask VLC to play stream once, while Wireshark captures packets with filter rtsp and sdp. One packet appears containing the SDP data we want. We select it and use "extract selected bytes to ..." and save to a file with name ending with .sdp.

    That gives us a file containing the SDP information we want. Job done.