博客
关于我
ffmpeg 帧率问题分析
阅读量:198 次
发布时间:2019-02-28

本文共 1332 字,大约阅读时间需要 4 分钟。

{

    /* 数据不需要解码 只需要复制 */
    if (!ist->decoding_needed) {
        ist->dts = ist->next_dts;
        switch (ist->dec_ctx->codec_type) {
        case AVMEDIA_TYPE_AUDIO:
            ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) /
                              ist->dec_ctx->sample_rate;

            break;

//这个case里面专门处理帧率的问题 当选择-re选项时会进入pkt->duration中 此处为40000 大概是40ms 也就是25帧

        case AVMEDIA_TYPE_VIDEO:
            if (ist->framerate.num) {
                // TODO: Remove work-around for c99-to-c89 issue 7
                AVRational time_base_q = AV_TIME_BASE_Q;
                int64_t next_dts = av_rescale_q(ist->next_dts, time_base_q, av_inv_q(ist->framerate));
                ist->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q);

            } else if (pkt->duration) {

 //

                ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
            } else if(ist->dec_ctx->framerate.num != 0) {
                int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame;
                ist->next_dts += ((int64_t)AV_TIME_BASE *
                                  ist->dec_ctx->framerate.den * ticks) /
                                  ist->dec_ctx->framerate.num / ist->dec_ctx->ticks_per_frame;
            }
            break;
        }
        ist->pts = ist->dts;
        ist->next_pts = ist->next_dts;
    }
    for (i = 0; pkt && i < nb_output_streams; i++) {
        OutputStream *ost = output_streams[i];
        if (!check_output_constraints(ist, ost) || ost->encoding_needed)
            continue;
        do_streamcopy(ist, ost, pkt);
    }
    return !eof_reached;
}

转载地址:http://nvln.baihongyu.com/

你可能感兴趣的文章
nodejs-mime类型
查看>>
nodejs中Express 路由统一设置缓存的小技巧
查看>>
NodeJs学习笔记001--npm换源
查看>>
Node入门之创建第一个HelloNode
查看>>
NOIp2005 过河
查看>>
NOPI读取Excel
查看>>
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
查看>>
npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
查看>>
npm run build部署到云服务器中的Nginx(图文配置)
查看>>
npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
查看>>
npm切换到淘宝源
查看>>
npm前端包管理工具简介---npm工作笔记001
查看>>
npm和yarn清理缓存命令
查看>>
npm和yarn的使用对比
查看>>
npm报错unable to access ‘https://github.com/sohee-lee7/Squire.git/‘
查看>>
npm的问题:config global `--global`, `--local` are deprecated. Use `--location=global` instead 的解决办法
查看>>
NPOI之Excel——合并单元格、设置样式、输入公式
查看>>
NPOI利用多任务模式分批写入多个Excel
查看>>
NR,NF,FNR
查看>>
nrf开发笔记一开发软件
查看>>