Dmitry Gorbunov wrote:<br><br>> Why dts? Because it's more reliable than pts after decoding (I presume you<br>> avcodec_decode_video on input packet to get raw video frame suitable for<br>> encoding).<br><br>I am not currently using avcodec_decode_video, I don't want to recompress the image data. I just want to take the MPEG4-TS stream and mux it with raw audio data. This is the basic flow of the encoding chain:<br>
<br>image sensor -> hardware capture -> hardware codec -> muxed with audio to an AVI file<br><br>I've been assigned the MPEG-4 data directly to AVPacket data pointer and then calling av_interleaved_write_frame. I can use ffmpeg to extract the audio and video, so it kinda of works, it just doesn't play back nicely in mplayer or vlc. I will look more into the dts member.<br>
<br>Thanks.<br>
<br><br><div class="gmail_quote">On Sun, Aug 14, 2011 at 10:53 PM, Dmitry Gorbunov <span dir="ltr"><<a href="mailto:atskiisotona@gmail.com">atskiisotona@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
Nicholas Butts wrote:<br>
><br>
> if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)<br>
> pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base,<br>
> _videoStream->time_base);<br>
><br>
<br>
</div>c->coded_frame->pts is a synthetic value produced by video encoder (usually<br>
0, 1, 2, 3, etc). It may be good for constant frame rates, but sometimes<br>
fails even then. And I believe that your case is related to variable frame<br>
rate. I don't know for sure, but most hardware devices seem to produce<br>
variable frame rate streams. My two web cameras do that at least.<br>
<br>
You should use input_packet.dts (packet you read from input mpeg stream via<br>
av_read_frame) and rescale it by input_stream->time_base and<br>
output_stream->time_base:<br>
<br>
pkt.pts = av_rescale_q(input_packet.pts, input_stream->time_base,<br>
output_stream->time_base); // of course condition is not required<br>
<br>
Why dts? Because it's more reliable than pts after decoding (I presume you<br>
avcodec_decode_video on input packet to get raw video frame suitable for<br>
encoding).<br>
<br>
The above solution works for me on my web cameras, I hope it helps you.<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://libav-users.943685.n4.nabble.com/Libav-user-Muxing-mpeg4-ts-and-raw-audio-to-AVI-file-tp3740515p3743865.html" target="_blank">http://libav-users.943685.n4.nabble.com/Libav-user-Muxing-mpeg4-ts-and-raw-audio-to-AVI-file-tp3740515p3743865.html</a><br>
Sent from the libav-users mailing list archive at Nabble.com.<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>
</font></blockquote></div><br><br clear="all"><br>-- <br>Nicholas Butts<br>SENIOR FIRMWARE ENGINEER<br><br>Appareo Systems, LLC<br>1810 NDSU Research Circle N<br>Fargo, ND 58102<br><br>P: (701) 356-2200<br>F: (701) 356-3157<br>
<br><a href="http://www.appareo.com">http://www.appareo.com</a><br><br><a href="mailto:nbutts@appareo.com">nbutts@appareo.com</a><br><br><br><br>NOTICE: This message {including attachments} is covered by the Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2521, is CONFIDENTIAL and may also be protected by ATTORNEY-CLIENT OR OTHER PRIVILEGE. If you believe that it has been sent to you in error, do not read it. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error and then delete it.<br>