<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=iso-8859-1"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><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:"Lucida Console";
        panose-1:2 11 6 9 4 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
h1
        {mso-style-priority:9;
        mso-style-link:"Überschrift 1 Zchn";
        margin-top:12.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;
        page-break-after:avoid;
        font-size:11.0pt;
        font-family:"Cambria","serif";
        color:#365F91;
        mso-fareast-language:EN-US;}
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.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
p.code, li.code, div.code
        {mso-style-name:code;
        mso-style-priority:99;
        mso-style-link:"code Zchn";
        margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:14.2pt;
        mso-add-space:auto;
        background:#D9D9D9;
        border:none;
        padding:0cm;
        font-size:9.0pt;
        font-family:"Lucida Console";
        color:black;
        mso-fareast-language:EN-US;}
p.codeCxSpFirst, li.codeCxSpFirst, div.codeCxSpFirst
        {mso-style-name:codeCxSpFirst;
        mso-style-priority:99;
        mso-style-link:"code Zchn";
        mso-style-type:export-only;
        margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:14.2pt;
        margin-bottom:.0001pt;
        mso-add-space:auto;
        background:#D9D9D9;
        border:none;
        padding:0cm;
        font-size:9.0pt;
        font-family:"Lucida Console";
        color:black;
        mso-fareast-language:EN-US;}
p.codeCxSpMiddle, li.codeCxSpMiddle, div.codeCxSpMiddle
        {mso-style-name:codeCxSpMiddle;
        mso-style-priority:99;
        mso-style-link:"code Zchn";
        mso-style-type:export-only;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:14.2pt;
        margin-bottom:.0001pt;
        mso-add-space:auto;
        background:#D9D9D9;
        border:none;
        padding:0cm;
        font-size:9.0pt;
        font-family:"Lucida Console";
        color:black;
        mso-fareast-language:EN-US;}
p.codeCxSpLast, li.codeCxSpLast, div.codeCxSpLast
        {mso-style-name:codeCxSpLast;
        mso-style-priority:99;
        mso-style-link:"code Zchn";
        mso-style-type:export-only;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:14.2pt;
        mso-add-space:auto;
        background:#D9D9D9;
        border:none;
        padding:0cm;
        font-size:9.0pt;
        font-family:"Lucida Console";
        color:black;
        mso-fareast-language:EN-US;}
span.codeZchn
        {mso-style-name:"code Zchn";
        mso-style-priority:99;
        mso-style-link:code;
        font-family:"Lucida Console";
        color:black;
        background:#D9D9D9;}
span.berschrift1Zchn
        {mso-style-name:"Überschrift 1 Zchn";
        mso-style-priority:9;
        mso-style-link:"Überschrift 1";
        font-family:"Cambria","serif";
        color:#365F91;
        font-weight:bold;}
span.E-MailFormatvorlage20
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:724375592;
        mso-list-type:hybrid;
        mso-list-template-ids:1550501922 -372599774 67567619 67567621 67567617 67567619 67567621 67567617 67567619 67567621;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-font-family:Calibri;
        mso-bidi-font-family:"Times New Roman";}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></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=DE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Hallo together,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>We have some problems to get AV in sync with our hardware decoders with some kind MP4 files.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>We have implemented audio- and video sinks based on a hardware decoder. This decoder(s) have a (common) clock (STC) . When I feed audio and video buffers with timestamps (PTS), the hardware will output the decoded frames according to this STC. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>To build the PTS for the hardware from the buffer PTS we<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US><span style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>          </span></span></span><![endif]><span lang=EN-US>In SEGMENT event store the segment in the element and reset the hardware STC to 0 (both for audio and video)<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US><span style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>          </span></span></span><![endif]><span lang=EN-US>In push() convert the PTS for the decoder with <o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:72.0pt;text-indent:-18.0pt;mso-list:l0 level2 lfo1'><![if !supportLists]><span lang=EN-US style='font-family:"Courier New"'><span style='mso-list:Ignore'>o<span style='font:7.0pt "Times New Roman"'>   </span></span></span><![endif]><span lang=EN-US>PTS = gst_segment_to_running_time (&thiz->seg, GST_FORMAT_TIME, GST_BUFFER_PTS (buffer));<o:p></o:p></span></p><p class=MsoListParagraph><span lang=EN-US>… and send the buffer with this new PTS to hardware<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Is this correct?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>As written above, this works for most streams, but we found some, where AV is not in sync. (compared to the playback of this streams with VLC or Windows Mediaplayer). The special of this streams seems to be the elst-box in the MP4 file. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Mostly I get two segment events before the first video buffer, for example<o:p></o:p></span></p><div style='mso-element:para-border-div;border:solid windowtext 1.0pt;padding:4.0pt 4.0pt 4.0pt 4.0pt;background:#D9D9D9;margin-left:14.2pt;margin-right:0cm'><p class=codeCxSpFirst style='margin-left:0cm;mso-add-space:auto;background:#D9D9D9'><span lang=EN-US>time segment start=0:00:00.000000000, offset=0:00:00.000000000, stop=99:99:99.999999999, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 0:00:00.000000000, duration 99:99:99.999999999<o:p></o:p></span></p><p class=codeCxSpMiddle style='margin-left:0cm;mso-add-space:auto;background:#D9D9D9'><span lang=EN-US>time segment start=0:00:00.083333333, offset=0:00:00.000000000, stop= 0:05:00.083333333, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 0:00:00.083333333, duration 99:99:99.999999999<o:p></o:p></span></p><p class=codeCxSpLast style='margin-left:0cm;mso-add-space:auto;background:#D9D9D9'>render l=        1120 t=0:00:00.083333333 flags=00004040 free=         100<o:p></o:p></p></div><p class=MsoNormal><span lang=EN-US>In the wrong case, I get 3 events like this<o:p></o:p></span></p><div style='mso-element:para-border-div;border:solid windowtext 1.0pt;padding:4.0pt 4.0pt 4.0pt 4.0pt;background:#D9D9D9;margin-left:14.2pt;margin-right:0cm'><p class=codeCxSpFirst style='margin-left:0cm;mso-add-space:auto;background:#D9D9D9'><span lang=EN-US>time segment start=0:00:00.000000000, offset=0:00:00.000000000, stop=99:99:99.999999999, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 0:00:00.000000000, duration 99:99:99.999999999<o:p></o:p></span></p><p class=codeCxSpMiddle style='margin-left:0cm;mso-add-space:auto;background:#D9D9D9'><span lang=EN-US>time segment start=0:00:00.000000000, offset=0:00:00.000000000, stop= 0:00:00.080000000, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 0:00:00.000000000, duration 99:99:99.999999999<o:p></o:p></span></p><p class=codeCxSpMiddle style='margin-left:0cm;mso-add-space:auto;background:#D9D9D9'><span lang=EN-US>time segment start=0:00:00.080000000, offset=0:00:00.000000000, stop= 0:04:30.400000000, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.080000000, base=0:00:00.000000000, position 0:00:00.080000000, duration 99:99:99.999999999<o:p></o:p></span></p><p class=codeCxSpLast style='margin-left:0cm;mso-add-space:auto;background:#D9D9D9'>render l=       34461 t=0:00:00.080000000 flags=00000040 free=         100<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>Thanks for any help or confirmation, that I’m not totally wrong. I’m not sure, if my STC/PTS calculation is correct or if possibly the is an issue in qtdemux.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Kind regards<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>/Juergen<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></body></html>