Encoding problem - what to save to single AVI frame?
Hello, I'm trying to encode a video and save it to AVI. The problem is that the resulting AVI is not possible to play in any player. For example, the SMPlayer (based on well known MPlayer) displays this error (coming from ffmpeg):
ID_VIDEO_CODEC=ffh264 Audio: no sound Starting playback... [h264 @ 012b8fc0]non-existing PPS 0 referenced [h264 @ 012b8fc0]decode_slice_header error [h264 @ 012b8fc0]no frame! Error while decoding frame! [h264 @ 012b8fc0]non-existing PPS 0 referenced [h264 @ 012b8fc0]decode_slice_header error [h264 @ 012b8fc0]no frame! Error while decoding frame!
While encoding the video I'm following the codec/console/enc/src/welsenc.cpp. This encoder saves each buffer from SLayerBSInfo::pBsBuf to "raw h264" file. I'm not sure what should I save to AVI as a single frame. All the layer's buffers connected in one "super buffer"? I have found this code: http://svn.pjsip.org/repos/pjproject/trunk/pjmedia/src/pjmedia-codec/openh264.cpp
and they are saving only the layer with the biggest payload (they are not saving to AVI). I tried it in my encoder but the AVI is still not playable.
I'm not able to find any single example or description how to use the OpenH264 (except the codec/console/enc/src/welsenc.cpp).
Thanks anyone for help!
Hi, LairMan. It is true that all the layer's buffers connected in one "super buffer". Can you tell me what is the value iSpatialLayerNum in your configure? If iSpatialLayerNum is 1, the "super buffer" contains one picture in H.264/AVC format. But if iSpatialLayerNum is larger than 1, the layer with the biggest payload may be in H.264/SVC format. I suggest you do following test: set iSpatialLayerNum = 1, encode several frames and save them into .264 file, use the OPEN264 decoder to decode the saved 264 file to see if there is any error.
Note that if iSpatialLayerNum is 1, the "super buffer" contains one picture in H.264/AVC format, and the SPS/PPS NAL units are combined with the first picture in the buffer.
Hello Dongzha, thank you for your response. In the meantime I made it work. Originally I configured the ISVCEncoder by the SEncParamExt structure using ISVCEncoder::InitializeExt() method. The structure was initialized using ISVCEncoder::GetDefaultParams() and some members such as width/height updated manually but it didn't work. Then I tried to initialize the encoder by SEncParamBase which is much more easier to understand and it worked then. I don't know what the problem exactly was, but I'm quite sure that the iSpatialLayerNum was 1 (set by the GetDefaultParams() method). Never mind, now I'm getting what I expected so I'm happy ;).