Lectopia rtsp stream capture IV

Another version of the script, this one attempts to get the address of the media from the address of the ‘Copyright’ window. It may work better or be easier to use than the script in Lectopia III. YMMV :P

getlect2.sh:

# extract the fid from the URL
FID=`echo "$1" | sed 's/^.*fid=\(.*\)\&cnt.*/\1/'`

# extract the base from the URL
BASEURL=`echo "$1" | sed 's/\(.*\)\/cast.*/\1/'`

# get the playlist file address
PLAYLIST=`wget -q -O - "$BASEURL/servepointer.lasso?FormatID=$FID" | grep rtsp | sed 's/.*rtsp:\/\/\(.*\)".*/\1/'`

# get the media file from the playlist file
MEDIA=`wget -q -O - $PLAYLIST | grep rtsp: | sed 's/.*src="\(.*\)".*/\1/' | sed 's/\r//'`

# get the date of the media file (to save file as)
DATE=`echo $MEDIA | sed 's/.*iLectures.\{10\}\(.\{10\}\).*/\1/'`

# actually rip the stream
mencoder $MEDIA -oac mp3lame -lameopts cbr:br=56 -ovc x264 -x264encopts bitrate=100 -rtsp-stream-over-tcp -o $DATE.avi

Steps to use:

  • Select the highest quality quicktime stream from the dropdown menu in the Lectopia Recordings List and click the Open button.
  • Copy the address of this window. If the address bar is hidden in your browser, you can get the address from the Page Info box. (shortcut in some browsers is Ctrl-I)
  • run ./getlect2.sh ‘http://…’ (make sure you have quotes around the address as shown)

Lectopia rstp stream capture III

Quick update in response to a comment on my previous lectopia stream ripping saving script. Apparently they changed the playlist format slightly which was enough to break my script.
Anyway, this should work for the new format and the old format. (not entirely certain about the old format, since it’s no longer available)

#!/usr/bin/env bash

# remove the protocol from the front of the URL if if necessary
INPUT=`echo $1 | sed 's/.*:\/\///'`

# Snip the URL from the playlist file
URL=`wget -q -O - $INPUT | grep rtsp: | sed 's/.*src="\(.*\)".*/\1/' | sed 's/\r//'`

# Store the DATE from the file
DATE=`echo $URL | sed 's/.*iLectures.\{10\}\(.\{10\}\).*/\1/'`

# re-encode the file data, using the DATE as the name
mencoder $URL -oac mp3lame -lameopts cbr:br=56 -ovc x264 -x264encopts bitrate=100 -rtsp-stream-over-tcp -o $DATE.avi

Quick notes on usage:

  • Copy the script above to a file eg. ‘getlect.sh’. Make the file executable with ‘chmod +x getlect.sh’.
  • On the Lectopia Recordings List, select the highest quality Quicktime stream from the dropdown and click the open button.
  • Click the ‘continue’ button after ignoring the copyright warning :-P
  • I have the the gecko-mediaplayer plugin for firefox installed under (k)ubuntu, and it gives a black screen here. You can right-click this black screen and select ‘copy location’ to get the playlist URL (it should start with “rstp://…”). If you have a different video plugin, you might have to inspect the frame source or something to get the stream address.
  • Run the script ‘./getlect.sh rstp://…’

Note that it will take as long to ‘rip’ the stream as it does to watch it, because the server sends it at a set rate. However if you have a good internet connection you can save several in parallel by running the script in a few different terminal windows (I’ve had 4 going in parallel before).

Any issues with the script, or if you find it useful, let me know. :)

Lectopia rtsp stream capture II

A new semester, and some more hacking on the ‘dumpstream’ script. Now it is a little smarter because it can read the playlist file given by lectopia, and extract the rtsp stream URL from it:

#!/usr/bin/env bash

# Snip the URL from the playlist file
URL=`wget -q -O - $1 | grep rtsp | sed 's/.*src="\(.*\)".*/\1/'`

# Store the DATE from the file
DATE=`echo $URL | sed 's/.*iLectures.\{10\}\(.\{10\}\).*/\1/'`

# re-encode the file data, using the DATE as the name
`mencoder $URL -oac mp3lame -lameopts cbr:br=56 -ovc x264 -x264encopts bitrate=100 -rtsp-stream-over-tcp -o $DATE.avi`

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.