Hello Huy
Thanks a lot for the answer. I found this solution 2 days ago, but first
I thought it was a dirty one. I wanted to check this before posting here
again, but you took it ahead. Your pointing shows me that in fact this
is not a dirty solution, so thanks a lot for support.
So, what I had to do (as Huy suggested), was to couple 7 8 and 5 NAL
types into only one buffer and to present it to libavcodec (in
avcodec_decode_video2 function).
Thus, using the [ and ] characters to delimit buffer boundaries, I was
coupling following before send them to libavcodec:
[7 8 5] [1] [1] [1] [1] [7 8 5] [1] [1] [1] and so on.
I don't receive errors anymore. Everything works now
Thank you
Nhat Huy wrote:
On Thu, Sep 2, 2010 at 3:58 PM, Alex Grosu <[email protected]> wrote:
Hello
I am currently decoding h264 streams (with libavcodec) and I am stuck with
the logic for SPS (sequence parameter set) and PPS (picture parameter set).
The board from which I am receiving the packages is sending a NAL unit in
each packet. The sequence for NAL types is:
7(SPS) 8(PPS) 5 1 1 1 1 7 8 5 1 1 1...
I am putting in front of each NAL the start sequence 0x000001 and sending
this packet to avcodec_decode_video2. When 7 and 8 types are coming, I am
doing the same logic, but avcodec_decode_video2 is returning -1. After this,
all the received NALs are decoded and the images are displayed. Every time
when SPS and PPS are coming, avcodec_decode_video2 returns -1 (fails). I
searched all over the net , and I still can't understand how to fill up the
extradata and extradata_size from AVCodecContext used. All I found is this
link: http://www.mail-archive.com/[email protected]/msg04939.html.
As I saw from here:
"To decode H.264 stream you need to have SPS and PPS NAL units also .". Ok,
I have them, but frankly I don't know how to use them. At first, I thought
that avcodec_decode_video2 will "automatically" use them. But returning -1,
I don't see how. Also, If I am discarding SPS and PPS from sending them to
libavcodec, nothing is decoded anymore.
Can you please give me a hint?
Thank you a lot !
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
Hi,
I think you should read H.264 bit stream structure and use these tools to
analyze a NAL unit of H.264 bitstream.
http://www.codecian.com/
http://tsviatko.jongov.com/index_prj_h264videoesviewer.htm
When FFmpeg decode a NAL unit, if the nal_unit_type equal 7,8 it will
continue decode to find the IDR nal_unit. In your case, I think that FFmpeg
found SPS, PPS but it can not find IDR thus it returns -1.
Hope it helps.
Huy.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user