<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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">
Sorry I was wrong on review both the video (H264) and audio (AAC) have the same time added to their PTS/DTS packet times.<span style="mso-spacerun:yes"> 
</span>The only frame that has the correct (from my programs point of view) is the first video frame/packet (PTS=0) and this packet only contains side data
<o:p> </o:p></p>
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
<o:p> </o:p></p>
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
ffprobe from start of first 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">
</p>
Sorry I was wrong on review both the video (H264) and audio (AAC) have the same time added to their PTS/DTS packet times.  The only frame that has the correct (from my programs point of view) is the first video frame/packet (PTS=0) and this packet only contains
 side data
<div><br>
</div>
<div>ffprobe from start of first file:</div>
<div>[PACKET]</div>
<div>codec_type=video</div>
<div>stream_index=0</div>
<div>pts=0</div>
<div>pts_time=0.000000</div>
<div>dts=0</div>
<div>dts_time=0.000000</div>
<div>duration=N/A</div>
<div>duration_time=N/A</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=28</div>
<div>pos=414</div>
<div>flags=__</div>
<div>[/PACKET]</div>
<div>[PACKET]</div>
<div>codec_type=audio</div>
<div>stream_index=1</div>
<div>pts=0</div>
<div>pts_time=0.000000</div>
<div>dts=0</div>
<div>dts_time=0.000000</div>
<div>duration=23</div>
<div>duration_time=0.023000</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=165</div>
<div>pos=462</div>
<div>flags=K_</div>
<div>[/PACKET]</div>
<div>[FRAME]</div>
<div>media_type=audio</div>
<div>stream_index=1</div>
<div>key_frame=1</div>
<div>pkt_pts=0</div>
<div>pkt_pts_time=0.000000</div>
<div>pkt_dts=0</div>
<div>pkt_dts_time=0.000000</div>
<div>best_effort_timestamp=0</div>
<div>best_effort_timestamp_time=0.000000</div>
<div>pkt_duration=23</div>
<div>pkt_duration_time=0.023000</div>
<div>pkt_pos=462</div>
<div>pkt_size=165</div>
<div>sample_fmt=fltp</div>
<div>nb_samples=1024</div>
<div>channels=2</div>
<div>channel_layout=stereo</div>
<div>[/FRAME]</div>
<div>[PACKET]</div>
<div>codec_type=audio</div>
<div>stream_index=1</div>
<div>pts=23</div>
<div>pts_time=0.023000</div>
<div>dts=23</div>
<div>dts_time=0.023000</div>
<div>duration=23</div>
<div>duration_time=0.023000</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=172</div>
<div>pos=644</div>
<div>flags=K_</div>
<div>[/PACKET]</div>
<div>[FRAME]</div>
<div>media_type=audio</div>
<div>stream_index=1</div>
<div>key_frame=1</div>
<div>pkt_pts=23</div>
<div>pkt_pts_time=0.023000</div>
<div>pkt_dts=23</div>
<div>pkt_dts_time=0.023000</div>
<div>best_effort_timestamp=23</div>
<div>best_effort_timestamp_time=0.023000</div>
<div>pkt_duration=23</div>
<div>pkt_duration_time=0.023000</div>
<div>pkt_pos=644</div>
<div>pkt_size=172</div>
<div>sample_fmt=fltp</div>
<div>nb_samples=1024</div>
<div>channels=2</div>
<div>channel_layout=stereo</div>
<div>[/FRAME]</div>
<div>[PACKET]</div>
<div>codec_type=video</div>
<div>stream_index=0</div>
<div>pts=0</div>
<div>pts_time=0.000000</div>
<div>dts=0</div>
<div>dts_time=0.000000</div>
<div>duration=N/A</div>
<div>duration_time=N/A</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=13673</div>
<div>pos=833</div>
<div>flags=K_</div>
<div>[/PACKET]</div>
<div>[FRAME]</div>
<div>media_type=video</div>
<div>stream_index=0</div>
<div>key_frame=1</div>
<div>pkt_pts=0</div>
<div>pkt_pts_time=0.000000</div>
<div>pkt_dts=0</div>
<div>pkt_dts_time=0.000000</div>
<div>best_effort_timestamp=0</div>
<div>best_effort_timestamp_time=0.000000</div>
<div>pkt_duration=N/A</div>
<div>pkt_duration_time=N/A</div>
<div>pkt_pos=833</div>
<div>pkt_size=13673</div>
<div>width=1920</div>
<div>height=1080</div>
<div>pix_fmt=yuv420p</div>
<div>sample_aspect_ratio=N/A</div>
<div>pict_type=I</div>
<div>coded_picture_number=0</div>
<div>display_picture_number=0</div>
<div>interlaced_frame=0</div>
<div>top_field_first=0</div>
<div>repeat_pict=0</div>
<div>color_range=unknown</div>
<div>color_space=unknown</div>
<div>color_primaries=unknown</div>
<div>color_transfer=unknown</div>
<div>chroma_location=left</div>
<div>[/FRAME]</div>
<div><br>
</div>
<div>ffprobe from start of second file:</div>
<div><br>
</div>
<div>[PACKET]</div>
<div>codec_type=video</div>
<div>stream_index=0</div>
<div>pts=0</div>
<div>pts_time=0.000000</div>
<div>dts=0</div>
<div>dts_time=0.000000</div>
<div>duration=N/A</div>
<div>duration_time=N/A</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=28</div>
<div>pos=414</div>
<div>flags=__</div>
<div>[/PACKET]</div>
<div>[PACKET]</div>
<div>codec_type=audio</div>
<div>stream_index=1</div>
<div>pts=1790282</div>
<div>pts_time=1790.282000</div>
<div>dts=1790282</div>
<div>dts_time=1790.282000</div>
<div>duration=23</div>
<div>duration_time=0.023000</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=170</div>
<div>pos=462</div>
<div>flags=K_</div>
<div>[/PACKET]</div>
<div>[FRAME]</div>
<div>media_type=audio</div>
<div>stream_index=1</div>
<div>key_frame=1</div>
<div>pkt_pts=1790282</div>
<div>pkt_pts_time=1790.282000</div>
<div>pkt_dts=1790282</div>
<div>pkt_dts_time=1790.282000</div>
<div>best_effort_timestamp=1790282</div>
<div>best_effort_timestamp_time=1790.282000</div>
<div>pkt_duration=23</div>
<div>pkt_duration_time=0.023000</div>
<div>pkt_pos=462</div>
<div>pkt_size=170</div>
<div>sample_fmt=fltp</div>
<div>nb_samples=1024</div>
<div>channels=2</div>
<div>channel_layout=stereo</div>
<div>[/FRAME]</div>
<div>[PACKET]</div>
<div>codec_type=video</div>
<div>stream_index=0</div>
<div>pts=1796496</div>
<div>pts_time=1796.496000</div>
<div>dts=1796496</div>
<div>dts_time=1796.496000</div>
<div>duration=N/A</div>
<div>duration_time=N/A</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=13559</div>
<div>pos=649</div>
<div>flags=K_</div>
<div>[/PACKET]</div>
<div>[FRAME]</div>
<div>media_type=video</div>
<div>stream_index=0</div>
<div>key_frame=1</div>
<div>pkt_pts=1796496</div>
<div>pkt_pts_time=1796.496000</div>
<div>pkt_dts=1796496</div>
<div>pkt_dts_time=1796.496000</div>
<div>best_effort_timestamp=1796496</div>
<div>best_effort_timestamp_time=1796.496000</div>
<div>pkt_duration=N/A</div>
<div>pkt_duration_time=N/A</div>
<div>pkt_pos=649</div>
<div>pkt_size=13559</div>
<div>width=1920</div>
<div>height=1080</div>
<div>pix_fmt=yuv420p</div>
<div>sample_aspect_ratio=N/A</div>
<div>pict_type=I</div>
<div>coded_picture_number=0</div>
<div>display_picture_number=0</div>
<div>interlaced_frame=0</div>
<div>top_field_first=0</div>
<div>repeat_pict=0</div>
<div>color_range=unknown</div>
<div>color_space=unknown</div>
<div>color_primaries=unknown</div>
<div>color_transfer=unknown</div>
<div>chroma_location=left</div>
<div>[/FRAME]</div>
<span></span>
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
<o:p></o:p></p>
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
<o:p> </o:p></p>
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
ffprobe from start of second 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">
<o:p> </o:p></p>
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
</p>
Sorry I was wrong on review both the video (H264) and audio (AAC) have the same time added to their PTS/DTS packet times.  The only frame that has the correct (from my programs point of view) is the first video frame/packet (PTS=0) and this packet only contains
 side data
<div><br>
</div>
<div>ffprobe from start of first file:</div>
<div>[PACKET]</div>
<div>codec_type=video</div>
<div>stream_index=0</div>
<div>pts=0</div>
<div>pts_time=0.000000</div>
<div>dts=0</div>
<div>dts_time=0.000000</div>
<div>duration=N/A</div>
<div>duration_time=N/A</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=28</div>
<div>pos=414</div>
<div>flags=__</div>
<div>[/PACKET]</div>
<div>[PACKET]</div>
<div>codec_type=audio</div>
<div>stream_index=1</div>
<div>pts=0</div>
<div>pts_time=0.000000</div>
<div>dts=0</div>
<div>dts_time=0.000000</div>
<div>duration=23</div>
<div>duration_time=0.023000</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=165</div>
<div>pos=462</div>
<div>flags=K_</div>
<div>[/PACKET]</div>
<div>[FRAME]</div>
<div>media_type=audio</div>
<div>stream_index=1</div>
<div>key_frame=1</div>
<div>pkt_pts=0</div>
<div>pkt_pts_time=0.000000</div>
<div>pkt_dts=0</div>
<div>pkt_dts_time=0.000000</div>
<div>best_effort_timestamp=0</div>
<div>best_effort_timestamp_time=0.000000</div>
<div>pkt_duration=23</div>
<div>pkt_duration_time=0.023000</div>
<div>pkt_pos=462</div>
<div>pkt_size=165</div>
<div>sample_fmt=fltp</div>
<div>nb_samples=1024</div>
<div>channels=2</div>
<div>channel_layout=stereo</div>
<div>[/FRAME]</div>
<div>[PACKET]</div>
<div>codec_type=audio</div>
<div>stream_index=1</div>
<div>pts=23</div>
<div>pts_time=0.023000</div>
<div>dts=23</div>
<div>dts_time=0.023000</div>
<div>duration=23</div>
<div>duration_time=0.023000</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=172</div>
<div>pos=644</div>
<div>flags=K_</div>
<div>[/PACKET]</div>
<div>[FRAME]</div>
<div>media_type=audio</div>
<div>stream_index=1</div>
<div>key_frame=1</div>
<div>pkt_pts=23</div>
<div>pkt_pts_time=0.023000</div>
<div>pkt_dts=23</div>
<div>pkt_dts_time=0.023000</div>
<div>best_effort_timestamp=23</div>
<div>best_effort_timestamp_time=0.023000</div>
<div>pkt_duration=23</div>
<div>pkt_duration_time=0.023000</div>
<div>pkt_pos=644</div>
<div>pkt_size=172</div>
<div>sample_fmt=fltp</div>
<div>nb_samples=1024</div>
<div>channels=2</div>
<div>channel_layout=stereo</div>
<div>[/FRAME]</div>
<div>[PACKET]</div>
<div>codec_type=video</div>
<div>stream_index=0</div>
<div>pts=0</div>
<div>pts_time=0.000000</div>
<div>dts=0</div>
<div>dts_time=0.000000</div>
<div>duration=N/A</div>
<div>duration_time=N/A</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=13673</div>
<div>pos=833</div>
<div>flags=K_</div>
<div>[/PACKET]</div>
<div>[FRAME]</div>
<div>media_type=video</div>
<div>stream_index=0</div>
<div>key_frame=1</div>
<div>pkt_pts=0</div>
<div>pkt_pts_time=0.000000</div>
<div>pkt_dts=0</div>
<div>pkt_dts_time=0.000000</div>
<div>best_effort_timestamp=0</div>
<div>best_effort_timestamp_time=0.000000</div>
<div>pkt_duration=N/A</div>
<div>pkt_duration_time=N/A</div>
<div>pkt_pos=833</div>
<div>pkt_size=13673</div>
<div>width=1920</div>
<div>height=1080</div>
<div>pix_fmt=yuv420p</div>
<div>sample_aspect_ratio=N/A</div>
<div>pict_type=I</div>
<div>coded_picture_number=0</div>
<div>display_picture_number=0</div>
<div>interlaced_frame=0</div>
<div>top_field_first=0</div>
<div>repeat_pict=0</div>
<div>color_range=unknown</div>
<div>color_space=unknown</div>
<div>color_primaries=unknown</div>
<div>color_transfer=unknown</div>
<div>chroma_location=left</div>
<div>[/FRAME]</div>
<div><br>
</div>
<div>ffprobe from start of second file:</div>
<div><br>
</div>
<div>[PACKET]</div>
<div>codec_type=video</div>
<div>stream_index=0</div>
<div>pts=0</div>
<div>pts_time=0.000000</div>
<div>dts=0</div>
<div>dts_time=0.000000</div>
<div>duration=N/A</div>
<div>duration_time=N/A</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=28</div>
<div>pos=414</div>
<div>flags=__</div>
<div>[/PACKET]</div>
<div>[PACKET]</div>
<div>codec_type=audio</div>
<div>stream_index=1</div>
<div>pts=1790282</div>
<div>pts_time=1790.282000</div>
<div>dts=1790282</div>
<div>dts_time=1790.282000</div>
<div>duration=23</div>
<div>duration_time=0.023000</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=170</div>
<div>pos=462</div>
<div>flags=K_</div>
<div>[/PACKET]</div>
<div>[FRAME]</div>
<div>media_type=audio</div>
<div>stream_index=1</div>
<div>key_frame=1</div>
<div>pkt_pts=1790282</div>
<div>pkt_pts_time=1790.282000</div>
<div>pkt_dts=1790282</div>
<div>pkt_dts_time=1790.282000</div>
<div>best_effort_timestamp=1790282</div>
<div>best_effort_timestamp_time=1790.282000</div>
<div>pkt_duration=23</div>
<div>pkt_duration_time=0.023000</div>
<div>pkt_pos=462</div>
<div>pkt_size=170</div>
<div>sample_fmt=fltp</div>
<div>nb_samples=1024</div>
<div>channels=2</div>
<div>channel_layout=stereo</div>
<div>[/FRAME]</div>
<div>[PACKET]</div>
<div>codec_type=video</div>
<div>stream_index=0</div>
<div>pts=1796496</div>
<div>pts_time=1796.496000</div>
<div>dts=1796496</div>
<div>dts_time=1796.496000</div>
<div>duration=N/A</div>
<div>duration_time=N/A</div>
<div>convergence_duration=N/A</div>
<div>convergence_duration_time=N/A</div>
<div>size=13559</div>
<div>pos=649</div>
<div>flags=K_</div>
<div>[/PACKET]</div>
<div>[FRAME]</div>
<div>media_type=video</div>
<div>stream_index=0</div>
<div>key_frame=1</div>
<div>pkt_pts=1796496</div>
<div>pkt_pts_time=1796.496000</div>
<div>pkt_dts=1796496</div>
<div>pkt_dts_time=1796.496000</div>
<div>best_effort_timestamp=1796496</div>
<div>best_effort_timestamp_time=1796.496000</div>
<div>pkt_duration=N/A</div>
<div>pkt_duration_time=N/A</div>
<div>pkt_pos=649</div>
<div>pkt_size=13559</div>
<div>width=1920</div>
<div>height=1080</div>
<div>pix_fmt=yuv420p</div>
<div>sample_aspect_ratio=N/A</div>
<div>pict_type=I</div>
<div>coded_picture_number=0</div>
<div>display_picture_number=0</div>
<div>interlaced_frame=0</div>
<div>top_field_first=0</div>
<div>repeat_pict=0</div>
<div>color_range=unknown</div>
<div>color_space=unknown</div>
<div>color_primaries=unknown</div>
<div>color_transfer=unknown</div>
<div>chroma_location=left</div>
<div>[/FRAME]</div>
<span></span>
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
<o:p></o:p></p>
<p class="MsoNormal" style="margin:0in 0in 8pt;line-height:107%;font-size:11pt;font-family:Calibri, sans-serif">
<o:p> </o:p></p>
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Libav-user <libav-user-bounces@ffmpeg.org> on behalf of william keeling <williamkeeling@hotmail.com><br>
<b>Sent:</b> Wednesday, May 12, 2021 8:56 PM<br>
<b>To:</b> libav-user@ffmpeg.org <libav-user@ffmpeg.org><br>
<b>Subject:</b> Re: [Libav-user] Start time and duration questions</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<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:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
A few more data points: </p>
<p class="x_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. </p>
<p class="x_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. </p>
<br>
</div>
<div>
<div id="x_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="x_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_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_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_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_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_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>
</div>
</body>
</html>