Articles

Navigation ( archives ›› 2007 ›› July ›› 13 ›› How-To rip Real Media RTSP Streams to MP3 using MPlayer )

How-To rip Real Media RTSP Streams to MP3 using MPlayer

Posted on July 13, 2007, 12:16 am EST

Using Ubuntu 7.04 fiesty (could be done in Windows) I will talk about how to rip Real Media ( rm ) RTSP ( Real Time Streaming Protocol ) streams from the internet to its specified format (rm) or as an audio file. Many users have asked me this questions on newsgroups, forums, and friends, so here is working solution that I have tested it on 3 different RTSP streams. Live Streaming, Streaming with Audio and Video, Streaming with Audio and no video, and Streaming with Audio and Static Image as Video. I hope this will be as help for you as it did for me.

Basically, there are programs out there which cost $40 or more to rip live real media streams from the net easily but 90% of them don't work correctly. I have found MPlayer which is an Open Source application which is amazing. From the website the definition of MPlayer is as follows: "MPlayer is a movie player which runs on many systems (see the documentation). It plays most MPEG/VOB, AVI, Ogg/OGM, VIVO, ASF/WMA/WMV, QT/MOV/MP4, RealMedia, Matroska, NUT, NuppelVideo, FLI, YUV4MPEG, FILM, RoQ, PVA files, supported by many native, XAnim, and Win32 DLL codecs. You can watch VideoCD, SVCD, DVD, 3ivx, DivX 3/4/5 and even WMV movies." The website for Mplayer is http://www.mplayerhq.hu/

Intro

As of writing this post, my MPlayer Version is MPlayer dev-SVN-r23770-4.1.2, make sure you install that. If your using distributions such as Ubuntu, Redhat, Suse, etc (which has MPlayer in its repositories, they do not usually have the latest version. Make sure you have it. And make sure you install all relative codecs. I will explain in brief on how you can install the latest version, how you install the important codecs, and finally how to rip RM (Real Media) Streaming files from the net.

The reason why I am saying that, is because you need to recompile Mplayer since there is a small glitch: "If you have a Pentium 4 and are experiencing a crash using the RealPlayer codecs, you may need to disable hyperthreading support." so we have to recompile MPlayer and omitting the flags '--enable-runtime-cpudetection'

Install the newest version of MPlayer in Ubuntu 7.04 Fiesty

This will take a lot of time since we are going to compile MPlayer directly from their repository (subversion) since we need the newest version. Older versions tend not to function correctly.

We need to download all the dependencies of MPlayer before we do this. This is how you download the dependencies in Ubuntu:

CODE:
$ sudo apt-get build-dep mplayer

Now we need to download the latest MPlayer version from subversion (svn). You might need to download SVN to do this:

CODE:
$ sudo apt-get install subversion

Now it is time to download the contents:

CODE:
$ svn co svn://svn.mplayerhq.hu/mplayer/trunk *

CD into that directory after all has been downloaded and we need to compile it:

CODE:
$ ./configure --enable-largefiles --enable-gui
$ ./make

NOTE: You can install it, but if you have mplayer already installed, your ubuntu updates will over right this current new build with the old one when updating. So it would be best to rename "mplayer to mplayer2" or something. And note as well, we omitted the '--enable-runtime-cpudetection' flag. That is the main reason why we are recompiling from SVN.

CODE:
$ cp mplayer mplayer2

That is it, MPlayer is installed! Now it is time to configure it by installing the codecs

Install MPlayer Windows Media and Real AudioCodecs in Ubuntu

The codecs are not bundled with MPlayer due to copyright issues, so you have to download the following codecs (I am listing all the good ones in case you want to rip other streams rather than Real Media:

  1. gstreamer0.8-plugins
  2. gstreamer0.8-lame
  3. gstreamer0.8-ffmpeg
  4. lame
  5. sox
  6. ffmpeg
  7. mjpegtools
  8. vorbis-tools
  9. libdvdcss2
  10. w32codecs

Now, the first 8 are bundled with Ubuntu or any other distribution by just using the repository, in Ubuntu I type the following command the starting codecs:

CODE:
$ sudo apt-get install gstreamer0.8-plugins gstreamer0.8-lame gstreamer0.8-ffmpeg lame sox ffmpeg mjpegtools vorbis-tools

Now, we have to install the important Windows codecs which are libdvdcss2 and w32codecs. We have to edit our repository sources and add the 3rd party (trusted) source to download the codecs. To do this, follow the following:

CODE:
$ echo "deb http://packages.medibuntu.org/ feisty free non-free" | sudo tee -a /etc/apt/sources.list
$ wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O- | sudo apt-key add - && sudo apt-get update

Now since we added the new repository, we could install the codecs using apt-get.

CODE:
$ sudo apt-get install w32codecs libdvdcss2

Now we are done. The necessary codecs are installed. Lets learn how to RIP!

How to rip Real Media RTSP Streams to MP3

By theory, whatever you listen you can save, correct? So, whatever we listen or 'stream' we could save it. So, if we have to listen to a 25 minute video or audio, it takes 25 minutes to rip it.

First of all, we need download the audiostream and save it on to the hard drive. I will be using a real media file from Stanford which uses AUDIO + Static Image as its format. We do this at first, to dump all audio on to disk, this will take 50 minutes, since the length of the streaming file is 50minutes. Within the terminal screen, type in the following:

CODE:
$ mplayer -ao pcm rtsp://vodreal.stanford.edu/opa/philo/070325.rm

While downloading, you can open another terminal screen window, and check if it is really downloading by doing:

CODE: 
$ ls -lh audiodump.wav
-rw-r--r-- 1 m0 m0 55M 2007-07-12 21:11 audiodump.wav

Notice the audio dump is in a wav format, this format will be huge, around 550MB for 50minutes, so we have to encode it to MP3.

How to Encode WAV to MP3 using LAME

The answer is quite simple, we just do this command:

CODE:
$ lame -preset-standard audiodump.wav finally_my_audio.mp3

You can play around with the encoding with fooling around with the advanced options, but that is basically it, our mp3 file ripped by an RTSP stream using Ubuntu, same thing could be done in any OS (OSX, Windows) since MPlayer is a cross platform application!

Conclusion

I will repeat my steps in sequential order:

  1. Install MPlayer and LAME
  2. Install Codecs for MPlayer
  3. Download Audio Dump File: mplayer -ao pcm URL
  4. Convert audiostream.wav to .mp3: lame -preset-standard audiodump.wav newfile.mp3

I hope that will solve all your problems, if not, leave a comment and I will help you as much as I can! Good Luck

About this Article:

Comments (6) - Add yours, or View the replies

Categoy (Software)

Views (18085)

Digg it: Digg this article