Whoami
Whoami

Reputation: 14418

getting AVFrame pts value

  1. I have a AVStream of Video from FormatContext. [ avstream ]
  2. Read Packet
  3. Decode packet if it is from video.
  4. Now Display the following.

    Packet DTS ->  7200.00    [ from packet ]
    Frame PTS   -> -9223372036854775808.000000
    stream time_base ->  0.000011
    Offset                    ->  0.080000    [ pts * time_base ]
    

code:

double pts = (double) packet.dts;
printf (" dts of packet %f , Frame pts:  %f, timeBase %f Offset: %f ",
    pts,
    (double)pFrame->pts, 
    av_q2d (avstream->time_base) , 
    pts
*av_q2d(avstream->time_base));
  1. Why is Frame pts negative ? Is it expected behavior ?
  2. Do I need to consider Frame pts from packet DTS [ ie: frame pts = packet dts ]

Upvotes: 1

Views: 2741

Answers (1)

Aaron Lieberman
Aaron Lieberman

Reputation: 414

The number you're seeing for PTS is -9223372036854775808 (0x8000000000000000) is also known as AV_NOPTS_VALUE. It means that there's no value available.

I couldn't find a solution when I was seeing this so after quite some time of banging my head against this, I ended up manually advancing my video clock when I saw this.

int64 pts = m_frame->pts;

if (pts == AV_NOPTS_VALUE)
{
    pts = m_videoClock +
        (1.f / av_q2d(stream->avg_frame_rate)) / av_q2d(stream->time_base);
}

m_videoClock = pts;

I don't think DTS is useful here because that represents when the packet decoded, which isn't a replacement for PTS.

Upvotes: 1

Related Questions