"scyber" wrote:
I have a transcoding server that is converting video feeds into HLS files. Playback is working, however at times the playback will rebuffer and "skip" back a number of seconds. It appears that if the transcoding server is not fast enough to transcode in real-time, the Roku will reach the end of m3u8 file and then skip back to the beginning of its buffer. Depending on the speed of the server, one rebuffer is sometimes enough to play through till the end of the video.
If my diagnosis of the behavior is correct, is there an event I can catch to simply pause the video when it runs out of video? Pausing would at least been a preferred behavior to "skipping" back.
I've had the same issue as you and what we've decided to do in Gabby is implement a "communication framework" in conjunction with streaming the media. That makes the application, etc. more "chatty", but helps handle this issue fairly well. Doing this gives you a lot of power over how you respond to and detect buffer underuns. If you can't stop the buffer underrun, you should at least handle it gracefully. So one thing we do is ask for "buffer" status before playback begins. Because you should know how many segments have been transcoded, it makes this easy to do. So first, you keep asking the transcoding server how many segments are ready until you fill a buffer -- then you begin playback. The second thing you can do is keep track of how long it took to fill the buffer (from the roku side). We're still playing with this, but if it takes you more than 60-70 seconds to fill 60 seconds of video -- you KNOW you can't keep up with playback. Lastly, you can send the same request everytime the roku hits its HLS target duration (using streamposition). Based on that status message, you should be able to detect upcoming buffer underruns. For instance -- if your buffer is 6 segments...and the status message drops to 4 segments available (or maybe even 3)...then you probably want to pause or warn the user with some kind of visual overlay. We're thinking about using a flashing yellow warning to let them know that "hey...your computer can't keep up". I wouldn't freak out if the value dropped to 5 because sometimes key frames don't arrive in a tight enough duration -- so anything less than 75% fill rate is my cutoff. To clarify, when I say "buffer" -- I mean minimum number of segments available for immediate playback.
Hopefully that helps,
RT