<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 6/20/2013 4:51 PM, Alex Cohn wrote:<br>
</div>
<blockquote
cite="mid:CADiKgojEaV=wiP7DP+H5_-eng6qGYS91xet4tPHRVG-DZ=2L+Q@mail.gmail.com"
type="cite">
<p dir="ltr">On 20 Jun 2013 11:13, "Dragos Iordache" <<a
moz-do-not-send="true" href="mailto:dragoshiordache@gmail.com">dragoshiordache@gmail.com</a>>
wrote:<br>
><br>
> Hi again,<br>
><br>
> So I tested some more and the stream works ok
with .\ffmpeg.exe -i .\test.h264 -c:v copy -f flv rtmp://<a
moz-do-not-send="true"
href="http://live.justin.tv/app/live_****">live.justin.tv/app/live_****</a><br>
> But the stream does not work with my implementation using
libffmpeg.<br>
><br>
> I tried different methods for sending the stream with
libffmpeg but none worked ok. What I do now:<br>
><br>
> -create an oformat of flv<br>
> -create a context for flv and filename=rtmp:/...<br>
> -initialize a stream of h264 codec<br>
> -write header<br>
> -encode using stagefright<br>
> -create a packet<br>
> -write the packet<br>
><br>
> 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.<br>
><br>
> 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.</p>
<p dir="ltr">Absolutely. FLV uses the AVCC format to store h264
NALUs. See for example an excellent explanation at <a
moz-do-not-send="true"
href="http://livertmpjavapublisher.blogspot.co.il/2011/06/h264-avcvideopacket.html">http://livertmpjavapublisher.blogspot.co.il/2011/06/h264-avcvideopacket.html</a>.</p>
<p dir="ltr">> What do you think is not right?</p>
<p dir="ltr">Stagefright encoder produces packets in annex-b
format. It could be enough to change their headers to AVCC
format to make your rtmp happy.</p>
<p dir="ltr">> Thanks for your help. <br>
><br>
> Dragos</p>
<p dir="ltr">Regards,<br>
Alex</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Libav-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a>
<a class="moz-txt-link-freetext" href="http://ffmpeg.org/mailman/listinfo/libav-user">http://ffmpeg.org/mailman/listinfo/libav-user</a>
</pre>
</blockquote>
<br>
<br>
Yes,<br>
<br>
Take the annex-b stream nals, typically
sps,pps,idr,slice,slice......<br>
<br>
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. <br>
<br>
I often refer to this java class which transcodes annex-b into AMF
flash live streams for the red5 server. <br>
<br>
<a class="moz-txt-link-freetext" href="http://code.google.com/p/comserver/source/browse/trunk/plugins/shoutcast/src/org/red5/server/plugin/shoutcast/marshal/transpose/VideoFramer.java#421">http://code.google.com/p/comserver/source/browse/trunk/plugins/shoutcast/src/org/red5/server/plugin/shoutcast/marshal/transpose/VideoFramer.java#421</a><br>
<br>
Although the raw frame parsing code is old, the beef of the critical
packets and format of the AMF payload is still valid.<br>
<br>
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.. <br>
<br>
<br>
<br>
</body>
</html>