Recently a friend of mine, who’s a singer asked me if I could help her get some videos of her performances from a website before they remove them. I discovered that the site didn’t have .flv urls in the source code, but instead used the RTMP streaming protocol. I did some googling and found a blog post that mentioned a command line utility called rtmpdump, which can be used to download the stream http://www.meydad.com/2012/07/14/how-to-download-a-rtmp-stream-to-a-local-flv-file-using-rtmpdump-for-mac/. That got me on the right track, but I still didn’t have the url. I then found a very good video on YouTube, which got me even further http://www.youtube.com/watch?v=8PuUnQCS7DQ. I was almost successful after combining these tutorials, but the video ended up skipping and was broken. After a long google session I noticed that one project that uses rtmpdump is ffmpeg. After some exploration I found the right parameters and was successful in downloading the videos. The process goes like this:
- Start Wireshark and start capturing network traffic
- Start playing the video on website
- Stop network capture
- Analyze capture data and formulate rtmp url (by combining rtmp location and video filename)
- Use ffmpeg to download the stream from the url
Here’s how you can do it on a Mac running Mountain Lion.
- In order to install ffmpeg, you can install a package manager called Homebrew by issuing the following:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
- Then issue the following commands:
brew doctor brew install ffmpeg
- In order to use Wireshark you have to have an X11 Window System installed. You can download and install the open-source XQuartz for Mac.
- Download and install Wireshark from http://www.wireshark.org/.
- Now you should have everything installed. Before you can open Wireshark, you have to have XQuartz running, so launch it now (it takes a while to open).
- After the X11 terminal window has opened, launch Wireshark.
- You can find good instruction for the Wireshark part in the YouTube video I mentioned earlier, but here’s a recap:
- Select network interface (en0)
- Click “Start”
- Write “rtmpt” in the filter box
- After the correct video has been playing for a few seconds stop the capture with Capture->Stop. You can now stop playing the video.
- Sort by the Source column and find and select the entry where the source was your IP and where it says “play(..” in the info field. (There might be several, if the video had adds for example)
- Right click and select “Follow TCP stream”
- Click “Find” and write “rtmp”. This will tell you the root url (tcUrl) of the stream (in my case it continued onto the next row until the last /-character).
- Then click “Find” again and search for “mp4”, which will give you the filename to append to the root url. You can also manually look for it, since it is close to the root url.
- Now you can download the clip with the following command
ffmpeg -i rtmp://rootUrl/filename.mp4 -c copy dump.mp4
And that’s it. Seems kind of difficult, but once you’ve done it once, it’s fast and easy.



0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.