最近項目需要錄制攝像機拍攝的視頻,使用h264編碼。測試發現h264編碼2k(1980×1080)視頻還算流暢,但編碼4k(3840×4120)視頻出現明顯卡頓丟幀現象。因此考慮使用h264 nvenc硬件編碼。 將原本代碼
AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H264);改為
AVCodec * codec = avcodec_find_encoder_by_name("nvenc_h264");即可實現h264 nvenc硬件編碼。 較CPU編碼,h264 nvenc硬件編碼的4k視頻明顯流暢許多,丟幀現象大幅減少。
新聞熱點
疑難解答