[Libav-user] H264+flv bad video stream
Dragos Iordache
dragoshiordache at gmail.com
Sat Jun 22 15:46:07 CEST 2013
On Fri, Jun 21, 2013 at 10:07 PM, Andy Shaules <bowljoman at gmail.com> wrote:
> On 6/20/2013 4:51 PM, Alex Cohn wrote:
>
> On 20 Jun 2013 11:13, "Dragos Iordache" <dragoshiordache at gmail.com> wrote:
> >
> > Hi again,
> >
> > So I tested some more and the stream works ok with .\ffmpeg.exe -i
> .\test.h264 -c:v copy -f flv rtmp://live.justin.tv/app/live_****
> > But the stream does not work with my implementation using libffmpeg.
> >
> > I tried different methods for sending the stream with libffmpeg but none
> worked ok. What I do now:
> >
> > -create an oformat of flv
> > -create a context for flv and filename=rtmp:/...
> > -initialize a stream of h264 codec
> > -write header
> > -encode using stagefright
> > -create a packet
> > -write the packet
> >
> > The test.h264 in the ffmpeg line is created using this method and
> filename is set to "test.h264" and not a rtmp server, so I think this is ok.
> >
> > The captured frame data differs slightly between the command I run with
> ffmpeg and my code using libffmpeg. One of the diferences if that the NAL
> header "00 00 00 01" is not like this in the ffmpeg method.
>
> Absolutely. FLV uses the AVCC format to store h264 NALUs. See for example
> an excellent explanation at
> http://livertmpjavapublisher.blogspot.co.il/2011/06/h264-avcvideopacket.html
> .
>
> > What do you think is not right?
>
> Stagefright encoder produces packets in annex-b format. It could be enough
> to change their headers to AVCC format to make your rtmp happy.
>
> > Thanks for your help.
> >
> > Dragos
>
> Regards,
> Alex
>
>
> _______________________________________________
> Libav-user mailing listLibav-user at ffmpeg.orghttp://ffmpeg.org/mailman/listinfo/libav-user
>
>
>
> Yes,
>
> Take the annex-b stream nals, typically sps,pps,idr,slice,slice......
>
> extract the sps and pps from the stream and create the flv avc config
> packet. For the rest of the frames, the idr and slices. Swap the marker
> bytes for size values, pre-pend pts offset and then wrap with the AMF flv
> audio block header.
>
> I often refer to this java class which transcodes annex-b into AMF flash
> live streams for the red5 server.
>
>
> http://code.google.com/p/comserver/source/browse/trunk/plugins/shoutcast/src/org/red5/server/plugin/shoutcast/marshal/transpose/VideoFramer.java#421
>
> Although the raw frame parsing code is old, the beef of the critical
> packets and format of the AMF payload is still valid.
>
> If writing a file, those AMF packets will need to be wrapped with the FLV
> context tag header and trailing size marker, but for rtmp they are ready to
> fly..
>
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
Thanks.
Alex and Carl you helped me a lot and now my app streams like a charm.
Great help guys.
Now that everything starts to take a shape I will share my project with all
of you.
It is called Colosseo. And you can check it over here colosseoapp.com
Thanks again,
Dragos
--
dragoshiordache at gmail.com
0726736376
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130622/8853cedd/attachment.html>
More information about the Libav-user
mailing list