[rtmpdump] Searching for key frames
fs ck
fsckemail at gmail.com
Sat Jan 8 17:11:35 CET 2011
Hi,
I've had intermittent problems where in some (hard to reproduce) cases
after an rtmp stream failure where the resulting flv file is filled
with megabytes of null chars at the end. This clearly breaks any
attempts at resuming the stream. Sometimes you don't get the null
chars but just have a 'corrupt' file where I guess a full frame hasn't
been written to the file when the stream failed.
I was planning or writing a file clean-up function which scanned the
file to reliably find the last valid key frame and then correct the
file for resuming. Maybe if it was efficient enough I could improve
the rtmpdump GetLastKeyframe() function to do this automatically. The
--skip function really does not seem to work for me in these cases and
I would typically get something like:
ERROR: Last tag size must be greater/equal zero
(prevTagSize=-886083377) and smaller then filesize, corrupt file!
DEBUG: Failed to get last keyframe.
The question I have is: What is a good algorithm for finding key
frames? Is there a signature I should search for? Would a backwards
search be robust enough? Failing that, if I had to do a forward search
(i.e. from the beginning of the file) what algo' should be used?
Any help or tips would be appreciated...
Thanks
More information about the rtmpdump
mailing list