Reputation: 85
I am receiving RTSP stream with live555 library and decode them with ffmpeg. At first, i couldnt decode data's that come from live555. After a little search i learned that I needed to include the sequence (SPS) and picture parameter sets (PPS) for my frame data before sending frame to the FFmpeg.
header : 00 00 00 01 67 4d 00 14 95 b8 58 25 90 00 00 00 01 68 ee 3c 80 00 00 00 01
FFmpeg can't decode H264 stream/frame data
Now i can take frame but a tiny problem comes out. [![enter image description here][1]][1]
3 packets still have problem. FFmpeg cant decode them i am suggesting they are special command. Because they are so small 9,4 and 5 byte come.
Here they are
[h264 @ 0x137c00] no frame! 00 00 00 01 67 4d 00 14 95 b8 58 25 90 00 00 00 01 68 ee 3c 80 00 00 00 01 67 4d 00 14 95 b8 58 25 90 [h264 @ 0x137c00] no frame! 00 00 00 01 67 4d 00 14 95 b8 58 25 90 00 00 00 01 68 ee 3c 80 00 00 00 01 68 ee 3c 80 [h264 @ 0x137c00] no frame! 00 00 00 01 67 4d 00 14 95 b8 58 25 90 00 00 00 01 68 ee 3c 80 00 00 00 01 06 e5 01 ec 80 [h264 @ 0x137c00] no frame!
any suggestion ?
Upvotes: 0
Views: 1141
Reputation: 85
Okay, i might have solved problem. I added Parsing operation before decoding frames.
avparser= av_parser_init(AV_CODEC_ID_H264);
len= av_parser_parse2(avparser,mCodecContext,&data,&lenght_parse,encodedFrame,encodedFrameSize,0,0,0);
while(encodedFrameSize)
{
len= av_parser_parse2(avparser,mCodecContext,&data,&lenght_parse,encodedFrame,encodedFrameSize,0,0,0);
encodedFrame += len;
encodedFrameSize -=len;
if(lenght_parse)
{
av_init_packet(&pkt);
pkt.data=data;
pkt.size=lenght_parse;
length = avcodec_decode_video2(mCodecContext,decodedFrame,&gotFrame,&pkt);
}
}
I tested app yesterday and a new problem came out. Application stops streaming after 4-5 hours. I think problem is based on decoding operation. Now i am trying to solve that.
Day by day, I'm approaching to solution !!
Upvotes: 0
Reputation: 11174
The packet starting with 00 00 00 01 67 is your SPS, and 00 00 00 01 68 is your PPS. You probably want to use the h264 AVParser which will combine PPS/SPS/frame into single packets, which is what the ffh264 decoder expects. A typical RTSP stream (or any network stream) will repeat the PPS/SPS every few seconds or so.
Upvotes: 1