Decoding problems
Hello, I'm decoding a H.264 video (encoded by OpenH264) and I have a these problems:
- The first frame (it is always the key-frame i.e. videoFrameTypeIDR) is never decoded. The ISVCDecoder::DecodeFrame2() returns dsErrorFree but the SBufferInfo::iBufferStatus==0 for each slice of the first frame. Is it OK? I don't know the H.264 priciples (I only have a brief idea of how it works) but I'd expected that there should be no problem with it.
- While ENCODING I have to force the I-frame for EACH frame (ISVCEncoder::ForceIntraFrame(true)) otherwise I'm not able to DECODE all the frames. On some frames the ISVCDecoder::DecodeFrame2() returns dsRefLost and the decoder display this log (currently processing the 5th frame):
[OpenH264] Info:CWelsDecoder::init_decoder(), openh264 codec version = [OpenH264] Info:eVideoType: 1 [OpenH264] Info:DecodeFrameConstruction()::::output first frame of new sequence, 1280 x 1024, crop_left:0, crop_right:0, crop_top:0, crop_bottom:0, ignored error packet:0. [OpenH264] Warning:reference picture introduced by this frame is lost during transmission! uiTId: 0 [OpenH264] Info:returned error from decoding:[0x427] [OpenH264] Info:decode failed, failure type:2
I'm decoding sequentially frame by frame (just playing the video without seeking). What is the problem?
I'd be glad if someone helps me. Thanks in advance!
Hi, I'm not sure why "The first frame is never decoded" in your case. If "DecodeFrame2() returns dsErrorFree but the SBufferInfo::iBufferStatus==0", it means bitstream is OK, but whole frame is not ready for output. It needs following data to decide whether current frame is complete. Thus a delay exists here.
So to prevent possible delay, I guess you may need call DecodeFrame2(NULL, 0, pData, &sDstInfo) right after each DecodeFrame2(pSrc, iSliceSize, pData, &sDstInfo) to get possible YUV output data.
With this, I think it is unnecessary to call ForceIntraFrame(). It is usually used when packet loss happens in UDP network to recover the video enc/dec channel.
Hello huili2, thanks a lot for your response. The DecodeFrame2(NULL, 0, pData, &sDstInfo) call helped, thanks!
But there is still the problem with the key-frame. I'm getting the dsRefLost from DecodeFrame2() quite often while decoding a video which was not encoded with each frame as a key-frame. So that when I call ForceIntraFrame() before EncodeFrame() for EACH frame then the decoding is OK. Otherwise the DecodeFrame2() returns dsRefLost often (for most of the decoded frames). Do you have some hint what should I check?
Curious about why dsRefLost is returned for most of the frames, if using openh264 encoder for single-layer coding. Is there any packet loss during transmission?
But if dsRefLost happens, ForceIntraFrame() is a feasible way.
Solved. The packets really lost during transmission. The player I'm testing on skips frames for higher recorded framerates (because of the speed optimalization).