RTSPget - download an RTSP stream

A frequently recurring question is "How can I download an RTSP stream so that I can watch it later?" This is probably because your network bandwidth isn't high enough to make the stream watchable live, or it may just be because you want to save it for later.

Now that the folks at xine have implemented an RTSP input filter, you can do just that! However, until stream-dumping is included in xine (or RTSP is included in Mplayer) the only way to do it seems to be via a program which calls xine's RTSP code directly.

Notes:

Source code

Build instructions

  1. First build the `libreal' and `librtsp' libraries from the xine distribution. If you haven't already built the whole of xine then something like the following might work.
     $ cd /usr/src/xine-lib-1-beta4
     $ ./configure
     $ cd src/input/libreal
     $ make
     $ cd ../librtsp
     $ make
    
    Now copy the completed libraries to wherever you put the `rtspget' source code. You'll find them in subdirectories called `.libs' of the libreal and librtsp directories, and their names will end with `.al', although you will have to rename them to `.a' when you copy them.
  2. Now compile the two source files. You will need access to some of the include files from the xine source tree. Something like the following may be appropriate.
     $ gcc -O3 -c -I/usr/src/xine-lib-1-beta4/src/input rtspget.c
     $ gcc -O3 -c xineutils.c -I/usr/src/xine-lib-1-beta4/include \
       -I/usr/src/xine-lib-1-beta4/src/xine-utils
    
  3. Link it all together and hope it works. . .
     $ gcc -o rtspget rtspget.o xineutils.o -L. -lrtsp -lreal
    

Using it

For best results, supply an MRL and an output file name (in that order). The MRL must start with `rtsp://'. You can also write (in any order):
-qbe quiet
-vbe verbose
-ochoose the output file name.
Note: `-o' can either be followed by a file name or placed last on the command line: in the latter case, the output file will be named after the MRL's base name (starting from the last slash).

If you don't name an output file, the program will output to stdout - although you probably don't want it to do that, for reasons explained below.

If you don't specify the quiet flag you'll get a running count of bytes downloaded so far (this is displayed on stderr).

Beware!

The RTSP code in xine is not perfect, so you may encounter some problems. Note that it doesn't seem to work at all on big-endian architectures.

That's it

Yup. Enjoy!