neddie Posted July 27, 2010 Report Share Posted July 27, 2010 This question is similar to Kieth's question, but I'm specifically interested in RTMP streams played by a flash player called "JW Player". I'm trying to use rtmpdump but I keep getting errors. In the html page, several parameters are passed to the flash player, including the following: 'streamer' : 'rtmp://ip.address/vod', 'file' : 'reallylongalphanumericstring', 'javascriptid' : 'video', 'type' : 'encrypt', 'enablejs' : 'true' I've also got the url to the swf file used to play the video. My question is, what do I have to give to rtmpdump to download the stream for later? I've tried this: rtmpdump -r rtmp://ip.address/vod -y reallylongalphanumericstring -W http://url.to/player.swf -o output.flv but I just get the error: Connecting ... INFO: Connected... ERROR: rtmp server sent error ERROR: rtmp server requested close I also tried the options -l 2 (to specify encryption), -a video (to specify the application name), but nothing works. I also tried the verbose option but just see things like: DEBUG: HandShake: Genuine Adobe Flash Media Server DEBUG: HandShake: Handshaking finished.... DEBUG: RTMP_Connect1, handshaked DEBUG: Invoking connect INFO: Connected... DEBUG: Property: <Name: level, STRING: error> DEBUG: Property: <Name: code, STRING: NetConnection.Connect.Rejected> DEBUG: Property: <Name: description, STRING: Connection failed.> which doesn't bring me much closer. It seems to be at least trying to use encryption and handshaking, but just gets a rejection message. Has anyone done something similar to this with more success? Quote Link to comment Share on other sites More sharing options...
Greg2 Posted July 28, 2010 Report Share Posted July 28, 2010 I played with this a little today and I've had some 'limited' success with rtmpdump v2.3 using the following guide: revisiting-rtmpdump I was using Mandriva 2010 and downloaded the rtmpdump-2.3.tgz located here: http://rtmpdump.mplayerhq.hu/download/ Then I compiled it using make SYS=posix for Linux systems. Quote Link to comment Share on other sites More sharing options...
neddie Posted July 29, 2010 Author Report Share Posted July 29, 2010 Thanks, Greg2. I followed the instructions you linked to, and used iptables to redirect my rtmp traffic. Then I ran rtmpsrv and expected to see the rtmpdump command printed out in the console when I played the stream. But of course the flash plugin couldn't play the stream due to the rtmp traffic being diverted, and rtmpsrv couldn't connect to it either for the same reason, so all I got was a spinning flash plugin and in the console this: RTMP Server v2.3 (c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL Streaming on rtmp://0.0.0.0:1935 WARNING: Trying different position for client digest! ERROR: RTMP_ReadPacket, failed to read RTMP packet header Closing connection... done! For giggles I tried rtmpsuck too, but got a similar output: RTMP Proxy Server v2.3 (c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL Streaming on rtmp://0.0.0.0:1935 WARNING: Trying different position for client digest! Processing connect app: vod flashVer: LNX 10,0,32,18 swfUrl: <url of swf file> tcUrl: <rtmp url> pageUrl: <url of webpage> ERROR: RTMP_Connect1, handshake failed. ERROR: RTMP_ReadPacket, failed to read RTMP packet header Closing connection... done! ERROR: WriteN, RTMP send error 32 (1536 bytes) ERROR: Handshake failed Closing connection... done! Then I undid the iptables change and tried rtmpdump again, this time also giving the webpage url with the -p option, but I just got the same errors as before, sent error, requested close. I tried playing the stream normally and it works fine. I guess I just don't get the iptables bit - if all the rtmp traffic is being diverted to localhost then it can never do the right handshaking etc because it can never contact the server. The README talks about setting an iptables rule for a specified user, which would make sense, but is that the user who is running rtmpsrv or the user running the browser? Your link doesn't even mention this bit. Has anyone got any clues how to get rtmp(dump|src|suck) working on this stream? Quote Link to comment Share on other sites More sharing options...
boatman9 Posted July 29, 2010 Report Share Posted July 29, 2010 Anyone tried flvstreamer? Quote Link to comment Share on other sites More sharing options...
neddie Posted August 2, 2010 Author Report Share Posted August 2, 2010 Ok, I've managed to get some partial success here. What I did was this: - Create a new user. I called him "charlie" - Set up iptables so that everybody apart from charlie has their rtmp traffic diverted. The command I used (as root) was this: iptables -t nat -A OUTPUT -p tcp --dport 1935 -m owner ! --uid-owner charlie -j REDIRECT - From a console, become charlie: su charlie cd (It's important to "cd" so that charlie is able to write files) - As charlie, start rtmpsuck: /usr/sbin/rtmpsuck - Use the browser (as your regular user) to access the stream. The traffic will be diverted, and intercepted by rtmpsuck. But because that's running as charlie, its rtmp traffic won't be diverted and it can access the stream and save it - As root, move the saved file from charlie's home to your regular user's directory and chown it accordingly. - Delete the iptables rule again so that the streams play normally as before (as root): iptables -t nat -D OUTPUT -p tcp --dport 1935 -m owner ! --uid-owner charlie -j REDIRECT (just the same but with -D instead of -A) This seemed to work, at least partially, and I got an .mp4 file as a result. The only problems that still remain are: - This mp4 file (which "file" thinks is actually an flv) can't be played in totem, only by mplayer - For long streams, the connection dies after a random amount of time but no matter how many times I try I still can't get the whole thing down in one file - If I skip forward in the stream to try to get the later bits, then mplayer also struggles with playing the file, I guess it's slightly corrupted Obviously the major problem is the stream dropping. I've no idea whether this is a client problem or a server problem. And I still don't know what the rtmpdump command would be to grab the stream directly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts