<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">I am trying to write audio packet to file using ffmpeg.<br>The source device sending the packet after some interval.<br><br>e.g. First packet has a time stamp 00:00:00 <br>Second packet has a time stamp 00:00:00.5000000<br>Third packet has a time stamp 00:00:01<br>And so on...</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">Means two packet per second.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">I want to encode those packets and write to a file.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">I am referring the Ffmpeg example from link <a href="https://www.ffmpeg.org/doxygen/3.2/muxing_8c-example.html" rel="nofollow noreferrer" title="Muxing.c" style="margin:0px;padding:0px;border:0px;color:rgb(0,89,153);text-decoration:none">Muxing.c</a></p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">While encoding and writing there is no error. But output file has only 2 sec audio duration and speed is also super fast.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">The video frames are proper according the settings.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">I think the problem is related to calculation of pts, dts and duration of packet.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">Suggest me how to calculate proper values for pts, dts and duration. Or if this problem related to other thing let me know how i can resolve the problem.</p></div>