FORUMS: list search recent posts

decode_slice_header error no frame !

COW Forums : FFmpeg

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
vu lee
decode_slice_header error no frame !
on Jun 5, 2011 at 3:44:33 pm

I am trying to decode H264 udp video stream but kept getting these errors. I used the ffmpeg example to decode this video stream( see my code below). m_videoFrame is the video frame extracted from UDP packet.

I am quite new to video codec, any guides would be appreciated.

[h264 @ 0x9316800] non-existing PPS 0 referenced
[h264 @ 0x9316800] decode_slice_header error
[h264 @ 0x9316800] no frame!
Error while decoding frame 0
[h264 @ 0x9316800] non-existing PPS 0 referenced
[h264 @ 0x9316800] decode_slice_header error
[h264 @ 0x9316800] no frame!
Error while decoding frame 0
[h264 @ 0x9316800] non-existing PPS 0 referenced
[h264 @ 0x9316800] decode_slice_header error
[h264 @ 0x9316800] no frame!
Error while decoding frame 0
[h264 @ 0x9316800] non-existing PPS 0 referenced
[h264 @ 0x9316800] decode_slice_header error
[h264 @ 0x9316800] no frame!
Error while decoding frame 0
[h264 @ 0x9316800] non-existing PPS 0 referenced
[h264 @ 0x9316800] decode_slice_header error
[h264 @ 0x9316800] no frame!



void GLWidget::decodeVideoFrame()
{
static int INBUF_SIZE = 4096;
AVCodec *codec;
AVCodecContext *c= NULL;
int frame, got_picture, len;
AVFrame *picture;
uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
AVPacket avpkt;

av_init_packet(&avpkt);

/* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);

printf("Video decodingn");

/* find the H264 video decoder */
codec = avcodec_find_decoder(CODEC_ID_H264);
if (!codec) {
fprintf(stderr, "codec not foundn");
exit(1);
}

c= avcodec_alloc_context();

picture= avcodec_alloc_frame();

if(codec->capabilities&CODEC_CAP_TRUNCATED)
c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */

/* For some codecs, such as msmpeg4 and mpeg4, width and height
MUST be initialized there because this information is not
available in the bitstream. */

/* open it */
if (avcodec_open(c, codec) < 0) {
fprintf(stderr, "could not open codecn");
exit(1);

}

/* the codec gives us the frame size, in samples */


frame = 0;
for(;;) {
avpkt.size = m_videoFrame.size();
if (avpkt.size == 0)
break;

/* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
and this is the only method to use them because you cannot
know the compressed data size before analysing it.

BUT some other codecs (msmpeg4, mpeg4) are inherently frame
based, so you must call them with all the data for one
frame exactly. You must also initialize 'width' and
'height' before initializing them. */

/* NOTE2: some codecs allow the raw parameters (frame size,
sample rate) to be changed at any frame. We handle this, so
you should also take care of it */

/* here, we use a stream based decoder (mpeg1video), so we
feed decoder and see if it could decode a frame */
c->width = 352;
c->height = 240;
c->bit_rate = 200000;
c->time_base.den = 1;
c->time_base.num = 30;
c->codec_id = CODEC_ID_H264;
c->codec_type = AVMEDIA_TYPE_VIDEO;



avpkt.data = (unsigned char*)m_videoFrame.data();
while (avpkt.size > 0) {
len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
if (len < 0) {
fprintf(stderr, "Error while decoding frame %dn", frame);
// exit(1);

}
if (got_picture) {
printf("------------------------------------------------------------saving frame %3dn", frame);
fflush(stdout);


frame++;
}
avpkt.size -= len;
avpkt.data += len;
}
}

/* some codecs, such as MPEG, transmit the I and P frame with a
latency of one frame. You must do the following to have a
chance to get the last frame of the video */
avpkt.data = NULL;
avpkt.size = 0;
len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
if (got_picture) {
printf("--------------------------------------------------------------------saving last frame %3dn", frame);
fflush(stdout);


frame++;
}


avcodec_close(c);
av_free(c);
av_free(picture);
printf("n");
}


Return to posts index

vu lee
Re: decode_slice_header error no frame !
on Jun 7, 2011 at 4:02:54 pm

Any suggestion?


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]