time_base

内部时间戳:

AVRarional time_base = {1,1,AV_TIME_BASE};
int64_t  timestamp = time/ time_base;  //内部时间戳  
int64_t time = timestamp * time_base;//实际时间(秒)

例子:

1:封装Packet的PTS,DTS;

</pre><pre name="code" class="cpp">AVRational time_base = ofmt_ctx->streams[0]->time_base;
AVRational r_framerate1 = { 60, 2 };   
AVRational time_base_q = { 1, AV_TIME_BASE }; 
//内部时间戳  
int64_t calc_duration = (double)(1/av_q2d(r_framerate1))*(AV_TIME_BASE); 
// int64_t calc_duration = (double)(1/av_q2d(r_framerate1))/av_q2d(time_base_q);

//转换为以packet的time_base的pts,dts,duration:
enc_pkt.pts = av_rescale_q(framecnt*calc_duration, time_base_q, time_base);  
enc_pkt.dts = enc_pkt.pts;         
enc_pkt.duration = av_rescale_q(calc_duration, time_base_q, time_base); 


2:判断PTS和当前时间间隔是否相等

pts时间还原为内部时间戳

        int64_t pts_time = av_rescale_q(enc_pkt.dts, time_base, time_base_q);  
        int64_t now_time = av_gettime() - start_time;  
        if (pts_time > now_time)  
            av_usleep(pts_time - now_time); 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值