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
Excellent instructions.
Just two minor quibbles :
FIrst, dport in the the two iptables commands should be preceded by two successive minus signs (–). It seems some text processing software merged the two minus signs into one long horizontal dash (–), so copy-pasting the command gives the dport as unrecognised option.
Second, the rtmpdump command given in the console where we started the rtmpsrv server must be run as root, so one should change the permissions of the resulting file in order to ba able to access it as a regular, non-root user. The commands chmod and chown are one way to do this.
Yes, you are right concerning the two successive minus signs, WordPress coverts them automatically to a long hyphen and I ignore how to prevent this from happening.
Regarding running the program as root, I’m not sure. I do not remember running it as root or having to use chmod or chown at all. I’ll verify it when I have the time. In my case, rtmpdump displayed the output in the console and I copied and pasted that output in a different shell.
Could be a problem with my permissions settings. But, on my system, it refuses to open the output file, unless I give the rtmpdump command as root.
What this iptables rule actually does?
I get an error msg:
iptables -t nat -A OUTPUT -p tcp –dport 1935 -j REDIRECT && rtmpsrv
Bad argument `–dport’
Try `iptables -h’ or ‘iptables –help’ for more information.
After reading all the posts, and figuring out the error in the –dport, instead of the long hyphen that it shows, I ws able to correct it, and start again.
However, I get the following msg:
RTMP Server v2.4 df6c518~git
(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL
Streaming on rtmp://0.0.0.0:1935
Segmentation fault
Is it doing anything???
How do I know?
Is this an error msg?
1.- The method was not working here either last time I tried.
2.- Segmentation fault, that seems like a problem with your binary file. Have you compiled the code yourself or are you using a precompiled binary? In the second case, does it match your architecture or library versions?