0
내 카메라 라이브 소프트웨어에서 FFmpeg (3.4) h264_qsv 인코더를 사용하면 40 프레임을 전송 한 후 인코딩 된 데이터가 수신되는 것으로 나타났습니다! 약 1.5 초의 대기 시간이 있습니다. 실시간 상황에 대해 유익하지 않습니다. 인코더를 구성하는 방법은 무엇입니까? 고마워.FFmpeg h264_qsv 인코더의 대기 시간을 줄이는 방법은 무엇입니까?
내 코드 : Mulvya의 팁
AVCodecContext* OpenH264Codec(int width, int height, int bitrate, int framerate)
{
AVCodecContext* ctx = 0;
AVCodec* c = 0;
c = avcodec_find_encoder_by_name("h264_qsv");
if (c == NULL) return NULL;
ctx = avcodec_alloc_context3(c);
if (ctx == NULL) return NULL;
ctx->width = width;
ctx->height = height;
ctx->pix_fmt = c->pix_fmts[0];
ctx->bit_rate = bitrate;
ctx->bit_rate_tolerance = ctx->bit_rate/2;
ctx->rc_min_rate = 32000;
ctx->rc_max_rate = ctx->bit_rate*1.5;
ctx->time_base.den = framerate;
ctx->time_base.num = 1;
ctx->framerate.den = 1;
ctx->framerate.num = framerate;
ctx->gop_size = framerate*5;
ctx->max_b_frames = 0;
av_opt_set(ctx->priv_data, "preset", "veryfast", 0);
av_opt_set(ctx->priv_data, "avbr_accuracy", "1", 0);
av_opt_set(ctx->priv_data, "async_depth", "1", 0);
av_opt_set(ctx->priv_data, "profile", "main", 0);
ctx->flags |= AV_CODEC_FLAG_QSCALE;
if (avcodec_open2(ctx, c, 0) < 0)
{
avcodec_free_context(&ctx);
return NULL;
}
return ctx;
}
아마도 미리보기와 관련이 있습니다. – Mulvya
당신은 내 큰 문제를 slove! 대단히 감사합니다 !! –