ffmpeg: v4l2_m2m: fix output media file missing keyframe at timestamp 0

This commit is contained in:
Joo Aun Saw 2019-08-19 15:41:56 +10:00
parent 65f2815773
commit 74f5b58d94
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,19 @@
commit e370306deb9c48f4daa4ae4d622a7bd8b3828bef
Author: Joo Aun Saw <jasaw@dius.com.au>
Date: Mon Aug 19 15:20:52 2019 +1000
avcodec/v4l2_m2m_enc: use joined with 1st frame header mode
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 354d78babb..32aaaf18fb 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -174,7 +174,7 @@ static int v4l2_prepare_encoder(V4L2m2mContext *s)
v4l2_set_timeperframe(s, avctx->framerate.num, avctx->framerate.den);
/* set ext ctrls */
- v4l2_set_ext_ctrl(s, MPEG_CID(HEADER_MODE), MPEG_VIDEO(HEADER_MODE_SEPARATE), "header mode");
+ v4l2_set_ext_ctrl(s, MPEG_CID(HEADER_MODE), MPEG_VIDEO(HEADER_MODE_JOINED_WITH_1ST_FRAME), "header mode");
/* enable bit rate control */
if (avctx->bit_rate > 1) {
v4l2_set_ext_ctrl(s, MPEG_CID(FRAME_RC_ENABLE) , 1, "rate control");

View File

@ -0,0 +1,30 @@
commit 05ee1b8f65e4029fcad832743701712a1a000ea3
Author: Joo Aun Saw <jasaw@dius.com.au>
Date: Mon Aug 19 15:21:30 2019 +1000
avcodec/v4l2: add timeout when dequeueing buffers
Add timeout to prevent lock up when buffer queue is empty.
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index efcb0426e4..8f9420e28d 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -580,7 +580,7 @@ int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame)
* 1. decoded frame available
* 2. an input buffer is ready to be dequeued
*/
- avbuf = v4l2_dequeue_v4l2buf(ctx, -1);
+ avbuf = v4l2_dequeue_v4l2buf(ctx, ctx_to_m2mctx(ctx)->draining ? -1 : 200);
if (!avbuf) {
if (ctx->done)
return AVERROR_EOF;
@@ -600,7 +600,7 @@ int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt)
* 1. encoded packet available
* 2. an input buffer ready to be dequeued
*/
- avbuf = v4l2_dequeue_v4l2buf(ctx, -1);
+ avbuf = v4l2_dequeue_v4l2buf(ctx, ctx_to_m2mctx(ctx)->draining ? -1 : 200);
if (!avbuf) {
if (ctx->done)
return AVERROR_EOF;