[FFmpeg-user] MPEGTS muxing, DTS errors

Sylvain sylvain at lahiette.com
Thu Jan 30 07:51:46 CET 2014


Hi all 

I am creating a MPEG2-TS with a,H264 stream, and i have  the following 
error messages, nearly for each frame i encode : 

	[mpegts @ 0x15459c0] dts < pcr, TS is invalid

The source code used to encode and mux the packet is the following 
(recorder is a structure from my application, it holds the needed 
structures for the compression/mux).   

int encode_function(PXL_Recorder_t  *recorder, AVFrame *pictorec)
{
  int32_t got_packet=0, ret = 0;

  av_init_packet(&recorder->packet);
  recorder->packet.data = recorder->outbuf;
  recorder->packet.size = recorder->outbuf_size;
  ret = avcodec_encode_video2(recorder->st->codec, &recorder->packet, 
pictorec, &got_packet);
  if (ret < 0) return ret;

  if (ret == 0 && got_packet && recorder->packet.size > 0)
  {
    recorder->packet.stream_index = recorder->st->index;
    ret = av_interleaved_write_frame(recorder->oc, &recorder->packet);
    //av_free_packet(&recorder->packet);
  }
  if (pictorec) pictorec->pts += av_rescale_q(1, recorder->st->codec-
>time_base, recorder->st->time_base);
  return got_packet;
}

Notes :
pictrorec is a persistant variable, the pointer is the same across 
successive calls. 
I'am capturing from a local video device, in PAL (ie 720x576 @ 25fps).

Do you see any missing stuff in this function in order to fix this 
dts<pcr messages?

Thanks for your time, 
SF



More information about the ffmpeg-user mailing list