Hello

I encode video and mux with H264-RTP using libavcodec/libavfilter libraries.
Everything works well except for calculating PTS timestamps.
I must properly timestamp my frames before passing them to encoder because i
get frames from a video sources that is not FFMpeg based.
How to properly set pts in AVFrame before passing it to
avcodec_encode_video? Currently what I do is:

int64_t now = av_gettime();
const AVRational codecTimebase =
avCodecCtx->getVideoCodecContext()->time_base;
const AVRational streamTimebase = avCodecCtx->getVideoStream()->time_base;
int64_t rescaledNow = av_rescale_q( now, codecTimebase, streamTimebase );
dstFrame->pts = rescaledNow;

Then avcodec_encode_video is called and i prepare AVPacket for sending:

AVPacket packet;
av_init_packet( &packet );
if(avCodecCtx->getVideoCodecContext()->coded_frame->key_frame)
{
    packet.flags |= AV_PKT_FLAG_KEY;
}
if(avCodecCtx->getVideoCodecContext()->coded_frame->pts != AV_NOPTS_VALUE)
{
    packet.pts=
av_rescale_q(avCodecCtx->getVideoCodecContext()->coded_frame->pts,
avCodecCtx->getVideoCodecContext()->time_base,
avCodecCtx->getVideoStream()->time_base);

}

packet.stream_index= avCodecCtx->getVideoStream()->index;
packet.data= video_outbuf;
packet.size= encodedBytes;

Unfortunatelly after I call av_interleaved_write_frame, I get ocassionally
following errors:
[rtp @ 05B80EC0]st:0 error, non monotone timestamps 4612923002548562400 >=
4612923002492312400

I open the SDP file generated by libavformat and open this file in VLC. VLC
receives the RTP/H264 stream but is playing only 1st frame. I encode video
with H264 and mux it with RTP.

Do you have an idea what may be wrong?

Regards
-- 
Dominik Tomczak
http://www.cubesoft.pl
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to