[rtmpdump] Crude fix rtmpdump repeats, "jumps" timestamps backwards

Howard Chu hyc at highlandsun.com
Mon Apr 16 15:58:44 CEST 2012


Gunnar wrote:
> For some rtmp-servers I get downloaded files which
> - are much larger than expected
> - when played in mplayer, the video "jumps backwards" every now and then
>
> 2 solutions,
> - fix the jump-backwards file
> - butcher rtmpdump
>
> Added some code to YAMD to check that every timestamp is larger than the
> earlier in the packet-header.
> Yes, that was the problem.
> Added some more code
> - detect timestampnew<  teimestampold, and set timestamp search =
> timestampold
> - in in this search-mode I "delete" the FLV-tags until the stream
> continues from where it "jumped backwards"
>
> THis worked, the fixed file almost "normal". plays almost perfectly, but
> seems I missed some frames sometimes, some "coder artifacts"
>
> OK, wireshark and finding "how and why". it was easy. I could see slight
> "pauses" in the stream of packets.
> Normally the client, rtmpdump just acks the streampackets with a 54 bit
> packet.
> But, sometimes a 84 bit "pause" packet!
>
> Looking more closely, the
> - rtmp-server send an onstatus and NetStream.Pause.Notify packet (after
> the slight "pause" in packets)
> - rtmpdump replies with "rtmp-pause-command" (but at what timestamp??)
> - server replies with an NetStream.Unpause.Notify, stream continues
> (from "older timestamp??)
>
> OK,OK, quick butcher-test, made a rtmpdump2.3 version with
> RTMP_SendPause disable
>
> int RTMP_SendPause(RTMP *r, int DoPause, int iTime){
> RTMP_LogPrintf("SENDING PAUSE\n") ;
>    return 0;
> }
>
> WORKED!!
>
> butbut, seems to happen only once, twice during beginning of stream, not
> what I excpected
> (without further debugging)
>
> Additionally the stream is now streamed "much slower", clear
> "do-nothings" every now and then, but correctly.

Your server has paused playback (for whatever reason) and rtmpdump timed out 
waiting for data. It sends the Pause/Unpause command to poke the server and 
make it resume sending data. So yes, if you disable the SendPause function, 
your overall download will be much slower.

Obviously the butchery you've done is wrong. Also, the SendPause command uses 
the timestamp of the last frame that it received. It is possible that more 
recent data would have arrived, but Flash servers are only able to seek to Key 
frames so sometimes it will resume from earlier than the last sent packet. 
There is already code in librtmp to skip any packets with older timestamps 
after a resume (though perhaps this code wasn't present in 2.3, I haven't 
bothered to check).

Use 2.4. Don't butcher the code, a lot more thought has gone into it than 
you're able to put into it.


More information about the rtmpdump mailing list