编码开始延迟一帧输出 #218

Closed
opened 2025-12-23 10:36:15 +01:00 by backuprepo · 3 comments
Owner

Originally created by @changliwu on GitHub (Sep 30, 2025).

编码帧率为2帧,开始时延迟一帧输出,如下:

                   pts(间隔)

input encode 129600(0)
input encode 176400(520)
output encode 129600(0) 1
input encode 219600(480)
output encode 176400(520) 0
input encode 266400(520)
output encode 219600(480) 0
input encode 309600(480)
output encode 266400(520) 0
input encode 356400(520)
output encode 309600(480) 0

h265编码,参数设置如下:
m_pRKEncodecCtx->pix_fmt = AV_PIX_FMT_DRM_PRIME;
m_pRKEncodecCtx->width = m_nDstW;
m_pRKEncodecCtx->height = m_nDstH;
m_pRKEncodecCtx->coded_width = m_nDstW;
m_pRKEncodecCtx->coded_height = m_nDstH;
m_pRKEncodecCtx->time_base = av_make_q(1,2);//pV.time_base;
m_pRKEncodecCtx->framerate = av_make_q(2,1);
m_pRKEncodecCtx->gop_size = m_nGopSize;
m_pRKEncodecCtx->max_b_frames = 0;

av_opt_set(m_pRKEncodecCtx->priv_data, "profile", "main", 0);
av_opt_set(m_pRKEncodecCtx->priv_data, "qp_init", "24", 0);//25
av_opt_set(m_pRKEncodecCtx->priv_data, "rc_mode", "CQP", 0);
av_opt_set(m_pRKEncodecCtx->priv_data, "afbc", "1", 0);

请问如何设置才能没有一帧延迟,即编码立即输出

Originally created by @changliwu on GitHub (Sep 30, 2025). 编码帧率为2帧,开始时延迟一帧输出,如下: pts(间隔) input encode 129600(0) input encode 176400(520) output encode 129600(0) 1 input encode 219600(480) output encode 176400(520) 0 input encode 266400(520) output encode 219600(480) 0 input encode 309600(480) output encode 266400(520) 0 input encode 356400(520) output encode 309600(480) 0 h265编码,参数设置如下: m_pRKEncodecCtx->pix_fmt = AV_PIX_FMT_DRM_PRIME; m_pRKEncodecCtx->width = m_nDstW; m_pRKEncodecCtx->height = m_nDstH; m_pRKEncodecCtx->coded_width = m_nDstW; m_pRKEncodecCtx->coded_height = m_nDstH; m_pRKEncodecCtx->time_base = av_make_q(1,2);//pV.time_base; m_pRKEncodecCtx->framerate = av_make_q(2,1); m_pRKEncodecCtx->gop_size = m_nGopSize; m_pRKEncodecCtx->max_b_frames = 0; av_opt_set(m_pRKEncodecCtx->priv_data, "profile", "main", 0); av_opt_set(m_pRKEncodecCtx->priv_data, "qp_init", "24", 0);//25 av_opt_set(m_pRKEncodecCtx->priv_data, "rc_mode", "CQP", 0); av_opt_set(m_pRKEncodecCtx->priv_data, "afbc", "1", 0); 请问如何设置才能没有一帧延迟,即编码立即输出
backuprepo 2025-12-23 10:36:15 +01:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@nyanmisaka commented on GitHub (Sep 30, 2025):

Use -flags +low_delay to disable async encoding.

https://github.com/nyanmisaka/ffmpeg-rockchip/wiki/Encoder#test-encoders

bc561013c9/libavcodec/avcodec.h (L314)

@nyanmisaka commented on GitHub (Sep 30, 2025): Use `-flags +low_delay` to disable async encoding. https://github.com/nyanmisaka/ffmpeg-rockchip/wiki/Encoder#test-encoders https://github.com/FFmpeg/FFmpeg/blob/bc561013c9a809a90c0d1b84413814ba612f7c44/libavcodec/avcodec.h#L314
Author
Owner

@changliwu commented on GitHub (Oct 9, 2025):

h265编码时,我这样设置的 av_opt_set(m_pRKEncodecCtx->priv_data,"flags","+low_delay",0),但是输出没起作用,请问哪里有问题吗?

@changliwu commented on GitHub (Oct 9, 2025): h265编码时,我这样设置的 av_opt_set(m_pRKEncodecCtx->priv_data,"flags","+low_delay",0),但是输出没起作用,请问哪里有问题吗?
Author
Owner

@changliwu commented on GitHub (Oct 9, 2025):

我按照下面的方法设置,可以了,谢谢!
m_pRKEncodecCtx->flags |= AV_CODEC_FLAG_LOW_DELAY;
av_opt_set(m_pRKEncodecCtx->priv_data, "preset", "fast", 0);
av_opt_set(m_pRKEncodecCtx->priv_data, "tune", "zerolatency", 0);

@changliwu commented on GitHub (Oct 9, 2025): 我按照下面的方法设置,可以了,谢谢! m_pRKEncodecCtx->flags |= AV_CODEC_FLAG_LOW_DELAY; av_opt_set(m_pRKEncodecCtx->priv_data, "preset", "fast", 0); av_opt_set(m_pRKEncodecCtx->priv_data, "tune", "zerolatency", 0);
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: starred/ffmpeg-rockchip#218
No description provided.