<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">Hi,</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">I'm using ffmpeg libraries to read from a UDP transport stream and decode the data, but I've been asked to add a feature to handle signal loss and I'm hoping I can get some help with this.</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">My initial workflow design would be something along these lines:</div><ol style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><li>Add a timeout to the av_read_frame call via url_set_interrupt_cb.</li><li>On interrupt, check if too much time as passed via gettimeofday timestamps</li><li>If too much time has passed, return 1, causing av_read_frame to fail.</li><li>If av_read_frame fails due to interrupt, insert black frames according to my current fps and amount of time that has passed. Also insert silence audio samples for the amount of time that has passed.</li><li>Continue in while loop, calling av_read_frame again, and starting the process over again.</li></ol><div><div><font class="Apple-style-span" face="Calibri,sans-serif">Sudo code workflow: </font></div><div><font class="Apple-style-span" face="Calibri,sans-serif"><br></font></div><div><font class="Apple-style-span" face="Calibri,sans-serif">int retVal = av_read_frame(m_formatInfo, &packet);</font></div><div><font class="Apple-style-span" face="Calibri,sans-serif">if (retVal < 0 && wasTimeout)</font></div><div><font class="Apple-style-span" face="Calibri,sans-serif">{</font></div><div><span class="Apple-style-span" style="font-family: Calibri, sans-serif; ">            //Insert blank frames</span></div><div><span class="Apple-style-span" style="font-family: Calibri, sans-serif; ">            //Insert empty audio</span></div><div><span class="Apple-style-span" style="font-family: Calibri, sans-serif; ">            continue;</span></div><div><font class="Apple-style-span" face="Calibri,sans-serif">}</font></div></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">However, I noticed a couple of things wrong when I started to implement this:</div><ol><li>When interrupt function returns 1, av_read_frame DOES NOT return a negative value.</li><li>Subsequent calls to av_read_frame (after timeout occurred) return immediately a negative value.</li></ol><div>Does anyone know why this happens? Has anyone here have any experience dealing with signal loss? Does this design look plausible to handle workflow? Any help is appreciated.</div><div><br></div><div>Thanks</div></body></html>