[FFmpeg-user] Unable to initialize H.264 codec with SPS/PPS from IP video camera...

Michael Mulhaupt mmulhaupt at gmail.com
Fri Mar 16 21:39:44 CET 2012


Hi All, I'm trying to view the video from a locally connected IP
camera (a cheap Starcam H.264 camera from China), and I am not able to
successfully initialize the H.264 video codec with the SPS/PPS
parameters from the SDP.  I tried removing the extradata from the
codec initialization, and just passing through on the full frames
(sending [7][8][5] H.264 NALUs) with the same behavior when decoding
the frame.

I would have guessed the camera is at fault, BUT VLC player is able to
display my camera, and it should be using the same codec.  So I'm not
sure if VLC does some extra massaging of the SPS/PPS or what.  Or am I
missing something obvious - like extracting some info from the SPS/PPS
myself and passing it explicitly to initialize the codec.  Including
initial ffprobe errors, SDP, and source code initialization snippet.

Running ffprobe shows the same problems I'm seeing with my code:
>>ffprobe.exe rtsp://192.168.0.20/H264
ffprobe version 0.9.1.git-88c76c7 Copyright (c) 2007-2012 the FFmpeg developers
  built on Mar 14 2012 19:14:58 with gcc 3.4.5 (mingw-vista special r3)
  configuration: --extra-cflags='-mno-cygwin -mms-bitfields'
--extra-ldflags='-Wl,-add-stdcall-alias' --enable-memalign-hack
--target-os=mingw32
  libavutil      51. 42.100 / 51. 42.100
  libavcodec     54. 10.100 / 54. 10.100
  libavformat    54.  2.100 / 54.  2.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 64.101 /  2. 64.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  7.100 /  0.  7.100
[h264 @ 0x2b65b40] Overread VUI by 6 bits
[h264 @ 0x2b65b40] cpb_count 33 invalid
[h264 @ 0x2b65b40] sps_id out of range
[h264 @ 0x2b65b40] Overread VUI by 6 bits
[h264 @ 0x2b65b40] cpb_count 33 invalid
[h264 @ 0x2b65b40] sps_id out of range
[h264 @ 0x2b65b40] non-existing PPS referenced
[h264 @ 0x2b65b40] non-existing PPS 0 referenced
[h264 @ 0x2b65b40] decode_slice_header error
[h264 @ 0x2b65b40] no frame!
[h264 @ 0x2b65b40] non-existing PPS referenced
...

My SDP is
v=0
o=- 12930000 1 IN IP4 192.168.0.20
s=Session streamed by "Object RTSPServer"
i=H264
t=0 0
a=tool:LIVE555 Streaming Media v2011.07.08
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:Session streamed by "Object RTSPServer"
a=x-qt-text-inf:H264
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:500
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=42001E;sprop-parameter-sets=J0IAHqpAUB6TcCAgJAAAAwAEAAADAGeAC5zgCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,KM48gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
a=control:track1

        char* sprops="J0IAHqpAUB6TcCAgJAAAAwAEAAADAGeAC5zgCAAAAAAAAAAAAAAA"
           "AAAAAAAAAAAAAAAAAAAAAAAAAAAA,KM48gAAAAAAAAAAAAAAAA"
           "AAAAAAAAAAAAAAAAA==";
	codec = avcodec_find_decoder(CODEC_ID_H264);
	codecCtx = avcodec_alloc_context();
	codecCtx->pix_fmt            = PIX_FMT_YUV420P  ;
	codecCtx->skip_frame         = AVDISCARD_DEFAULT;
	codecCtx->error_concealment   = 3;
	codecCtx->skip_loop_filter      = AVDISCARD_DEFAULT;
	codecCtx->workaround_bugs      = 1;
	codecCtx->codec_type         = AVMEDIA_TYPE_VIDEO;
	codecCtx->codec_id            = CODEC_ID_H264;
	codecCtx->pix_fmt = PIX_FMT_YUV420P;
	codecCtx->sample_fmt = AV_SAMPLE_FMT_NONE;
	codecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
	codecCtx->skip_loop_filter = AVDISCARD_DEFAULT;
	codecCtx->skip_idct = AVDISCARD_DEFAULT;
	codecCtx->skip_frame = AVDISCARD_DEFAULT;
	codecCtx->color_primaries = AVCOL_PRI_UNSPECIFIED;
	codecCtx->color_trc = AVCOL_TRC_UNSPECIFIED;
	codecCtx->colorspace = AVCOL_SPC_UNSPECIFIED;
	codecCtx->color_range = AVCOL_RANGE_UNSPECIFIED;
	codecCtx->chroma_sample_location = AVCHROMA_LOC_LEFT;
	codecCtx->extradata = parseH264ConfigStr(sprops, &codecCtx->extradata_size);
        avcodec_open(codecCtx, codec)  // spits out these errors

parseH264ConfigStr() from vlc source code - modules/demux/live555.cpp


More information about the ffmpeg-user mailing list