How to download streaming media with RTMPDump
Often, we watch multimedia content on-line and we would like to be able to download it for off-line viewing or other purposes. In certain cases, video-sharing websites provide a download link so that we can download the video file directly. In addition, there are a number of convenient web browser plug-ins that enhance our browser with the capability of downloading multimedia content from web sites. Such is the case of the Firefox plug-in DownloadHelper and others. However, most of those plug-ins work only in the most popular sites, but not in all. Sometimes, one can find the link to the streaming file just by having a look to the page source. Yet an alternative trick consists on finding the multimedia file in your browser cache, but the newer versions of Adobe Flash Player make this task much more complicated.
RTMPDump is a very powerful tool that help us to find the actual source of multimedia content. The big advantage is that it is relatively site-independent and should work in for any site using the Real Time Messaging Protocol (RTMP), which nowadays means most of the sites. The only disadvantage is that it is a command-line tool. Herein, I am going to explain how to use RTMPDump to figure out the source of a streaming video.
1.- First we need to install RTMPDump. In most Linux distros you can simply use your package manager.
2.- Next we start the server. As root we type this in a console:
iptables -t nat -A OUTPUT -p tcp –dport 1935 -j REDIRECT && rtmpsrv
3.- Now, in our browser, we load or reload the page in which the video is displaying and play the video.
4.- In the console where we started thertmpsrv server, we should see the command we need to use to download the video.
5.- Now we interrupt the server by doing “Crtl + c” at the console and typing:
iptables -t nat -D OUTPUT -p tcp –dport 1935 -j REDIRECT
6.- Next, we just copy and paste the command we need to use to download the video.
And voilà! Just make sure that you are legally entitled to capture that content.
In some cases, the command will give you valuable information on how to download other files. For instance, in one case, RTMPDump allowed me to download the streamed flv file, but with that information I was also able to figure out how download the corresponding HD mp4 file stored in the same server:
wget –wait=2 –waitretry=2 –timeout=2 -d –retry-connrefused -c http://media.tsr.ch/tj/2011/tj_20111118_full_f_FINGERPRINT-1201k.mp4 -O 19.30.mp4