The stream I'm using is coded with h264 without mpegts. <div><br></div><div>However, I'm following a sort of "low level" approach, since my goal is to read frames from the file, move their content into a RTP packet and, at the receiver side, rebuild the set of sent packets (regardless if this has an actual sense for the file I consider). </div>
<div>I supposed that a simple copy of the packet's payload could be enough to rebuild the stream at the receiver side, but I guess that I'm missing something important.</div><div><br></div><div>Another weird thing: if I make a raw copy of the following AVStream's parameters (m_copyStream is the original sender-side stream, while outputStream is the one at the receiver side)</div>
<div><div> </div><div><div> outputStream->r_frame_rate = m_copyStream.r_frame_rate;</div><div> outputStream->first_dts = m_copyStream.first_dts;</div><div> outputStream->pts = m_copyStream.pts;</div>
<div> outputStream->time_base = m_copyStream.time_base;</div></div></div><div><div> outputStream->pts_wrap_bits = m_copyStream.pts_wrap_bits;</div><div> outputStream->start_time = AV_NOPTS_VALUE;</div>
<div> outputStream->sample_aspect_ratio = m_copyStream.sample_aspect_ratio;</div><div> outputStream->avg_frame_rate = m_copyStream.avg_frame_rate;</div></div><div><br></div><div>which I assume should replicate the sender AVStream at the receiver, the program stops for an arithmetic exception caused by the pts, whose denominator is 0. However, it's not clear how the original file could play perfectly without these information...</div>
<div><br></div><div>Regards,</div><div>Alessandro</div><div><br></div><div><div class="gmail_quote">Il giorno 23 febbraio 2012 04:24, Kalileo <span dir="ltr"><<a href="mailto:kalileo@universalx.net">kalileo@universalx.net</a>></span> ha scritto:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Feb 23, 2012, at 00:59 , ALESSANDRO PAGANELLI wrote:<br>
<br>
> I'm working on a project (which uses Libav/Ffmpeg) in which I have to transmit an h264 encoded file (with Mp4 file format) over a simulated network (I'm using network simulator 3 for this), to "emulate" a real video streaming.<br>
><br>
> Now, I'm facing the problem regarding how to "rebuild" the transmitted file at the receiver side. More in details, this issue regards the settings needed to replicate the configurations for AVFormatContext, AVStream and AVCodecContext, starting from the same structures I have at the transmitter.<br>
> As for now, I just copied the content of the sender's AVCodecContext structure to the receiver's one, but the resulting file is broken. I suspect that other settings have to be replicated too, but it's not clear which ones are those required by h264 and Mp4.<br>
><br>
> Is there any document/tutorial about the required settings for each specific codec or format?<br>
<br>
</div>If your source file is mp4 and your stream is mpegts then you might need to add the h264_mp4toannexb filter. This filter is available as an option for ffmpeg and you can also use it between av_read_frame and av_write_frame.<br>
<div class="im"><br>
> More in general, do you have suggestions about how to approach this problem for a generic combination of codec and format? I planned to implement different possible combinations of them, so it would be great if there is a "smart" way to copy these contexts without doing it "by hand" :) .<br>
<br>
</div>If you scan through this list you'll note a lot of questions which basically come back to the same problem you see here (and yes, one of them I had been asking).<br>
<br>
As far as I understood this problem the reason is that h264 (and I think also aac) are packed differently depending of if they are to be saved to a file or if they are to be streamed. h264 frames in a mpegts stream require a specific header for each frame, which is this "annex B".<br>
<br>
This h264_mp4toannexb filter will take the required information from the file header and put it in the annex B frame header. This is meant to work if you have a mp4 file to begin with. (There is a similar filter for aac.)<br>
<br>
If your source file is not in the mp4 format which this filter expects then you're out of luck (this is where I'm stuck too :( ). I have source files which are h264+aac in mpegts format, and there these filters do not work.<br>
<br>
Unfortunately there seems to be no other documentation about how to build a correct annex B header manually except what's in the source code (if there is, please point me to it!).<br>
<br>
<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" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>______________________________________________<br><br>Ing. Alessandro Paganelli, Ph. D. Student, 25th Cycle<br><br>Department of Information Engineering<br>University of Modena and Reggio Emilia<br>
via Vignolese 905, 41125 Modena (MO), ITALY<br><br>E-mail: <a href="mailto:alessandro.paganelli@unimore.it">alessandro.paganelli@unimore.it</a><br>
</div>