[FFmpeg-devel,04/25] avcodec/v4l2_m2m_enc: add support for -force_key_frames

Submitted by Aman Gupta on Sept. 3, 2019, 1:02 a.m.

Details

Message ID 20190903010230.96236-5-ffmpeg@tmm1.net
State Accepted
Commit ab4835f41885c0f2e2f75101d72b888557c0e284
Headers show

Commit Message

Aman Gupta Sept. 3, 2019, 1:02 a.m.
From: Aman Gupta <aman@tmm1.net>

Signed-off-by: Aman Gupta <aman@tmm1.net>
---
 libavcodec/v4l2_m2m_enc.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Guo, Yejun Sept. 12, 2019, 10:45 a.m.
hi

> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of

> Aman Gupta

> Sent: Tuesday, September 03, 2019 9:02 AM

> To: ffmpeg-devel@ffmpeg.org

> Cc: lorusak@gmail.com; Aman Gupta <ffmpeg@tmm1.net>;

> jorge.ramirez.ortiz@gmail.com; Aman Gupta <aman@tmm1.net>

> Subject: [FFmpeg-devel] [PATCH 04/25] avcodec/v4l2_m2m_enc: add support

> for -force_key_frames

> 

> From: Aman Gupta <aman@tmm1.net>

> 

> Signed-off-by: Aman Gupta <aman@tmm1.net>

> ---

>  libavcodec/v4l2_m2m_enc.c | 3 +++

>  1 file changed, 3 insertions(+)

> 

> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c

> index 27bb254fc1..a0d5bcf760 100644

> --- a/libavcodec/v4l2_m2m_enc.c

> +++ b/libavcodec/v4l2_m2m_enc.c

> @@ -245,6 +245,9 @@ static int v4l2_send_frame(AVCodecContext *avctx,

> const AVFrame *frame)

>      V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;

>      V4L2Context *const output = &s->output;

> 

> +    if (frame && frame->pict_type == AV_PICTURE_TYPE_I)

> +        v4l2_set_ext_ctrl(s, MPEG_CID(FORCE_KEY_FRAME), 0, "force key

> frame");

> +


looks that a version check is needed here. seems that this macro is introduced by https://patchwork.kernel.org/patch/8058501/. 

There is build error on my machine after I rebase master.

src/libavcodec/v4l2_m2m_enc.c: In function ‘v4l2_set_ext_ctrl’:
src/libavcodec/v4l2_m2m_enc.c:51:12: warning: braces around scalar initializer
     struct v4l2_ext_controls ctrls = { { 0 } };
            ^
src/libavcodec/v4l2_m2m_enc.c:51:12: note: (near initialization for ‘ctrls.ctrl_class’)
src/libavcodec/v4l2_m2m_enc.c: In function ‘v4l2_get_ext_ctrl’:
src/libavcodec/v4l2_m2m_enc.c:71:12: warning: braces around scalar initializer
     struct v4l2_ext_controls ctrls = { { 0 } };
            ^
src/libavcodec/v4l2_m2m_enc.c:71:12: note: (near initialization for ‘ctrls.ctrl_class’)
src/libavcodec/v4l2_m2m_enc.c: In function ‘v4l2_send_frame’:
src/libavcodec/v4l2_m2m_enc.c:34:21: error: ‘V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME’ undeclared (first use in this function)
 #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x
                     ^
src/libavcodec/v4l2_m2m_enc.c:249:30: note: in expansion of macro ‘MPEG_CID’
         v4l2_set_ext_ctrl(s, MPEG_CID(FORCE_KEY_FRAME), 0, "force key frame");
                              ^
src/libavcodec/v4l2_m2m_enc.c:34:21: note: each undeclared identifier is reported only once for each function it appears in
 #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x
                     ^
src/libavcodec/v4l2_m2m_enc.c:249:30: note: in expansion of macro ‘MPEG_CID’
         v4l2_set_ext_ctrl(s, MPEG_CID(FORCE_KEY_FRAME), 0, "force key frame");
                              ^
src/ffbuild/common.mak:59: recipe for target 'libavcodec/v4l2_m2m_enc.o' failed
make: *** [libavcodec/v4l2_m2m_enc.o] Error 1
make: *** Waiting for unfinished jobs....


>      return ff_v4l2_context_enqueue_frame(output, frame);

>  }

> 

> --

> 2.20.1

> 

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

> 

> To unsubscribe, visit link above, or email

> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Patch hide | download patch | download mbox

diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 27bb254fc1..a0d5bcf760 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -245,6 +245,9 @@  static int v4l2_send_frame(AVCodecContext *avctx, const AVFrame *frame)
     V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
     V4L2Context *const output = &s->output;
 
+    if (frame && frame->pict_type == AV_PICTURE_TYPE_I)
+        v4l2_set_ext_ctrl(s, MPEG_CID(FORCE_KEY_FRAME), 0, "force key frame");
+
     return ff_v4l2_context_enqueue_frame(output, frame);
 }