ffmpeg H264 编解码配置
生活随笔
收集整理的這篇文章主要介紹了
ffmpeg H264 编解码配置
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
ffmpeg H264編解碼前面有文章介紹下,本文主要介紹一些參數(shù)配置。
編碼:
int InitEncoderCodec( int iWidth, int iHeight) {AVCodec * pH264Codec = avcodec_find_encoder(AV_CODEC_ID_H264);if(NULL == pH264Codec){printf("%s", "avcodec_find_encoder failed");return -1;}outPutEncContext = avcodec_alloc_context3(pH264Codec);outPutEncContext->gop_size = 30;outPutEncContext->has_b_frames = 0;outPutEncContext->max_b_frames = 0;outPutEncContext->codec_id = pH264Codec->id;outPutEncContext->time_base.num = 2;outPutEncContext->time_base.den = 15;outPutEncContext->pix_fmt = *pH264Codec->pix_fmts;outPutEncContext->width = iWidth;outPutEncContext->height = iHeight;outPutEncContext->qmin = 34;outPutEncContext->qmax = 50;AVDictionary *options = nullptr;outPutEncContext->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; av_opt_set(outPutEncContext->priv_data,"tune","zerolatency",0);av_dict_set(&options,"preset","ultrafast",0);int ret = avcodec_open2(outPutEncContext, pH264Codec, &options);if (ret < 0){printf("%s", "open codec failed");return ret;}return 1; }
?解碼:
codecContext->flags |=CODEC_FLAG_LOW_DELAY;
編碼codec?的time_base實際上表示視頻的幀率,qmin,qmax決定了編碼的質量,qmin,qmax越大編碼的質量越差。zerolatency參數(shù)的作用是提搞編碼的實時性。
解碼codec?加上CODEC_FLAG_LOW_DELAY,可提高解碼速度(低延時)。
?視頻教程 播放地址: http://www.iqiyi.com/u/1426749687
轉載于:https://www.cnblogs.com/wanggang123/p/6346787.html
總結
以上是生活随笔為你收集整理的ffmpeg H264 编解码配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一直出现 Enter passphras
- 下一篇: 精通移动端布局 - 概念篇 -