[Libav-user] timestamps not set after streaming video

Charles A Prosser caprosse at us.ibm.com
Tue Nov 11 22:07:07 CET 2014



Hello,

I am encoding video data on an Android device, sending the encoded video
data to a server via websocket, and decoding the video data on the server.
This seems to work fine, except it appears that the timestamps are not set
in the decoded video frames.

On the Android client:

AVRational time_base = new AVRational();
time_base.num(1);
time_base.den(m_videoFormat.getFrameRate());
video_c.time_base(time_base);
frame.pts(0)

// For each frame:
   frame.pts(frame.pts() + 1);
   int ret = avcodec_encode_video2(video_c, pkt, frame, got_output);
   if (ret < 0) {
      return(-1);
   }

   if (got_output) {
      System.out.printf("Write frame %3d, (size=%5d), (milliseconds: %14d),
(tstamp: %8d)\n",
      	              	m_iFrames, pkt.size(), time, pkt.pts());

      // Send pkt.data to server via websocket
      :
      :
      :
   }


On the client the printf appears to display valid timestamps.
Write frame  37, (size= 1275), (milliseconds:  1415727731456), (tstamp:
20)

On the server:

// For each chunk of video data read from websocket...

   avpkt.size = iBytes;     // iBytes is length of data read from websocket
   avpkt.data = cBytes;   // cBytes is data read from websocket

   int len = avcodec_decode_video2(c, frame, &got_frame, &avpkt);
   if (len < 0) {
      return(-1);
   }

   if (got_frame) {
      printf("Frame timestamps: pts: %lld, dts: %lld, base: %lld. \n",
     		(long long)avpkt.pts, (long long)avpkt.dts,
		av_q2d(c->time_base));

      // Write frame to disk...

   }

On the server the timestamps appear to be not set.
Frame timestamps: pts: -9223372036854775808, dts: -9223372036854775808,
base: 222879922077.

Any idea what I'm doing wrong?  Thanks in advance for any suggestions!

Charles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141111/464601a2/attachment.html>


More information about the Libav-user mailing list