Lectopia rtsp stream capture

Lectopia is used by my university to publish recordings of lectures. Many of the lecturers make downloadable copies of the lectures available. Unfortunately, some lecturers only make streams of their lectures available. This sucks because skipping back and forth in a lecture is extremely slow, and unlike youtube or similar, if you want to skip back and re-watch a section of the lecture, that section has to be downloaded again – no caching. The streams are not capturable using standard utils – it isn’t possible to rip the stream directly using either vlc -demux=dump or mplayer -dumpstream.

eg. mplayer -dumpstream gives:

unsupported RTSP server. Server type is 'QTSS/6.0.2 (Build/526.2; Platform/MacOSX; Release/Mac OS X Server; )'.
...
Cannot dump this stream - no file descriptor available.

Instead, if you want to make a copy of the stream you must re-encode it. Fortunately, this is easy with mencoder. Below is a script I wrote, which takes a command line argument of the stream address and saves the file using the first 10 characters of the stream name – which is usually YYMMDDTTTT (year, month, day and time).

#!/usr/bin/env bash
DATE=`echo $1 | sed 's/.*iLectures.\{10\}\(.\{10\}\).*/\1/'`
`mencoder $1 -oac mp3lame -lameopts cbr:br=56 -ovc x264 -x264encopts bitrate=100 -rtsp-stream-over-tcp -o $DATE.avi`

The default video bitrate of 100 kbits/second is fine for “slides+voiceover” lecture recordings and results in ~1MB/minute filesize (with the audio bitrate of 56). You may want to use a higher video bitrate if you’ve got more action on-screen. I set up 6 instances of at the same time and yanked

Hopefully someone will find this useful.

Tags: , ,

One Comment

  • songuke says:

    Works nicely for me. I’m looking for a way to dump a rtsp stream too. The rtsp source I’m trying also cannot be dumped by mplayer -dumpstream, in which the “no file descriptor available” error is returned. Your script saves me from a big trouble. :)

    Thanks.

Leave a Reply

XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>