Looks like the bbc breaks that last few tags when a download times out. This patch checks the previous tag payloadsize against the current tags prevtaglength. On 4 November 2014 at 16:04, Peter Pickford <rtmpdump@netremedies.ca> wrote:
diff --git a/rtmpdump.c b/rtmpdump.c index 13741a7..5a69395 100644 --- a/rtmpdump.c +++ b/rtmpdump.c @@ -303,8 +303,29 @@ GetLastKeyframe(FILE * file, // output file [in] // find the last seekable frame off_t tsize = 0; uint32_t prevTagSize = 0; + uint32_t headerSize = 0; + uint32_t payloadSize = 0; + off_t offset = 0; + off_t lastGoodTag = 0;
// go through the file and find the last video keyframe + fseek(file, 5, SEEK_SET); + if (fread(buffer, 1, 4, file) != 4) { + RTMP_Log(RTMP_LOGERROR, "Couldn't read headerSize from file!"); + return RD_FAILED; + } + headerSize = AMF_DecodeInt32(buffer); + offset = headerSize; + while (offset < size) { + fseeko(file, offset + 5, SEEK_SET); + if (fread(buffer, 1, 4, file) != 4) { + break; + } + payloadSize = AMF_DecodeInt24(buffer); + lastGoodTag = offset; + offset += payloadSize + 15; // the back pointer the tag header and the payload + } + tsize = size - lastGoodTag - 4; // set tsize to point to offset from end of file of the header of last good tag do { int xread;