Hello,<br>I saw this case already discussed several times before but still quite unobvious one, so I decided to raise it once more.<br>I've got a network client application which receives a stream of raw H.264 video data encoded as annex b. The stream is depayed properly and video data packets go to avcodec_decode_video2() ffmpeg/libav function to be decoded like this:<br>
<br>AVPacket pkt;<br>pkt.dts = unit->pts();<br>pkt.pts = unit->dts();<br>pkt.data = unit->data();<br>pkt.size = unit->size();<br><br>if (unit->isRap()) {<br> pkt.flags |= AV_PKT_FLAG_KEY;<br>}<br><br>int isFrameFinished(0);<br>
if (0 >= avcodec_decode_video2(codecCtx_, frame_, &isFrameFinished, &pkt)) {<br> printf("oops\n");<br> return;<br>}<br><br>if (isFrameFinished) {<br> *_frame = frame_;<br> *width = codecCtx_->width;<br>
*height = codecCtx_->height;<br> *pixFmt = codecCtx_->pix_fmt;<br>}<br><br>The code above decodes the stream successfully. Now I need to switch the processing to GStreamer but got stuck with a problem. I use appsrc to inject data to the pipeline, the pipeline is like this:<br>
<br>appsrc -> h264parse -> ffdec_h264 -> ffmpegcolorspace -> ximagesink<br><br>I've set appsrc the following caps: video/x-h264,width=960,height=580,framerate=25/1 and push buffers with the same caps:<br><br>
GstBuffer* buffer = gst_buffer_new();<br>gst_buffer_set_data(buffer, const_cast<unsigned char*>(unit->data()), unit->size());<br><br>if (unit->isRap())<br> GST_BUFFER_FLAGS(buffer) |= GST_BUFFER_FLAG_DELTA_UNIT;<br>
<br>GstCaps* video_caps = gst_caps_new_simple ("video/x-h264",<br> "width", G_TYPE_INT, 960,<br> "height", G_TYPE_INT, 540,<br>
"framerate", GST_TYPE_FRACTION, 25, 1,<br> NULL);<br><br>gst_buffer_set_caps(buffer, video_caps);<br> GstFlowReturn ret = gst_app_src_push_buffer(GST_APP_SRC(videosource), buffer);<br>
<br>The problem is that ffdec_h264 element throws some error messages and provides no output, the pipeline is dry. Here's some messages of interest from the LOG level output. ERROR level:<br><br>0:00:17.436071901 15944 0xfd8630 ERROR ffmpeg :0:: non-existing PPS referenced<br>
0:00:17.436199850 15944 0xfd8630 ERROR ffmpeg :0:: slice type too large (0) at 0 0<br>0:00:17.436217450 15944 0xfd8630 ERROR ffmpeg :0:: decode_slice_header error<br>0:00:17.436239240 15944 0xfd8630 ERROR ffmpeg :0:: slice type too large (0) at 0 0<br>
0:00:17.436255444 15944 0xfd8630 ERROR ffmpeg :0:: decode_slice_header error<br>0:00:17.436335063 15944 0xfd8630 ERROR ffmpeg :0:: no frame!<br><br>and LOG-level (these messages seem to repeat for each buffer):<br>
<br>99:99:99.999999999, dur 99:99:99.999999999, size 109, offset 18446744073709551615, offset_end 18446744073709551615, caps: video/x-h264, width=(int)960, height=(int)540, framerate=(fraction)25/1, parsed=(boolean)true, stream-format=(string)byte-stream, alignment=(string)au<br>
0:00:42.490123738 15944 0xfd8630 LOG ffmpeg gstffmpegdec.c:2622:gst_ffmpegdec_chain:<decoder> Received new data of size 109, offset:18446744073709551615, ts:99:99:99.999999999, dur:99:99:99.999999999, info 98<br>
0:00:42.490146087 15944 0xfd8630 LOG ffmpeg gstffmpegdec.c:2660:gst_ffmpegdec_chain:<decoder> Calling av_parser_parse2 with offset -1, ts:99:99:99.999999999 size 109<br>0:00:42.490170113 15944 0xfd8630 LOG ffmpeg gstffmpegdec.c:2669:gst_ffmpegdec_chain:<decoder> parser returned res 109 and size 0, id 15<br>
0:00:42.490186316 15944 0xfd8630 LOG ffmpeg gstffmpegdec.c:2683:gst_ffmpegdec_chain:<decoder> consuming 0 bytes. id 15<br>0:00:42.490222354 15944 0xfd8630 LOG GST_SCHEDULING gstpad.c:4715:gst_pad_push:<parse:src> called chainfunction &gst_ffmpegdec_chain with buffer 0x7fd0bc171840, returned ok<br>
0:00:42.528915821 15944 0xfd8630 LOG GST_SCHEDULING gstpad.c:4708:gst_pad_push:<parse:src> calling chainfunction &gst_ffmpegdec_chain with buffer 0x7fd0bc35ec80, data 0x10f2220, malloc (nil), ts 99:99:99.999999999, dur 99:99:99.999999999, size 109, offset 18446744073709551615, offset_end 18446744073709551615, caps: video/x-h264, width=(int)960, height=(int)540, framerate=(fraction)25/1, parsed=(boolean)true, stream-format=(string)byte-stream, alignment=(string)au<br>
<br>I've also tried to change a sink to filesink, but the output file is empty, too.<br><br>Perhaps, someone could help me with the problem, maybe I should set more precise input caps or more buffer metadata. It is quite common use case when decoding raw H.264 stream, so any advice is particularly useful. My GStreamer version is 0.10.36.<br>
<br>Thanks in advance!<br><br>Alexey Chernov<br>