DTS、PTS
FFmpeg中获取PTS:
- AVPacket中
- AVFrame中(其获取PTS的av_frame_get_best_effort_timestamp已经弃用且不需要使用)
时间基
相关计算公式:
1 2 3 4
| time_in_seconds = pts * av_q2d(time_base)
timestamp = timebase * time_in_seconds
|
FFmpeg内部的时间基:AV_TIME_BASE
1 2 3 4 5
| #define AV_TIME_BASE 1000000
#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
|
相关定义与转换函数。
1 2 3 4 5 6 7 8 9 10 11 12 13
| typedef struct AVRational{ int num; int den; } AVRational;
static inline double av_q2d(AVRational a){ return a.num / (double) a.den; }
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq);
|