應用X264進(jìn)行H.264編碼,如果編碼不能成功,大部分情況是編碼參數選擇不正確
這里邊的編碼參數大家應該看到了吧,那么如果我們用ffmpeg怎么設置這些編碼參數呢?
代碼為證:
- m_VCtx->codec_type = CODEC_TYPE_VIDEO;
- m_VCtx->bit_rate = bitrate * 1000;
- m_VCtx->width = width;
- m_VCtx->height = height;
- m_VCtx->time_base.den = fps;
- m_VCtx->time_base.num = 1;
- m_VCtx->gop_size = fps * 10;
-
- m_VCtx->crf = 26;
- m_VCtx->refs = 3;
- m_VCtx->flags2 = CODEC_FLAG2_MIXED_REFS;
- m_VCtx->max_b_frames = 3;
- m_VCtx->deblockbeta = -1;
- m_VCtx->deblockalpha = -1;
- m_VCtx->trellis = 2;
- m_VCtx->partitions = X264_PART_I4X4 | X264_PART_I8X8 | X264_PART_P8X8 | X264_PART_P4X4 | X264_PART_B8X8;
- m_VCtx->flags2 |= CODEC_FLAG2_8X8DCT;
- m_VCtx->me_method = 8;
- m_VCtx->me_range = 16;
- m_VCtx->me_subpel_quality = 7;
- m_VCtx->qmin = 10;
- m_VCtx->qmax = 51;
- m_VCtx->rc_initial_buffer_occupancy = 0.9;
- m_VCtx->i_quant_factor = 1.0 / 1.40f;
- m_VCtx->b_quant_factor = 1.30f;
- m_VCtx->chromaoffset = 0;
- m_VCtx->max_qdiff = 4;
- m_VCtx->qcompress = 0.6f;
- m_VCtx->complexityblur = 20.0f;
- m_VCtx->qblur = 0.5f;
- m_VCtx->directpred = 1;
- m_VCtx->noise_reduction = 0;
- m_VCtx->pix_fmt = PIX_FMT_YUV420P;
-
- m_VCtx->thread_count = 1;
- m_VCtx->scenechange_threshold = 40;
- m_VCtx->bframebias = 0;
- m_VCtx->flags2 |= CODEC_FLAG2_AUD;
- m_VCtx->coder_type = FF_CODER_TYPE_AC;
- m_VCtx->flags |= CODEC_FLAG_LOOP_FILTER;
- m_VCtx->me_cmp = FF_CMP_CHROMA;
- m_VCtx->flags2 |= CODEC_FLAG2_FASTPSKIP;
- m_VCtx->flags2 |= CODEC_FLAG2_BPYRAMID;
- m_VCtx->flags2 |= CODEC_FLAG_NORMALIZE_AQP;
- m_VCtx->flags2 |= CODEC_FLAG2_WPRED;
- m_VCtx->keyint_min = 25;
- m_VCtx->flags2 |= CODEC_FLAG2_MBTREE;
-
-
-
-
-
-
-
-
-
-
- m_VCtx->level = 30;
- m_VCtx->b_frame_strategy = 2;
- m_VCtx->codec_tag = 7;
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請
點(diǎn)擊舉報。