<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);">
Again, T<span id="" title="" class=""><span id="" title="" class="">hanks</span> for your input -- never said the code was bug free or even not buggy -- but I do know the free of all the context listed are being called and other than avformat_free_context()
 which has no way to check it worked  (not sure way it was written like that) are validated.</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span title="" class=""><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span title="" class="">code is here <a href="https://github.com/wkeeling63/racecam" id="LPlnk">https://github.com/wkeeling63/racecam</a></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Please let me know if you have any ideas </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks</div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1"></div>
<br>
<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 Paul B Mahol <onemda@gmail.com><br>
<b>Sent:</b> Wednesday, March 3, 2021 1:28 PM<br>
<b>To:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter. <libav-user@ffmpeg.org><br>
<b>Subject:</b> Re: [Libav-user] Reuse of format context after free and reallocate?</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Wed, Mar 3, 2021 at 8:26 PM william keeling <<a href="mailto:williamkeeling@hotmail.com">williamkeeling@hotmail.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
thanks for you input -- I am freeing all context and still get the errors as if FLVContext is not freed</div>
</div>
</blockquote>
<div><br>
</div>
<div>Than show actual code, It must be buggy.</div>
<div> </div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_gmail-m_-8794236861927058738appendonsend"></div>
<hr style="display:inline-block; width:98%">
<div id="x_gmail-m_-8794236861927058738divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Libav-user <<a href="mailto:libav-user-bounces@ffmpeg.org" target="_blank">libav-user-bounces@ffmpeg.org</a>>
 on behalf of Paul B Mahol <<a href="mailto:onemda@gmail.com" target="_blank">onemda@gmail.com</a>><br>
<b>Sent:</b> Wednesday, March 3, 2021 11:21 AM<br>
<b>To:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter. <<a href="mailto:libav-user@ffmpeg.org" target="_blank">libav-user@ffmpeg.org</a>><br>
<b>Subject:</b> Re: [Libav-user] Reuse of format context after free and reallocate?</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div>
<div dir="ltr">On Wed, Mar 3, 2021 at 5:50 PM william keeling <<a href="mailto:williamkeeling@hotmail.com" target="_blank">williamkeeling@hotmail.com</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I have not used "<span style="font-size:15px; background-color:rgb(255,255,255); display:inline">valgrind" I will need to look into that tool.  any tips on how to use it?</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:15px; background-color:rgb(255,255,255); display:inline"><br>
</span></div>
</div>
</blockquote>
<div><br>
</div>
<div>If you are on Linux, using it is very easy.</div>
<div><br>
</div>
<div> </div>
<blockquote style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:15px; background-color:rgb(255,255,255); display:inline"></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:15px; background-color:rgb(255,255,255); display:inline">yes, I am free the all contexts before reallocation but I cannot find a way to for the FLVContext/Muxer to be freed/reinitialized thru the API.</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:15px; background-color:rgb(255,255,255); display:inline">I am doing the following:</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:15px; background-color:rgb(255,255,255); display:inline">
<p style="background-color:rgb(255,255,255); font-size:11pt; font-family:Calibri,sans-serif; margin:0px 0px 8pt; line-height:15.6933px">
avcodec_free_context() of all streams video and audio </p>
<p style="background-color:rgb(255,255,255); font-size:11pt; font-family:Calibri,sans-serif; margin:0px 0px 8pt; line-height:15.6933px">
<span style="font-family:Calibri,sans-serif; font-size:11pt">avformat_free_context() </span></p>
<p style="background-color:rgb(255,255,255); font-size:11pt; font-family:Calibri,sans-serif; margin:0px 0px 8pt; line-height:15.6933px">
avio_close() </p>
</span></div>
</div>
</blockquote>
<div><br>
</div>
<div>If you really do all this than that error would never happen.</div>
<div> </div>
<blockquote style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:15px; background-color:rgb(255,255,255); display:inline"><br>
</span></div>
<div id="x_gmail-m_-8794236861927058738x_gmail-m_2468805046675342257appendonsend">
</div>
<hr style="display:inline-block; width:98%">
<div id="x_gmail-m_-8794236861927058738x_gmail-m_2468805046675342257divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Libav-user <<a href="mailto:libav-user-bounces@ffmpeg.org" target="_blank">libav-user-bounces@ffmpeg.org</a>> on behalf of Paul B Mahol <<a href="mailto:onemda@gmail.com" target="_blank">onemda@gmail.com</a>><br>
<b>Sent:</b> Wednesday, March 3, 2021 5:54 AM<br>
<b>To:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter. <<a href="mailto:libav-user@ffmpeg.org" target="_blank">libav-user@ffmpeg.org</a>><br>
<b>Subject:</b> Re: [Libav-user] Reuse of format context after free and reallocate?</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div>
<div dir="ltr">On Wed, Mar 3, 2021 at 5:22 AM william keeling <<a href="mailto:williamkeeling@hotmail.com" target="_blank">williamkeeling@hotmail.com</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
 I did some digging and found the error is coming from this code in flvenv.c line 921.
<div><br>
</div>
<div>  if (pkt->dts < -flv->delay) {</div>
<div>        av_log(s, AV_LOG_WARNING,</div>
<div>               "Packets are not in the proper order with respect to DTS\n");</div>
<div>        return AVERROR(EINVAL);</div>
<div><br>
</div>
<div>flv is a pointer to  FLVContext from AVFormatContext->priv_data.<br>
</div>
<div><br>
</div>
<div>Looks like the avformat_write_header()/avformat_init_output uses the state of the muxer at the last run even if the AVFormatContext has been freed and reallocated.</div>
So how do I get the FLVContext to be initlized as if a fresh run. Or how do I free the old FLVContext so when avformat_write_header() initlizes the priv_data it is fresh.<br>
</div>
<div id="x_gmail-m_-8794236861927058738x_gmail-m_2468805046675342257x_gmail-m_8628966046779895580appendonsend">
</div>
<hr style="display:inline-block; width:98%">
<div id="x_gmail-m_-8794236861927058738x_gmail-m_2468805046675342257x_gmail-m_8628966046779895580divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Libav-user <<a href="mailto:libav-user-bounces@ffmpeg.org" target="_blank">libav-user-bounces@ffmpeg.org</a>> on behalf of william keeling <<a href="mailto:WilliamKeeling@hotmail.com" target="_blank">WilliamKeeling@hotmail.com</a>><br>
<b>Sent:</b> Monday, March 1, 2021 2:32 PM<br>
<b>To:</b> <a href="mailto:libav-user@ffmpeg.org" target="_blank">libav-user@ffmpeg.org</a> <<a href="mailto:libav-user@ffmpeg.org" target="_blank">libav-user@ffmpeg.org</a>><br>
<b>Subject:</b> [Libav-user] Reuse of format context after free and reallocate?</font>
<div> </div>
</div>
<div dir="ltr">
<p style="margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
I have a program the creates flash format stream and is work the first time thru but when I process the second stream, I get DTS/PTS non monotonically errors. </p>
<p style="margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
After each stream I free and reallocate all contexts: </p>
<p style="margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
avcodec_free_context() of all streams video and audio </p>
<p style="margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
avformat_free_context() </p>
<p style="margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
avio_close() </p>
<p style="margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
<p style="margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
What am I missing so the format context can be reallocate and used? </p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Looks like to be real bug to me.</div>
<div> </div>
<blockquote style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div dir="ltr">
<p style="margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
<p style="margin:0in 0in 8pt; line-height:107%; font-size:11pt; font-family:Calibri,sans-serif">
Thanks William </p>
</div>
</div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".</blockquote>
</div>
</div>
</div>
</div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".</blockquote>
</div>
</div>
</div>
</div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".</blockquote>
</div>
</div>
</div>
</body>
</html>