ffmpeg # 各种封装格式的time_base

封装层的time_base

ffmpeg # 各种封装格式的time_base_第1张图片
image.png
ffmpeg code
  • TS
    mpegts.c中:
    avpriv_set_pts_info(st, 33, 1, 90000);

mpegtsenc.c中

        avpriv_set_pts_info(st, 33, 1, 90000);
  • mp4
    mov.c中
    avpriv_set_pts_info(st, 64, 1, sc->time_scale);

其出处:

static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)

{
...
    sc->time_scale = avio_rb32(pb);
    if (sc->time_scale <= 0) {
        av_log(c->fc, AV_LOG_ERROR, "Invalid mdhd time scale %d, defaulting to 1\n", sc->time_scale);
        sc->time_scale = 1;
    }
...
}

movenc.c中

        avpriv_set_pts_info(st, 64, 1, track->timescale);

  • flv
    flvdec.c中
    avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */

flvenc.c中

        avpriv_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */

  • mkv
    matroskadec.c中
        avpriv_set_pts_info(st, 64, matroska->time_scale * track->time_scale,
                            1000 * 1000 * 1000);    /* 64 bit pts in ns */

matroskaenc.c

    for (i = 0; i < s->nb_streams; i++) {
        // ms precision is the de-facto standard timescale for mkv files
        avpriv_set_pts_info(s->streams[i], 64, 1, 1000);
    }

可见 mux时,ffmpeg的输出 mkv的time_base为{1, 1000}

协议或例子
  • TS
ffmpeg # 各种封装格式的time_base_第2张图片
image.png

ffmpeg # 各种封装格式的time_base_第3张图片
image.png

TS格式的pts和dts单位是90000

  • flv
ffmpeg # 各种封装格式的time_base_第4张图片
image.png

flv的时间戳单位为ms

  • mp4


    ffmpeg # 各种封装格式的time_base_第5张图片
    帧率
ffmpeg # 各种封装格式的time_base_第6张图片
image.png
ffmpeg # 各种封装格式的time_base_第7张图片
image.png
ffmpeg # 各种封装格式的time_base_第8张图片
image.png

References:

https://blog.csdn.net/zhuweigangzwg/article/details/64919706
https://www.jianshu.com/p/bf323cee3b8e
https://blog.csdn.net/achang21/article/details/77890961
http://www.samirchen.com/ffmpeg-tutorial-7/
https://blog.csdn.net/TopsLuo/article/details/77981732
https://blog.csdn.net/peckjerry/article/details/48344389

你可能感兴趣的:(ffmpeg # 各种封装格式的time_base)