<p>On Apr 25, 2012 8:27 PM, "Григорий" <<a href="mailto:grishka93@gmail.com">grishka93@gmail.com</a>> wrote:<br>
><br>
> Alex Cohn <<a href="mailto:alexcohn@netvision.net.il">alexcohn@netvision.net.il</a>> писал(а) в своём письме Wed, 25 Apr 2012 17:54:44 +0400:<br>
><br>
>> On Wed, Apr 25, 2012 at 16:45, Григорий <<a href="mailto:grishka93@gmail.com">grishka93@gmail.com</a>> wrote:<br>
>>><br>
>>> Andrey Utkin <<a href="mailto:andrey.krieger.utkin@gmail.com">andrey.krieger.utkin@gmail.com</a>> писал(а) в своём письме Wed,<br>
>>> 25 Apr 2012 17:29:09 +0400:<br>
>>><br>
>>><br>
>>>> 25 апреля 2012 г. 15:52 пользователь Григорий <<a href="mailto:grishka93@gmail.com">grishka93@gmail.com</a>><br>
>>>> написал:<br>
>>>>><br>
>>>>><br>
>>>>> Hi all.<br>
>>>>> I've built libffmpeg for Android and am trying to decode H.264 stream<br>
>>>>> using<br>
>>>>> it. I'm receiving that stream via RTMP connection and passing all video<br>
>>>>> packets (excluding first byte that contains flags related to RTMP) to the<br>
>>>>> avcodec_decode_video2 function. With H.263 it works perfectly, but when I<br>
>>>>> try to use the same code (only with codec ID changed) for H.264, every<br>
>>>>> call<br>
>>>>> to avcodec_decode_video2 returns -1 and nothing gets decoded.<br>
>>>>> Here is the output:<br>
>>>><br>
>>>><br>
>>>><br>
>>>> Do you know libavformat can read and demux RTMP stream by itself?<br>
>>>> Seems like problem in your demuxer, because decoding the frames it<br>
>>>> produces fail.<br>
>>>><br>
>>><br>
>>> Yes I know, but I need more than simply receiving and playing, this will be<br>
>>> a kind of VoIP service. My demuxer seems to work fine - I am able to<br>
>>> successfully decode audio using Speex and video using libavcodec when it is<br>
>>> encoded into H.263. Only problem is with H.264.<br>
>><br>
>><br>
>> Packing of h264 into a stream is not trivial. You may find some<br>
>> curious information at<br>
>> <a href="http://livertmpjavapublisher.blogspot.com/2011/06/h264-avcvideopacket.html">http://livertmpjavapublisher.blogspot.com/2011/06/h264-avcvideopacket.html</a><br>
>><br>
>> Alex<br>
>> _______________________________________________<br>
>> Libav-user mailing list<br>
>> <a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
>> <a href="http://ffmpeg.org/mailman/listinfo/libav-user">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
><br>
><br>
> Thank you for this link. I've made it to parse the decoder configuration record, extract SPS, PPS and some other things. I've tried to pass PPS and SPS to avcodec_decode_video2 but it still returns -1, prints "no frame!" and does not decode anything else. Prepending 0x00000001 before them or making AVCDCR as described here <a href="http://stackoverflow.com/questions/3493742/problem-to-decode-h264-video-over-rtp-with-ffmpeg-libavcodec">http://stackoverflow.com/questions/3493742/problem-to-decode-h264-video-over-rtp-with-ffmpeg-libavcodec</a> give the same result.</p>
<p>H264 decoder expects SPS and PPS to arrive together with the first (IDR) frame.</p>
<p>Удачи,<br>
Alex</p>