On Fri, Sep 10, 2010 at 5:38 PM, Alex Grosu <[email protected]> wrote:

> Hello
>
> The information you passed will help me later, thanks. In this moment, my
> application communicates with an embedded product which sends only one frame
> per NAL in this moment. Later, it will send inceed multiple slices, and we
> said that we will see what we are going to do then. Is there any possibility
> to find which slice is the start of a frame sequence and which slice is the
> end of it? In you case for example, is there a possibility to find the first
> 5 from I frame  and the last 5 from I frame (or, the first 1 and last 1 from
> B frame / P frame) ?
> Regards,
> Alex
>
>
> Nhat Huy wrote:
>
>> On Thu, Sep 9, 2010 at 9:00 PM, Alex Grosu <[email protected]> wrote:
>>
>>
>>
>>> 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
>>>
>>>
>>>
>>
>>
>> Hi,
>>
>> If you coupled H.264 slice as  [7 8 5] [1] [1] [1] [1] [7 8 5] [1] [1] [1]
>> and so on, it can work well only in single slice/ frame case.
>> If you use multiple slice , it goes wrong.
>>
>> For ex. my sequence has 5 frame I B B B P, and number of slices is 4 per
>> frame. The NAL_unit_type of bit stream is:
>> [7 8 5 5 5 5][1 1 1 1][1 1 1 1][1 1 1 1][1 1 1 1]
>> I use [ and ] to mark the frame boundary.
>>
>> When you feed avcodec_decode_video2, the input buffer must contains whole
>> frame data.
>> Thus, the problem that you have to calculate exactly the input buffer
>> length, and feed it enough data plus some padding if necessary before pass
>> it to avcodec_decode_video2.
>>
>> 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
>

Hi,

There is a syntax element named first_mb_in_slice in slice header. It
describes the position of the first macroblock in that slice. It equals 0 to
indicate a new frame.

I am not sure that this information can help or not.

I just know that when I call av_read_frame, I can receive a buffer contained
whole frame data. But I do not know how can it do this ?

Huy.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to