mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Set I frame max qp to 22 for nvidia encoder
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#define SAVE_DECODER_STREAM 1
|
||||
#define SAVE_DECODER_STREAM 0
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#define SAVE_DECODER_STREAM 1
|
||||
#define SAVE_DECODER_STREAM 0
|
||||
|
||||
NvidiaVideoDecoder::NvidiaVideoDecoder() {}
|
||||
NvidiaVideoDecoder::~NvidiaVideoDecoder() {
|
||||
@@ -51,7 +51,7 @@ int NvidiaVideoDecoder::Decode(
|
||||
}
|
||||
|
||||
if ((*(data + 4) & 0x1f) == 0x07) {
|
||||
// LOG_WARN("Receive key frame");
|
||||
LOG_WARN("Receive key frame");
|
||||
}
|
||||
|
||||
int num_frame_returned = decoder->Decode(data, size);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "video_decoder_factory.h"
|
||||
|
||||
#include "ffmpeg/ffmpeg_video_decoder.h"
|
||||
#include "log.h"
|
||||
#include "nvcodec/nvidia_video_decoder.h"
|
||||
|
||||
VideoDecoderFactory::VideoDecoderFactory() {}
|
||||
@@ -26,6 +27,9 @@ bool VideoDecoderFactory::CheckIsHardwareAccerlerationSupported() {
|
||||
CUvideoctxlock cudaCtxLock;
|
||||
cuResult = cuvidCtxLockCreate(&cudaCtxLock, 0);
|
||||
if (cuResult != CUDA_SUCCESS) {
|
||||
LOG_WARN(
|
||||
"System not support hardware accelerated decode, use default software "
|
||||
"decoder");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#define SAVE_ENCODER_STREAM 1
|
||||
#define SAVE_ENCODER_STREAM 0
|
||||
|
||||
FFmpegVideoEncoder::FFmpegVideoEncoder() {}
|
||||
FFmpegVideoEncoder::~FFmpegVideoEncoder() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#define SAVE_ENCODER_STREAM 1
|
||||
#define SAVE_ENCODER_STREAM 0
|
||||
|
||||
NvidiaVideoEncoder::NvidiaVideoEncoder() {}
|
||||
NvidiaVideoEncoder::~NvidiaVideoEncoder() {
|
||||
@@ -50,14 +50,15 @@ int NvidiaVideoEncoder::Init() {
|
||||
init_params.encodeConfig->profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID;
|
||||
init_params.encodeConfig->encodeCodecConfig.h264Config.level =
|
||||
NV_ENC_LEVEL::NV_ENC_LEVEL_H264_31;
|
||||
// TO TEST: not tested yet
|
||||
// init_params.encodeConfig->gopLength = NVENC_INFINITE_GOPLENGTH;
|
||||
init_params.encodeConfig->gopLength = keyFrameInterval_;
|
||||
// Do not use B-frame for realtime application
|
||||
init_params.encodeConfig->frameIntervalP = 1;
|
||||
init_params.encodeConfig->rcParams.rateControlMode =
|
||||
NV_ENC_PARAMS_RC_MODE::NV_ENC_PARAMS_RC_CBR;
|
||||
NV_ENC_PARAMS_RC_MODE::NV_ENC_PARAMS_RC_VBR;
|
||||
init_params.encodeConfig->rcParams.maxBitRate = maxBitrate_ * 500;
|
||||
// init_params.encodeConfig->rcParams.enableMinQP = 1;
|
||||
// init_params.encodeConfig->rcParams.minQP.qpIntra = 10;
|
||||
init_params.encodeConfig->rcParams.enableMaxQP = 1;
|
||||
init_params.encodeConfig->rcParams.maxQP.qpIntra = 22;
|
||||
init_params.encodeConfig->encodeCodecConfig.h264Config.sliceMode = 1;
|
||||
init_params.encodeConfig->encodeCodecConfig.h264Config.sliceModeData =
|
||||
max_payload_size_;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "video_encoder_factory.h"
|
||||
|
||||
#include "ffmpeg/ffmpeg_video_encoder.h"
|
||||
#include "log.h"
|
||||
#include "nvcodec/nvidia_video_encoder.h"
|
||||
|
||||
VideoEncoderFactory::VideoEncoderFactory() {}
|
||||
@@ -26,11 +27,17 @@ bool VideoEncoderFactory::CheckIsHardwareAccerlerationSupported() {
|
||||
|
||||
cuResult = cuInit(0);
|
||||
if (cuResult != CUDA_SUCCESS) {
|
||||
LOG_WARN(
|
||||
"System not support hardware accelerated encode, use default software "
|
||||
"encoder");
|
||||
return false;
|
||||
}
|
||||
|
||||
NVENCSTATUS nvEncStatus = NvEncodeAPICreateInstance(&functionList);
|
||||
if (nvEncStatus != NV_ENC_SUCCESS) {
|
||||
LOG_WARN(
|
||||
"System not support hardware accelerated encode, use default software "
|
||||
"encoder");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user