From fb22771b70bd73579079da97f38cde4f66d1ca48 Mon Sep 17 00:00:00 2001 From: popoviciri Date: Sun, 29 Sep 2019 21:36:08 +0200 Subject: [PATCH] update motion --- .../motion/0001-enable-awb-greyworld.patch | 35 --- .../motion/0001-fix_bitrate_overflow.patch | 13 - package/motion/0001-without-nls.patch | 51 ++++ .../motion/0002-enable-h264-omx-codec.patch | 17 ++ package/motion/0002-enable-h264-v4l2m2m.patch | 233 ------------------ .../0003-ensure-first-frame-pts-zero.patch | 23 -- ...01-decouple-avcodec-send-and-receive.patch | 202 --------------- package/motion/enable-h264-omx-codec.patch | 13 - package/motion/motion.hash | 2 + package/motion/motion.mk | 13 +- 10 files changed, 75 insertions(+), 527 deletions(-) delete mode 100644 package/motion/0001-enable-awb-greyworld.patch delete mode 100644 package/motion/0001-fix_bitrate_overflow.patch create mode 100644 package/motion/0001-without-nls.patch create mode 100644 package/motion/0002-enable-h264-omx-codec.patch delete mode 100644 package/motion/0002-enable-h264-v4l2m2m.patch delete mode 100644 package/motion/0003-ensure-first-frame-pts-zero.patch delete mode 100644 package/motion/1001-decouple-avcodec-send-and-receive.patch delete mode 100644 package/motion/enable-h264-omx-codec.patch diff --git a/package/motion/0001-enable-awb-greyworld.patch b/package/motion/0001-enable-awb-greyworld.patch deleted file mode 100644 index 1fcb219f69..0000000000 --- a/package/motion/0001-enable-awb-greyworld.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/raspicam/RaspiCamControl.c b/raspicam/RaspiCamControl.c -index 073d657..ad0e405 100644 ---- a/raspicam/RaspiCamControl.c -+++ b/raspicam/RaspiCamControl.c -@@ -73,7 +73,8 @@ static XREF_T awb_map[] = - {"fluorescent", MMAL_PARAM_AWBMODE_FLUORESCENT}, - {"incandescent", MMAL_PARAM_AWBMODE_INCANDESCENT}, - {"flash", MMAL_PARAM_AWBMODE_FLASH}, -- {"horizon", MMAL_PARAM_AWBMODE_HORIZON} -+ {"horizon", MMAL_PARAM_AWBMODE_HORIZON}, -+ {"greyworld", MMAL_PARAM_AWBMODE_GREYWORLD} - }; - - static const int awb_map_size = sizeof(awb_map) / sizeof(awb_map[0]); -@@ -1196,6 +1197,7 @@ int raspicamcontrol_set_exposure_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOS - * - MMAL_PARAM_AWBMODE_INCANDESCENT, - * - MMAL_PARAM_AWBMODE_FLASH, - * - MMAL_PARAM_AWBMODE_HORIZON, -+ * - MMAL_PARAM_AWBMODE_GREYWORLD, - * @return 0 if successful, non-zero if any parameters out of range - */ - int raspicamcontrol_set_awb_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_AWBMODE_T awb_mode) -diff --git a/raspicam/RaspiCamControl.h b/raspicam/RaspiCamControl.h -index f4c189a..e7a847f 100644 ---- a/raspicam/RaspiCamControl.h -+++ b/raspicam/RaspiCamControl.h -@@ -57,6 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - MMAL_PARAM_AWBMODE_INCANDESCENT, - MMAL_PARAM_AWBMODE_FLASH, - MMAL_PARAM_AWBMODE_HORIZON, -+ MMAL_PARAM_AWBMODE_GREYWORLD, - * - * Image FX - MMAL_PARAM_IMAGEFX_NONE, - diff --git a/package/motion/0001-fix_bitrate_overflow.patch b/package/motion/0001-fix_bitrate_overflow.patch deleted file mode 100644 index 598131d14e..0000000000 --- a/package/motion/0001-fix_bitrate_overflow.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/ffmpeg.c b/ffmpeg.c -index a8afa6e..3f731ca 100644 ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -558,7 +558,7 @@ static int ffmpeg_set_quality(struct ffmpeg *ffmpeg){ - if ((strcmp(ffmpeg->codec->name, "h264_omx") == 0) || (strcmp(ffmpeg->codec->name, "mpeg4_omx") == 0)) { - // H264 OMX encoder quality can only be controlled via bit_rate - // bit_rate = ffmpeg->width * ffmpeg->height * ffmpeg->fps * quality_factor -- ffmpeg->quality = (ffmpeg->width * ffmpeg->height * ffmpeg->fps * ffmpeg->quality) >> 7; -+ ffmpeg->quality = (int)(((int64_t)ffmpeg->width * ffmpeg->height * ffmpeg->fps * ffmpeg->quality) >> 7); - // Clip bit rate to min - if (ffmpeg->quality < 4000) // magic number - ffmpeg->quality = 4000; diff --git a/package/motion/0001-without-nls.patch b/package/motion/0001-without-nls.patch new file mode 100644 index 0000000000..543c59285a --- /dev/null +++ b/package/motion/0001-without-nls.patch @@ -0,0 +1,51 @@ +gist 4d213af40bb4786c3a51535bf7cc1fdd +Author: Mr-DaveDev +Date: Thu Sep 29 22:07:12 2019 + +diff --git a/Makefile.am b/Makefile.am +index ecc20f1..8b262c0 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -1,6 +1,4 @@ +-ACLOCAL_AMFLAGS = -I m4 +- +-SUBDIRS = src po man ++SUBDIRS = src man + + sysconfdir = @sysconfdir@/$(PACKAGE) + sysconf_DATA = \ +diff --git a/configure.ac b/configure.ac +index 6ee2554..42b1c36 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -6,10 +6,6 @@ AC_GNU_SOURCE + AC_CONFIG_HEADERS([config.h]) + AC_CONFIG_SRCDIR([src/motion.c]) + AC_CANONICAL_HOST +-AC_CONFIG_MACRO_DIR([m4]) +- +-AM_GNU_GETTEXT([external]) +-AM_GNU_GETTEXT_VERSION([0.18]) + + ############################################################################## + ### Check additional system headers +@@ -470,7 +466,6 @@ LDFLAGS="$TEMP_LDFLAGS" + AC_CONFIG_FILES([ + Makefile + src/Makefile +- po/Makefile.in + man/Makefile + data/camera1-dist.conf + data/camera2-dist.conf +diff --git a/src/Makefile.am b/src/Makefile.am +index bedd1b3..aa253ca 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -4,7 +4,6 @@ if INC_MMAL_SRC + MMAL_SRC=raspicam/RaspiCamControl.c raspicam/RaspiCLI.c + endif + +-LIBS = @LIBINTL@ @LIBS@ + + bin_PROGRAMS = motion + diff --git a/package/motion/0002-enable-h264-omx-codec.patch b/package/motion/0002-enable-h264-omx-codec.patch new file mode 100644 index 0000000000..14935f02db --- /dev/null +++ b/package/motion/0002-enable-h264-omx-codec.patch @@ -0,0 +1,17 @@ +Author: jasaw + + +diff --git a/src/ffmpeg.c b/src/ffmpeg.c +index 3af961a..d59f0e1 100644 +--- a/src/ffmpeg.c ++++ b/src/ffmpeg.c +@@ -680,7 +680,7 @@ static const char *ffmpeg_codec_is_blacklisted(const char *codec_name){ + * - remove the "h264_omx" from this blacklist. + * More information: https://github.com/Motion-Project/motion/issues/433 + */ +- {"h264_omx", "Codec causes lock up on your FFMpeg version"}, ++ //{"h264_omx", "Codec causes lock up on your FFMpeg version"}, + #endif + #if (LIBAVFORMAT_VERSION_MAJOR < 57) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR < 41)) + {"h264_v4l2m2m", "FFMpeg version is too old"}, + diff --git a/package/motion/0002-enable-h264-v4l2m2m.patch b/package/motion/0002-enable-h264-v4l2m2m.patch deleted file mode 100644 index 2a3423c916..0000000000 --- a/package/motion/0002-enable-h264-v4l2m2m.patch +++ /dev/null @@ -1,233 +0,0 @@ -diff --git a/ffmpeg.c b/ffmpeg.c -index 3f731ca..7a42d24 100644 ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -179,6 +179,14 @@ int my_copy_packet(AVPacket *dest_pkt, AVPacket *src_pkt){ - #endif - } - /*********************************************/ -+void my_free_nal_info(struct ffmpeg *ffmpeg){ -+ if (ffmpeg->nal_info) { -+ free(ffmpeg->nal_info); -+ ffmpeg->nal_info = NULL; -+ ffmpeg->nal_info_len = 0; -+ } -+} -+/*********************************************/ - - /**************************************************************************** - **************************************************************************** -@@ -409,6 +417,25 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){ - return -1; - } - -+ if (ffmpeg->nal_info_separated) { -+ // h264_v4l2m2m has NAL units separated from the first frame, which makes -+ // some players very unhappy. -+ if ((ffmpeg->pkt.pts == 0) && (!(ffmpeg->pkt.flags & AV_PKT_FLAG_KEY))) { -+ my_free_nal_info(ffmpeg); -+ ffmpeg->nal_info_len = ffmpeg->pkt.size; -+ ffmpeg->nal_info = malloc(ffmpeg->nal_info_len); -+ if (ffmpeg->nal_info) -+ memcpy(ffmpeg->nal_info, &ffmpeg->pkt.data[0], ffmpeg->nal_info_len); -+ else -+ ffmpeg->nal_info_len = 0; -+ } else if (ffmpeg->nal_info) { -+ int old_size = ffmpeg->pkt.size; -+ av_grow_packet(&ffmpeg->pkt, ffmpeg->nal_info_len); -+ memmove(&ffmpeg->pkt.data[ffmpeg->nal_info_len], &ffmpeg->pkt.data[0], old_size); -+ memcpy(&ffmpeg->pkt.data[0], ffmpeg->nal_info, ffmpeg->nal_info_len); -+ my_free_nal_info(ffmpeg); -+ } -+ } - return 0; - - #elif (LIBAVFORMAT_VERSION_MAJOR >= 55) || ((LIBAVFORMAT_VERSION_MAJOR == 54) && (LIBAVFORMAT_VERSION_MINOR > 6)) -@@ -555,7 +582,9 @@ static int ffmpeg_set_quality(struct ffmpeg *ffmpeg){ - ffmpeg->quality = 45; // default to 45% quality - av_dict_set(&ffmpeg->opts, "preset", "ultrafast", 0); - av_dict_set(&ffmpeg->opts, "tune", "zerolatency", 0); -- if ((strcmp(ffmpeg->codec->name, "h264_omx") == 0) || (strcmp(ffmpeg->codec->name, "mpeg4_omx") == 0)) { -+ if ((strcmp(ffmpeg->codec->name, "h264_omx") == 0) || -+ (strcmp(ffmpeg->codec->name, "mpeg4_omx") == 0) || -+ (strcmp(ffmpeg->codec->name, "h264_v4l2m2m") == 0)) { - // H264 OMX encoder quality can only be controlled via bit_rate - // bit_rate = ffmpeg->width * ffmpeg->height * ffmpeg->fps * quality_factor - ffmpeg->quality = (int)(((int64_t)ffmpeg->width * ffmpeg->height * ffmpeg->fps * ffmpeg->quality) >> 7); -@@ -702,13 +731,20 @@ static int ffmpeg_set_codec(struct ffmpeg *ffmpeg){ - ffmpeg->ctx_codec->height = ffmpeg->height; - ffmpeg->ctx_codec->time_base.num = 1; - ffmpeg->ctx_codec->time_base.den = ffmpeg->fps; -- ffmpeg->ctx_codec->pix_fmt = MY_PIX_FMT_YUV420P; -+ if (strcmp(ffmpeg->codec->name, "h264_v4l2m2m") == 0) -+ ffmpeg->ctx_codec->pix_fmt = AV_PIX_FMT_NV21; -+ else -+ ffmpeg->ctx_codec->pix_fmt = MY_PIX_FMT_YUV420P; - ffmpeg->ctx_codec->max_b_frames = 0; - if (strcmp(ffmpeg->codec_name, "ffv1") == 0){ - ffmpeg->ctx_codec->strict_std_compliance = -2; - ffmpeg->ctx_codec->level = 3; - } - ffmpeg->ctx_codec->flags |= MY_CODEC_FLAG_GLOBAL_HEADER; -+ // h264_v4l2m2m has NAL units separated from the first frame. We need to deal -+ // with it appriopriately later -+ if (strcmp(ffmpeg->codec->name, "h264_v4l2m2m") == 0) -+ ffmpeg->nal_info_separated = 1; - - retcd = ffmpeg_set_quality(ffmpeg); - if (retcd < 0){ -@@ -768,8 +804,69 @@ static int ffmpeg_set_stream(struct ffmpeg *ffmpeg){ - - } - -+ -+static int ffmpeg_alloc_video_buffer(AVFrame *frame, int align) -+{ -+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); -+ int ret, i, padded_height; -+ int plane_padding = FFMAX(16 + 16/*STRIDE_ALIGN*/, align); -+ -+ if (!desc) -+ return AVERROR(EINVAL); -+ -+ if ((ret = av_image_check_size(frame->width, frame->height, 0, NULL)) < 0) -+ return ret; -+ -+ if (!frame->linesize[0]) { -+ if (align <= 0) -+ align = 32; /* STRIDE_ALIGN. Should be av_cpu_max_align() */ -+ -+ for(i=1; i<=align; i+=i) { -+ ret = av_image_fill_linesizes(frame->linesize, frame->format, -+ FFALIGN(frame->width, i)); -+ if (ret < 0) -+ return ret; -+ if (!(frame->linesize[0] & (align-1))) -+ break; -+ } -+ -+ for (i = 0; i < 4 && frame->linesize[i]; i++) -+ frame->linesize[i] = FFALIGN(frame->linesize[i], align); -+ } -+ -+ padded_height = FFALIGN(frame->height, 32); -+ if ((ret = av_image_fill_pointers(frame->data, frame->format, padded_height, -+ NULL, frame->linesize)) < 0) -+ return ret; -+ -+ frame->buf[0] = av_buffer_alloc(ret + 4*plane_padding); -+ if (!frame->buf[0]) { -+ ret = AVERROR(ENOMEM); -+ av_frame_unref(frame); -+ return ret; -+ } -+ frame->buf[1] = av_buffer_alloc(ret + 4*plane_padding); -+ if (!frame->buf[1]) { -+ ret = AVERROR(ENOMEM); -+ av_frame_unref(frame); -+ return ret; -+ } -+ -+ frame->data[0] = frame->buf[0]->data; -+ frame->data[1] = frame->buf[1]->data; -+ frame->data[2] = frame->data[1] + ((frame->width * padded_height) / 4); -+ -+ frame->extended_data = frame->data; -+ -+ return 0; -+} -+ -+ - static int ffmpeg_set_picture(struct ffmpeg *ffmpeg){ - -+ int retcd; -+ char errstr[128]; -+ - ffmpeg->picture = my_frame_alloc(); - if (!ffmpeg->picture) { - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, _("could not alloc frame")); -@@ -789,6 +886,17 @@ static int ffmpeg_set_picture(struct ffmpeg *ffmpeg){ - ffmpeg->picture->width = ffmpeg->ctx_codec->width; - ffmpeg->picture->height = ffmpeg->ctx_codec->height; - -+ // h264_v4l2m2m encoder expects video buffer to be allocated -+ if (strcmp(ffmpeg->codec->name, "h264_v4l2m2m") == 0) { -+ retcd = ffmpeg_alloc_video_buffer(ffmpeg->picture, 32); -+ if (retcd) { -+ av_strerror(retcd, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, _("could not alloc buffers %s"), errstr); -+ ffmpeg_free_context(ffmpeg); -+ return -1; -+ } -+ } -+ - return 0; - - } -@@ -891,6 +999,12 @@ static int ffmpeg_flush_codec(struct ffmpeg *ffmpeg){ - my_packet_unref(ffmpeg->pkt); - return -1; - } -+ // v4l2_m2m encoder uses pts 0 and size 0 to indicate AVERROR_EOF -+ if ((ffmpeg->pkt.pts == 0) || (ffmpeg->pkt.size == 0)) { -+ recv_cd = AVERROR_EOF; -+ my_packet_unref(ffmpeg->pkt); -+ continue; -+ } - retcd = av_write_frame(ffmpeg->oc, &ffmpeg->pkt); - if (retcd < 0) { - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO -@@ -1339,6 +1453,7 @@ void ffmpeg_close(struct ffmpeg *ffmpeg){ - } - } - ffmpeg_free_context(ffmpeg); -+ my_free_nal_info(ffmpeg); - } - - #else -@@ -1365,9 +1480,28 @@ int ffmpeg_put_image(struct ffmpeg *ffmpeg, struct image_data *img_data, const s - } - - /* Setup pointers and line widths. */ -- ffmpeg->picture->data[0] = image; -- ffmpeg->picture->data[1] = image + (ffmpeg->ctx_codec->width * ffmpeg->ctx_codec->height); -- ffmpeg->picture->data[2] = ffmpeg->picture->data[1] + ((ffmpeg->ctx_codec->width * ffmpeg->ctx_codec->height) / 4); -+ if (strcmp(ffmpeg->codec->name, "h264_v4l2m2m") == 0) { -+ // assume NV21 format -+ int cr_len = ffmpeg->ctx_codec->width * ffmpeg->ctx_codec->height / 4; -+ unsigned char *imagecr = image + (ffmpeg->ctx_codec->width * ffmpeg->ctx_codec->height); -+ unsigned char *imagecb = image + (ffmpeg->ctx_codec->width * ffmpeg->ctx_codec->height) + cr_len; -+ int x; -+ int y; -+ memcpy(ffmpeg->picture->data[0], image, ffmpeg->ctx_codec->width * ffmpeg->ctx_codec->height); -+ for (y = 0; y < ffmpeg->ctx_codec->height; y++) { -+ for (x = 0; x < ffmpeg->ctx_codec->width/4; x++) { -+ ffmpeg->picture->data[1][y*ffmpeg->ctx_codec->width/2 + x*2] = *imagecb; -+ ffmpeg->picture->data[1][y*ffmpeg->ctx_codec->width/2 + x*2 + 1] = *imagecr; -+ imagecb++; -+ imagecr++; -+ } -+ } -+ } else { -+ // assume YUV420P format -+ ffmpeg->picture->data[0] = image; -+ ffmpeg->picture->data[1] = image + (ffmpeg->ctx_codec->width * ffmpeg->ctx_codec->height); -+ ffmpeg->picture->data[2] = ffmpeg->picture->data[1] + ((ffmpeg->ctx_codec->width * ffmpeg->ctx_codec->height) / 4); -+ } - - ffmpeg->gop_cnt ++; - if (ffmpeg->gop_cnt == ffmpeg->ctx_codec->gop_size ){ -diff --git a/ffmpeg.h b/ffmpeg.h -index ca77430..c4ae7bb 100644 ---- a/ffmpeg.h -+++ b/ffmpeg.h -@@ -61,6 +61,9 @@ struct ffmpeg { - int high_resolution; - int motion_images; - int passthrough; -+ int nal_info_separated; -+ char *nal_info; -+ int nal_info_len; - }; - #else - struct ffmpeg { diff --git a/package/motion/0003-ensure-first-frame-pts-zero.patch b/package/motion/0003-ensure-first-frame-pts-zero.patch deleted file mode 100644 index 56b0d6c19c..0000000000 --- a/package/motion/0003-ensure-first-frame-pts-zero.patch +++ /dev/null @@ -1,23 +0,0 @@ -commit 0cd12918f93fc6559dad56d176a60ddc3f0844d6 -Author: Joo Aun Saw -Date: Thu Sep 5 14:20:07 2019 +1000 - - ffmpeg: ensure first frame PTS is zero - -diff --git a/ffmpeg.c b/ffmpeg.c -index 7a42d24..665aa00 100644 ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -512,7 +512,11 @@ static int ffmpeg_set_pts(struct ffmpeg *ffmpeg, const struct timeval *tv1){ - ffmpeg_reset_movie_start_time(ffmpeg, tv1); - pts_interval = 0; - } -- ffmpeg->picture->pts = av_rescale_q(pts_interval,(AVRational){1, 1000000L},ffmpeg->video_st->time_base) + ffmpeg->base_pts; -+ if (ffmpeg->last_pts < 0) { -+ // This is the very first frame, ensure PTS is zero -+ ffmpeg->picture->pts = 0; -+ } else -+ ffmpeg->picture->pts = av_rescale_q(pts_interval,(AVRational){1, 1000000L},ffmpeg->video_st->time_base) + ffmpeg->base_pts; - - if (ffmpeg->test_mode == TRUE){ - MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO diff --git a/package/motion/1001-decouple-avcodec-send-and-receive.patch b/package/motion/1001-decouple-avcodec-send-and-receive.patch deleted file mode 100644 index cf35ada2e0..0000000000 --- a/package/motion/1001-decouple-avcodec-send-and-receive.patch +++ /dev/null @@ -1,202 +0,0 @@ -diff --git a/ffmpeg.c b/ffmpeg.c -index 665aa00..1246fdc 100644 ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -386,6 +386,14 @@ static int ffmpeg_get_oformat(struct ffmpeg *ffmpeg){ - return 0; - } - -+static int ffmpeg_write_packet(struct ffmpeg *ffmpeg){ -+ if (ffmpeg->tlapse == TIMELAPSE_APPEND) { -+ return ffmpeg_timelapse_append(ffmpeg, ffmpeg->pkt); -+ } else { -+ return av_write_frame(ffmpeg->oc, &ffmpeg->pkt); -+ } -+} -+ - static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){ - - #if (LIBAVFORMAT_VERSION_MAJOR >= 58) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR >= 41)) -@@ -400,41 +408,49 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){ - ,_("Error sending frame for encoding:%s"),errstr); - return -1; - } -- retcd = avcodec_receive_packet(ffmpeg->ctx_codec, &ffmpeg->pkt); -- if (retcd == AVERROR(EAGAIN)){ -- //Buffered packet. Throw special return code -- av_strerror(retcd, errstr, sizeof(errstr)); -- MOTION_LOG(DBG, TYPE_ENCODER, NO_ERRNO -- ,_("Receive packet threw EAGAIN returning -2 code :%s"),errstr); -- my_packet_unref(ffmpeg->pkt); -- return -2; -- } -- if (retcd < 0 ){ -- av_strerror(retcd, errstr, sizeof(errstr)); -- MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO -- ,_("Error receiving encoded packet video:%s"),errstr); -- //Packet is freed upon failure of encoding -- return -1; -- } -- -- if (ffmpeg->nal_info_separated) { -- // h264_v4l2m2m has NAL units separated from the first frame, which makes -- // some players very unhappy. -- if ((ffmpeg->pkt.pts == 0) && (!(ffmpeg->pkt.flags & AV_PKT_FLAG_KEY))) { -- my_free_nal_info(ffmpeg); -- ffmpeg->nal_info_len = ffmpeg->pkt.size; -- ffmpeg->nal_info = malloc(ffmpeg->nal_info_len); -- if (ffmpeg->nal_info) -- memcpy(ffmpeg->nal_info, &ffmpeg->pkt.data[0], ffmpeg->nal_info_len); -- else -- ffmpeg->nal_info_len = 0; -- } else if (ffmpeg->nal_info) { -- int old_size = ffmpeg->pkt.size; -- av_grow_packet(&ffmpeg->pkt, ffmpeg->nal_info_len); -- memmove(&ffmpeg->pkt.data[ffmpeg->nal_info_len], &ffmpeg->pkt.data[0], old_size); -- memcpy(&ffmpeg->pkt.data[0], ffmpeg->nal_info, ffmpeg->nal_info_len); -- my_free_nal_info(ffmpeg); -+ while (retcd >= 0) { -+ av_init_packet(&ffmpeg->pkt); -+ ffmpeg->pkt.data = NULL; -+ ffmpeg->pkt.size = 0; -+ retcd = avcodec_receive_packet(ffmpeg->ctx_codec, &ffmpeg->pkt); -+ if (retcd == AVERROR(EAGAIN)){ -+ //Buffered packet. Throw special return code -+ my_packet_unref(ffmpeg->pkt); -+ return -2; - } -+ if (retcd < 0 ){ -+ av_strerror(retcd, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "Error receiving encoded packet video:%s",errstr); -+ my_packet_unref(ffmpeg->pkt); -+ return -1; -+ } else { -+ if (ffmpeg->nal_info_separated) { -+ // h264_v4l2m2m has NAL units separated from the first frame, which makes -+ // some players very unhappy. -+ if ((ffmpeg->pkt.pts == 0) && (!(ffmpeg->pkt.flags & AV_PKT_FLAG_KEY))) { -+ my_free_nal_info(ffmpeg); -+ ffmpeg->nal_info_len = ffmpeg->pkt.size; -+ ffmpeg->nal_info = malloc(ffmpeg->nal_info_len); -+ if (ffmpeg->nal_info) -+ memcpy(ffmpeg->nal_info, &ffmpeg->pkt.data[0], ffmpeg->nal_info_len); -+ else -+ ffmpeg->nal_info_len = 0; -+ } else if (ffmpeg->nal_info) { -+ int old_size = ffmpeg->pkt.size; -+ av_grow_packet(&ffmpeg->pkt, ffmpeg->nal_info_len); -+ memmove(&ffmpeg->pkt.data[ffmpeg->nal_info_len], &ffmpeg->pkt.data[0], old_size); -+ memcpy(&ffmpeg->pkt.data[0], ffmpeg->nal_info, ffmpeg->nal_info_len); -+ my_free_nal_info(ffmpeg); -+ } -+ } -+ if (ffmpeg_write_packet(ffmpeg) < 0) { -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "Error while writing video frame"); -+ my_packet_unref(ffmpeg->pkt); -+ ffmpeg_free_context(ffmpeg); -+ return -1; -+ } -+ } -+ my_packet_unref(ffmpeg->pkt); - } - return 0; - -@@ -444,11 +460,15 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){ - char errstr[128]; - int got_packet_ptr; - -+ av_init_packet(&ffmpeg->pkt); -+ ffmpeg->pkt.data = NULL; -+ ffmpeg->pkt.size = 0; -+ - retcd = avcodec_encode_video2(ffmpeg->ctx_codec, &ffmpeg->pkt, ffmpeg->picture, &got_packet_ptr); - if (retcd < 0 ){ - av_strerror(retcd, errstr, sizeof(errstr)); - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, _("Error encoding video:%s"),errstr); -- //Packet is freed upon failure of encoding -+ my_packet_unref(ffmpeg->pkt); - return -1; - } - if (got_packet_ptr == 0){ -@@ -457,6 +477,15 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){ - return -2; - } - -+ retcd = ffmpeg_write_packet(ffmpeg); -+ if (retcd < 0) { -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "Error while writing video frame"); -+ my_packet_unref(ffmpeg->pkt); -+ ffmpeg_free_context(ffmpeg); -+ return -1; -+ } -+ my_packet_unref(ffmpeg->pkt); -+ - return 0; - - #else -@@ -465,6 +494,10 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){ - uint8_t *video_outbuf; - int video_outbuf_size; - -+ av_init_packet(&ffmpeg->pkt); -+ ffmpeg->pkt.data = NULL; -+ ffmpeg->pkt.size = 0; -+ - video_outbuf_size = (ffmpeg->ctx_codec->width +16) * (ffmpeg->ctx_codec->height +16) * 1; - video_outbuf = mymalloc(video_outbuf_size); - -@@ -490,6 +523,17 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){ - ffmpeg->pkt.pts = ffmpeg->picture->pts; - ffmpeg->pkt.dts = ffmpeg->pkt.pts; - -+ retcd = ffmpeg_write_packet(ffmpeg); -+ if (retcd < 0) { -+ av_strerror(retcd, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "Error while writing video frame"); -+ my_packet_unref(ffmpeg->pkt); -+ free(video_outbuf); -+ ffmpeg_free_context(ffmpeg); -+ return -1; -+ } -+ -+ my_packet_unref(ffmpeg->pkt); - free(video_outbuf); - - return 0; -@@ -1034,14 +1078,9 @@ static int ffmpeg_flush_codec(struct ffmpeg *ffmpeg){ - static int ffmpeg_put_frame(struct ffmpeg *ffmpeg, const struct timeval *tv1){ - int retcd; - -- av_init_packet(&ffmpeg->pkt); -- ffmpeg->pkt.data = NULL; -- ffmpeg->pkt.size = 0; -- - retcd = ffmpeg_set_pts(ffmpeg, tv1); - if (retcd < 0) { - //If there is an error, it has already been reported. -- my_packet_unref(ffmpeg->pkt); - return 0; - } - -@@ -1050,21 +1089,9 @@ static int ffmpeg_put_frame(struct ffmpeg *ffmpeg, const struct timeval *tv1){ - if (retcd != -2){ - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, _("Error while encoding picture")); - } -- my_packet_unref(ffmpeg->pkt); - return retcd; - } - -- if (ffmpeg->tlapse == TIMELAPSE_APPEND) { -- retcd = ffmpeg_timelapse_append(ffmpeg, ffmpeg->pkt); -- } else { -- retcd = av_write_frame(ffmpeg->oc, &ffmpeg->pkt); -- } -- my_packet_unref(ffmpeg->pkt); -- -- if (retcd < 0) { -- MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, _("Error while writing video frame")); -- return -1; -- } - return retcd; - - } diff --git a/package/motion/enable-h264-omx-codec.patch b/package/motion/enable-h264-omx-codec.patch deleted file mode 100644 index 90568ad640..0000000000 --- a/package/motion/enable-h264-omx-codec.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/ffmpeg.c b/ffmpeg.c -index a729cda..798c017 100644 ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -513,7 +513,7 @@ static int ffmpeg_codec_is_blacklisted(const char *codec_name){ - * - remove the "h264_omx" from this blacklist. - * More information: https://github.com/Motion-Project/motion/issues/433 - */ -- "h264_omx", -+ //"h264_omx", - }; - size_t i; - diff --git a/package/motion/motion.hash b/package/motion/motion.hash index ae0216f002..dcc8cae6e1 100644 --- a/package/motion/motion.hash +++ b/package/motion/motion.hash @@ -1,3 +1,5 @@ # locally computed hash sha256 2074b935bdfe28f84c2c3233274b06908336778f303bb13530d4299c3f8aa4e2 motion-release-4.1.1.tar.gz sha256 c8d40976b41da8eb9f9f7128599403a312fc26b7226bf3787d75f78cb5a6cc6e motion-release-4.2.2.tar.gz +sha256 dba1d32c9a777f4e822d26ded25f24072b7234c70dc9850f8ea61564c0a8eca5 motion-5c8ac5282b3e980270555c1d2c6f710829a2856e.tar.gz + diff --git a/package/motion/motion.mk b/package/motion/motion.mk index 19021697d9..773544e346 100644 --- a/package/motion/motion.mk +++ b/package/motion/motion.mk @@ -4,24 +4,21 @@ # ################################################################################ -MOTION_VERSION = release-4.2.2 -MOTION_SITE = $(call github,motion-project,motion,$(MOTION_VERSION)) +MOTION_VERSION = 5c8ac5282b3e980270555c1d2c6f710829a2856e +MOTION_SITE = $(call github,Motion-Project,motion,$(MOTION_VERSION)) MOTION_AUTORECONF = YES MOTION_CONF_OPTS = --without-pgsql \ - --without-sdl \ --without-sqlite3 \ --without-mysql \ - --with-ffmpeg=$(STAGING_DIR)/usr/lib \ - --with-ffmpeg-headers=$(STAGING_DIR)/usr/include + --without-mariadb \ + --with-ffmpeg=$(STAGING_DIR)/usr/lib define MOTION_INSTALL_TARGET_CMDS - cp $(@D)/motion $(TARGET_DIR)/usr/bin/motion + cp $(@D)/src/motion $(TARGET_DIR)/usr/bin/motion endef ifeq ($(BR2_PACKAGE_RPI_USERLAND),y) MOTION_DEPENDENCIES += rpi-userland -MOTION_CONF_OPTS += --with-mmal-include=$(STAGING_DIR)/usr/include \ - --with-mmal-lib=$(STAGING_DIR)/lib endif $(eval $(autotools-package))