<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
 /* List Definitions */
 @list l0
        {mso-list-id:1508713307;
        mso-list-type:hybrid;
        mso-list-template-ids:-385705696 67698699 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0D8;
        mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level2
        {mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-tab-stop:1.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level4
        {mso-level-tab-stop:2.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-tab-stop:2.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-tab-stop:3.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level7
        {mso-level-tab-stop:3.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-tab-stop:4.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
-->
</style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="Section1">
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Hi,<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">In our application we are receiving a live stream, doing a ffmpeg decode, doing some overlay on the video and then encoding it as a mpeg2 stream.<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">After this we are streaming the video using live.<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">The problem is that the video when viewed in VLC is very jittery.
<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">So I analyzed the packets in wire shark and observed that the time stamp of each of the UDP packets is not in sequence.
<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font size="2" color="red" face="Arial"><span style="font-size:
10.0pt;font-family:Arial;color:red">Ex. Timestamp: 1487557790 – Frame n<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" color="red" face="Arial"><span style="font-size:
10.0pt;font-family:Arial;color:red">      Timestamp: 1487554190 – Frame n + 1<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" color="red" face="Arial"><span style="font-size:
10.0pt;font-family:Arial;color:red"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font size="2" color="red" face="Arial"><span style="font-size:
10.0pt;font-family:Arial;color:red">For the next frame the timestamp will not be in sequence.</span></font>
<font size="2" color="red" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:red"> <o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><img width="583" height="212" id="_x0000_i1025" src="cid:image001.jpg@01CBC871.2288C740"><o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Why are the time stamps not in sequence when the packets are received?<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">I have observed that on the sending side, for every frame the fPresentationTime is in the correct sequence.
<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">The code snippet from where I am reading the queue and updating the presentation time is given below.<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF"> void LiveInputSource:: incomingDataHandler1()<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">{<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    int ret;<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    if (!isCurrentlyAwaitingData()) return ;<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF"><o:p> </o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    ret = readData();<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    if (ret < 0 )<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    {<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">        handleClosure (this);<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    }<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    else if (ret == 0 )<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    {<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">        int uSecsToDelay = 50000 ;<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">        nextTask() = envir().taskScheduler().scheduleDelayedTask (uSecsToDelay, (TaskFunc*)incomingDataHandler,
 this);<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    }<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    else {<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">        nextTask() = envir().taskScheduler().scheduleDelayedTask (0, (TaskFunc*)afterGetting, this);<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    }<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">}<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">int LiveInputVideoSource:: readData()<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">{<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    /* Get frame from queue */<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    queue_get (frame, &frame_len);<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    if (frame_len == 0)<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    {<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">        return 0;<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    }<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF"><o:p> </o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    /* Copy frame to fTo */<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    memcpy (fTo, frame, frame_len);<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    fFrameSize = frame_len;<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">  
<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    gettimeofday (&fPresentationTime);<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">    return 1;<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF">}<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="1" color="#3366ff" face="Arial"><span style="font-size:8.0pt;font-family:Arial;color:#3366FF"><o:p> </o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><font size="2" face="Wingdings"><span style="font-size:10.0pt;font-family:Wingdings"><span style="mso-list:Ignore">Ø<font size="1" face="Times New Roman"><span style="font:7.0pt "Times New Roman"">      
</span></font></span></span></font><![endif]><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">For MPEG2 we are using this class MPEG1or2VideoStreamDiscreteFramer.<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">So when I see this code I observe that a lot of manipulation is done to the presentation time. So is it possible that the time stamp values
 are getting jumbled here? <o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-left:.5in"><i><font size="2" color="#3366ff" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:#3366FF;
font-style:italic">void MPEG1or2VideoStreamDiscreteFramer<o:p></o:p></span></font></i></p>
<p class="MsoNormal" style="margin-left:.5in"><i><font size="2" color="#3366ff" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:#3366FF;
font-style:italic">::afterGettingFrame1(unsigned frameSize, unsigned numTruncatedBytes,<o:p></o:p></span></font></i></p>
<p class="MsoNormal" style="margin-left:.5in"><i><font size="2" color="#3366ff" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:#3366FF;
font-style:italic">                     struct timeval presentationTime,<o:p></o:p></span></font></i></p>
<p class="MsoNormal"><i><font size="2" color="#3366ff" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:#3366FF;font-style:italic">                     unsigned durationInMicroseconds)<o:p></o:p></span></font></i></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Thanks in Advance.<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Regards,<o:p></o:p></span></font></p>
<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size:10.0pt;
font-family:Arial">Priya<o:p></o:p></span></font></p>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
http://www.mindtree.com/email/disclaimer.html<br>
</font>
</body>
</html>