<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
A few more data points:<o:p> </o:p></p>
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
The issue is in the AAC stream. On the first file create by my program the PTS in the packets written with av_write_frame() are the same as what is in the container file (as per ffprobe) but in subsequent files a seeming random value (same value for the whole
 file) is add to each PTS that is passed to av_write_frame() for that file.<o:p> </o:p></p>
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
I hope this will make it clear to someone what I am doing wrong.<o:p> </o:p></p>
<br>
</div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> william keeling<br>
<b>Sent:</b> Saturday, May 8, 2021 1:32 PM<br>
<b>To:</b> libav-user@ffmpeg.org <libav-user@ffmpeg.org><br>
<b>Subject:</b> Start time and duration questions</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
I have a program that iterative creates Flash container files with 2 streams (video h264 and audio AAC).<span style=""> 
</span>The format and codec contexts are allocated before and freed after each file.
<span style=""> </span>Calls are made to avformat_write_header() after contexts are allocated and to av_write_trailer() before contexts are freed.<span style=""> 
</span> </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
I am using 1 for AVFormatContext.start_time_realtime (since 0 will get current system time).
<span style=""> </span>How do you start from 0 when muxing? </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
The other issue is first file shows the correct start time and duration when played thru VLC media player.<span style=""> 
</span>All subsequent files show a 0 start time, large duration and a black screen for a while; then the start time changes to a large start time that is correct run time below the duration and the video plays.
<span style=""> Any </span>ideas what I have done wrong that is causing the wrong start and duration time and the delay in video playing but only on subsequent files? </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
Thanks </p>
<br>
</div>
</div>
</div>
</body>
</html>