FFmpeg 视频编码器参数一般设置

 AVCodec* codec = avcodec_find_encoder(AV_CODEC_ID_H264);//编码格式
 m_pVideoCodecCtx = avcodec_alloc_context3(codec);
 if (!m_pVideoCodecCtx){
 m_pVideoCodecCtx->width = m_videoOutWidth;//视频宽度
 m_pVideoCodecCtx->height = m_video0utHeight;//视频高度
 m_pVideoCodecCtx->time_base = (AVRational){1,30};//时间基
 m_pVideoCodecCtx->gop_size = 20;//gop序列 I帧跨度
 m_pVideoCodecCtx->max_b_frames = 0;//设置B帧为0 一般用于直播
 m_pVideoCodecCtx->pix_fmt = AV_PIX_FMT_YUV420P;//像素格式
 m_pVideoCodecCtx->codec_id = AV_CODEC_ID_H264;//编码器id
 }
 //av_opt_set (m_pVideoCodecCtx->priv_data,"preset","superfast",0);
 m_pVideoCodecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;//全局的header

 int ret = avcodec_open2(m_pVideoCodecCtx,codec, NULL);
 m_pVideoStream = avformat_new_stream(m_pFormatCtx,NULL);//new一个视频的流
 m_pVideoStream->codecpar->codec_tag = 0;
 avcodec_parameters_from_context (m_pVideoStream->codecpar,m_pVideoCodecCtx);//将参数拷贝到视频流信息中

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Rnwater

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值