<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:m="http://schemas.microsoft.com/office/2004/12/omml" 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 14 (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:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I have been having a tough time with an IP camera that serves out MPEG4. <o:p></o:p></p><p class=MsoNormal>I have dug into the headers and all that bit parseing and I think I understand why the timestamps are messed up.<o:p></o:p></p><p class=MsoNormal>It has no “Group Of Video Object Plane” headers, but that is ok, they are “optional”<o:p></o:p></p><p class=MsoNormal>But the vop_time_increment rolls over and the modulo_time_base is ALWAYS 0. <span style='font-family:Wingdings'>L</span><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'>My question is about the if condition in <span style='font-size:9.0pt;font-family:Consolas'>MPEG4VideoStreamParser::parseVideoObjectPlane() that handles these kinds of “buggy” mpeg 4 streams.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'>It reads: <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'>…<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> } <span style='color:blue'>else</span> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> <span style='color:blue'>if</span> (newTotalTicks < fPrevNewTotalTicks && vop_coding_type != 2<span style='color:green'>/*B*/</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> && modulo_time_base == 0 && vop_time_increment == 0 && !fJustSawTimeCode) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> <span style='color:green'>// This is another kind of buggy MPEG-4 video stream, in which</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> <span style='color:green'>// "vop_time_increment" wraps around, but without</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> <span style='color:green'>// "modulo_time_base" changing (or just having had a new time code).</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> <span style='color:green'>// Overcome this by pretending that "vop_time_increment" *did* wrap around:</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas;color:blue'>#ifdef</span><span style='font-size:9.0pt;font-family:Consolas'> DEBUG<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> fprintf(stderr, <span style='color:#A31515'>"Buggy MPEG-4 video stream: \"vop_time_increment\" wrapped around, but without \"modulo_time_base\" changing!\n"</span>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas;color:blue'>#endif</span><span style='font-size:9.0pt;font-family:Consolas'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> ++fSecondsSinceLastTimeCode;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> newTotalTicks += vop_time_increment_resolution;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'>…<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'>In my case vop_time_increment is never (or very rarely) exactly 0. It is usually a number below 100. Also the ticks case is never true.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'>When I add a last_vop_time_increment variable and change the test I can get it to execute this code with improved results.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'>…<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas;color:blue'>if</span><span style='font-size:9.0pt;font-family:Consolas'> ((vop_time_increment - last_vop_time_increment_ < 0) && vop_coding_type != 2<span style='color:green'>/*B*/</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'> && modulo_time_base == 0 && !fJustSawTimeCode_) <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'>…<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'>It still has a negative jump in the timestamps, but they are at least now very predictable and patterned. <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Consolas'>Is MPEG4 just that way? Messy group of non-compliant streams?<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:9.0pt;font-family:"Arial","sans-serif";color:black'> Jeff Shanab, Manager, Software Engineering<o:p></o:p></span></b></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Arial","sans-serif";color:black'> D 630.633.4515 | C 630.453.7764 | F 630.633.4815 | </span><span style='font-size:9.0pt;font-family:"Arial","sans-serif";color:#1F497D'> jshanab@smartwire.com</span><span style='font-size:9.0pt;font-family:"Arial","sans-serif";color:black'> <o:p></o:p></span></p><p class=MsoNormal><a href="http://www.smartwire.com/"><span style='color:#1F497D;text-decoration:none'><img border=0 width=626 height=108 id="Picture_x0020_5" src="cid:image001.gif@01CCE8BF.6572C640" alt="Description: Description: Description: Description: cid:706AA5FB-B29A-4B95-B275-FE31EE559CF0@hsd1.il.comcast.net."></span></a><span style='color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> </span><a href="https://twitter.com/#!/WindyCityWire"><span style='color:#1F497D;text-decoration:none'><img border=0 width=22 height=29 id="Picture_x0020_3" src="cid:image002.gif@01CCE8BF.6572C640" alt="Description: Description: Description: Description: Description: Description: Description: sig4"></span></a><span style='color:#1F497D'> </span><a href="http://www.youtube.com/user/WindyCityWire"><span style='color:#1F497D;text-decoration:none'><img border=0 width=22 height=29 id="Picture_x0020_2" src="cid:image003.gif@01CCE8BF.6572C640" alt="Description: Description: Description: Description: Description: Description: Description: sig3"></span></a><span style='color:#1F497D'> </span><a href="https://www.facebook.com/pages/Windy-City-Wire/270745609656461"><span style='color:#1F497D;text-decoration:none'><img border=0 width=22 height=29 id="Picture_x0020_1" src="cid:image004.gif@01CCE8BF.6572C640" alt="Description: Description: Description: Description: Description: Description: Description: sig2"></span></a><span style='color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>