[x264-devel] FFMpeg - x254 and how to calculate the pts and dts values correctly.

Denis info at denisgottardello.it
Thu Sep 15 12:17:10 CEST 2011



In this mode

                                                pAVFrame->pts= Frames;
                                                //pCodecCtx->coded_frame->pts= Frames;
                                                //qDebug() << pCodecCtx->coded_frame->pts << pAVFrame->pkt_dts;
                                                int OutSize= avcodec_encode_video(pCodecCtx, pOutBuffer, BYTEPIC, pAVFrame);
                                                if (OutSize> 0) {
                                                    AVPacket Packet;
                                                    av_init_packet(&Packet);
                                                    if (pCodecCtx->coded_frame->pts != AV_NOPTS_VALUE) {
                                                        Packet.pts= av_rescale_q(pCodecCtx->coded_frame->pts, pCodecCtx->time_base, pVideoStream->time_base);
                                                    }
                                                    if (pCodecCtx->coded_frame->key_frame) Packet.flags |= AV_PKT_FLAG_KEY;
                                                    Packet.stream_index= pVideoStream->index;
                                                    Packet.data= pOutBuffer;
                                                    Packet.size= OutSize;
                                                    if (av_interleaved_write_frame(pFormatCtx, &Packet)!= 0) qDebug() << "av_interleaved_write_frame Error!";
                                                }
                                                Frames++;


I insert a packet in the video stream. When I try to play the produced file I obtain this error:


PachetCount: 1 , 32768 bytes, pBufferSize: 32768 
[mpegts @ 0x8eca320] Invalid timestamps stream=0, pts=0, dts=8589927392, size=1186
[mpegts @ 0x8eca320] Invalid timestamps stream=0, pts=14400, dts=8589930992, size=21
[mpegts @ 0x8eca320] max_analyze_duration 5000000 reached at 5000000
[mpegts @ 0x8eca320] Estimating duration from bitrate, this may be inaccurate
dump_format begin 
Input #0, mpegts, from 'foo.mpg':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0.0[0x100]: Video: h264 (High), yuv420p, 320x240, 25 fps, 25 tbr, 90k tbn, 50 tbc
dump_format end 
0 
"fps: 25" 


This error appears only in CODEC_ID_H264 mode and not in CODEC_ID_MPEG4 mode.
Which is the right way for calculate the pts and dts value?

-- 
www.denisgottardello.it
Skype: mrdebug
Videosurveillance and home automation! 
http://www.denisgottardello.it/DomusBoss/DomusBossIndice.php


More information about the x264-devel mailing list