<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to calculate PTS in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/How-to-calculate-PTS/m-p/830145#M127532</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear NXP Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my application frames per second varies somewhere between 15-25 fps, and in order to get the right playback of the video stream I think I need to calculate the presentation timestamp in my application code (the encoder is not doing it itself). In libimxvpuapi encoded_frame-&amp;gt;pts just copies raw_frame-&amp;gt;pts, so I guess the raw_frame-&amp;gt;pts needs to be calculated by the application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking around I found a formula for h264 streams (&lt;A class="link-titled" href="https://stackoverflow.com/questions/6603979/ffmpegavcodec-encode-video-setting-pts-h264/9423605" title="https://stackoverflow.com/questions/6603979/ffmpegavcodec-encode-video-setting-pts-h264/9423605"&gt;c++ - ffmpeg::avcodec_encode_video setting PTS h264 - Stack Overflow&lt;/A&gt;):&lt;/P&gt;&lt;P&gt;//Calculate PTS: (1 / FPS) * sample rate * frame number&lt;BR /&gt;//sample rate 90KHz is for h.264 at 30 fps&lt;BR /&gt;picture-&amp;gt;pts = (1.0 / 30) * 90 * frame_count;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has any of you used a similar formula or is there any official documentation for it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Remus.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Jun 2018 13:22:03 GMT</pubDate>
    <dc:creator>remusmp</dc:creator>
    <dc:date>2018-06-28T13:22:03Z</dc:date>
    <item>
      <title>How to calculate PTS</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-calculate-PTS/m-p/830145#M127532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear NXP Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my application frames per second varies somewhere between 15-25 fps, and in order to get the right playback of the video stream I think I need to calculate the presentation timestamp in my application code (the encoder is not doing it itself). In libimxvpuapi encoded_frame-&amp;gt;pts just copies raw_frame-&amp;gt;pts, so I guess the raw_frame-&amp;gt;pts needs to be calculated by the application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking around I found a formula for h264 streams (&lt;A class="link-titled" href="https://stackoverflow.com/questions/6603979/ffmpegavcodec-encode-video-setting-pts-h264/9423605" title="https://stackoverflow.com/questions/6603979/ffmpegavcodec-encode-video-setting-pts-h264/9423605"&gt;c++ - ffmpeg::avcodec_encode_video setting PTS h264 - Stack Overflow&lt;/A&gt;):&lt;/P&gt;&lt;P&gt;//Calculate PTS: (1 / FPS) * sample rate * frame number&lt;BR /&gt;//sample rate 90KHz is for h.264 at 30 fps&lt;BR /&gt;picture-&amp;gt;pts = (1.0 / 30) * 90 * frame_count;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has any of you used a similar formula or is there any official documentation for it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Remus.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jun 2018 13:22:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-calculate-PTS/m-p/830145#M127532</guid>
      <dc:creator>remusmp</dc:creator>
      <dc:date>2018-06-28T13:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate PTS</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-calculate-PTS/m-p/830146#M127533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;maybe you can refer to the link as below:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/message/442184"&gt;https://community.nxp.com/message/442184&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Aug 2018 03:59:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-calculate-PTS/m-p/830146#M127533</guid>
      <dc:creator>joanxie</dc:creator>
      <dc:date>2018-08-10T03:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate PTS</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-calculate-PTS/m-p/830147#M127534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's my calculation of PTS, DTS and frame duration:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;unsigned int currentFrameTimestamp = this-&amp;gt;getCurrentTimestamp() - this-&amp;gt;startTime; // [ms]&lt;BR /&gt;pAVPacket-&amp;gt;pts = currentFrameTimestamp * 90; // Presentation timestamp. 90000 represents 1 second.&lt;BR /&gt;pAVPacket-&amp;gt;dts = currentFrameTimestamp * 90; // Decoding timestamp. Same as presentation timestamp.&lt;BR /&gt;pAVPacket-&amp;gt;duration = currentFrameTimestamp - this-&amp;gt;previousFrameTimestamp; // Duration of the frame.&lt;BR /&gt;this-&amp;gt;previousFrameTimestamp = currentFrameTimestamp; // Used to calculate the duration of the next frame.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It plays correctly in any player showing the right duration even if some frames are dropped from time to time. getCurrentTimestamp is system time in milliseconds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also figured out how to create the MP4 container along with the H.264 encoded video stream on-the-fly. This means no post-processing step is necessary for creating the container. If anyone's interested let me know and I'll post some code for it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2018 09:05:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-calculate-PTS/m-p/830147#M127534</guid>
      <dc:creator>remusmp</dc:creator>
      <dc:date>2018-08-15T09:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate PTS</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-calculate-PTS/m-p/830148#M127535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Remus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am interested with how you create the MP4 container along with the H.264 encoded video stream on-the-fly.&lt;/P&gt;&lt;P&gt;Could you please show me the code for it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Appreciate it !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Benson&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jan 2019 02:40:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-calculate-PTS/m-p/830148#M127535</guid>
      <dc:creator>bensonhuang</dc:creator>
      <dc:date>2019-01-28T02:40:32Z</dc:date>
    </item>
  </channel>
</rss>

