windowsh.264openh264

OpenH264 decoding with network latency causing failure


I have OpenH264 working on my local network.

The code is something like.

send(server, frame)
recv(client, frame)
DecodeFrameNoDelay(frame, frame_buffer)

if(frame_buffer.iBufferStatus == 1)
//process frame

This works fine with a low latency connection on my local network. but fails on a high latency connection like a slow VPS.

I can receive the first frame but then the stream fails and DecodeFrameNoDelay does not return any frames.

If i set the bitrate and FPS very low i can get it to work. this leads me to believe its has to do with the timing?

Should I be putting the decoded frames in to a buffer and then have the decoder decode the frames from the buffer? as to maintain the required FPS?

I appreciate any feedback thanks!


Solution

  • h264_encoder->SetOption(ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod);
    // or
    h264_encoder->ForceIntraFrame(TRUE);
    

    I am assuming that when streaming over the internet there needs to be a IDR frame sent over so often to keep the decoding in sync.

    I feel this pretty hack but this gets the job done.