關於 ffmpeg 中av_rescale_rnd 和avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, 的含義

int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,  enum AVRounding) av_const;

這個函數在ffmpeg中主要是將編碼視頻的pts等由原來的容器中規定的轉化爲現在容器規定的大小,總的來說是這樣的: 

                                                a*bq/cq;

本人在代碼中是這樣用的:

npkt.pts=av_rescale_q_rnd(npkt.pts,instream->time_base,outstream->time_base,AV_ROUND_NEAR_INF);

其中time_base結構是這樣的:

                                   den,num;

den是分母,num是分子,num/den是1/幀率;

int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,const AVFrame *frame, int *got_packet_ptr);

是將幀frame編碼爲avpkt遵照AVCodecContext 格式。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章