Skip to content

Commit

Permalink
Fix jpeg encode error and ffmpeg param checking (#319)
Browse files Browse the repository at this point in the history
* Fix exit fail when poll error

* Flush cache for jpeg cmdlist

* ffmpeg paramter check

* Remove limitation

Co-authored-by: zhangxiaojingCAN <104607452+zhangxiaojingCAN@users.noreply.github.com>
  • Loading branch information
longyiluo and zhangxiaojingCAN authored Sep 15, 2022
1 parent fdc2769 commit 8691100
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
13 changes: 10 additions & 3 deletions package/encode_app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,15 @@ static void *v4l2_output(void *arg)
iRet = poll(tFds, 1, /*-1*/3000);//3000ms
if (iRet <= 0)
{
printf("poll error!\n");
continue;
printf("ch %d: poll error!\n", channel);

if(received_sigterm == 1)
{
sem_post(&pCtx->pSemGetData[channel]);
break;
}
else
continue;
}

struct v4l2_buffer buf;
Expand Down Expand Up @@ -511,7 +518,7 @@ static void *v4l2_output(void *arg)

if(pCtx->v4l2_rev[channel][pCtx->v4l2_wp[channel]].addr != V4L2_INVALID_INDEX)
{
printf("v4l2 buffer overflow\n");
printf("ch %d: v4l2 buffer overflow\n", channel);
enqueue_buf(buf.index, channel);
}
else if(time - start_time < 1000000000)
Expand Down
13 changes: 13 additions & 0 deletions package/ffmpeg_canaan/0035-buildroot-ffmpeg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Index: b/libavcodec/libk510_h264.c
===================================================================
--- a/libavcodec/libk510_h264.c
+++ b/libavcodec/libk510_h264.c
@@ -409,7 +409,7 @@ static const AVOption options[] =
//{ option name, description, offset in the context object, type default, min, max, flags, unit}
// ***** GOP options ******
{ "g", "Set gop size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 25}, 0, 1000, FLAGS },
- { "b", "Set video bitrate", OFFSET(bit_rate), AV_OPT_TYPE_INT, {.i64 = 4000000}, 0, 20000000, FLAGS },
+ { "b", "Set video bitrate", OFFSET(bit_rate), AV_OPT_TYPE_INT, {.i64 = 4000000}, 1000, 20000000, FLAGS },
{ "r", "Set video framerate", OFFSET(framerate), AV_OPT_TYPE_INT, {.i64 = 30}, 30, 30, FLAGS },
{ "ch", "Set encode channel ", OFFSET(channel), AV_OPT_TYPE_INT, {.i64 = 0}, 0, (VENC_MAX_CHANNELS-1), FLAGS },
{ "idr_freq", "IDR frequency. -1=No IDRs", OFFSET(idrFreq), AV_OPT_TYPE_INT, {.i64 = 25 }, -1, 256, FLAGS },
Binary file modified package/venc_lib/src/libvenc.so
Binary file not shown.

0 comments on commit 8691100

Please sign in to comment.