mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-29 06:06:32 +00:00
commit
c757e64993
1
board/raspberrypi/overlay/opt/vc/lib
Symbolic link
1
board/raspberrypi/overlay/opt/vc/lib
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../usr/lib
|
1
board/raspberrypi2/overlay/opt/vc/lib
Symbolic link
1
board/raspberrypi2/overlay/opt/vc/lib
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../usr/lib
|
1
board/raspberrypi3/overlay/opt/vc/lib
Symbolic link
1
board/raspberrypi3/overlay/opt/vc/lib
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../usr/lib
|
@ -27,6 +27,7 @@ BR2_PACKAGE_FFMPEG=y
|
|||||||
BR2_PACKAGE_FFMPEG_GPL=y
|
BR2_PACKAGE_FFMPEG_GPL=y
|
||||||
BR2_PACKAGE_FFMPEG_NONFREE=y
|
BR2_PACKAGE_FFMPEG_NONFREE=y
|
||||||
BR2_PACKAGE_FFMPEG_SWSCALE=y
|
BR2_PACKAGE_FFMPEG_SWSCALE=y
|
||||||
|
BR2_PACKAGE_FFMPEG_RPI_HW_CODECS=y
|
||||||
BR2_PACKAGE_LIBWEBCAM=y
|
BR2_PACKAGE_LIBWEBCAM=y
|
||||||
BR2_PACKAGE_MOTION=y
|
BR2_PACKAGE_MOTION=y
|
||||||
BR2_PACKAGE_STREAMEYE=y
|
BR2_PACKAGE_STREAMEYE=y
|
||||||
|
@ -27,6 +27,7 @@ BR2_PACKAGE_FFMPEG=y
|
|||||||
BR2_PACKAGE_FFMPEG_GPL=y
|
BR2_PACKAGE_FFMPEG_GPL=y
|
||||||
BR2_PACKAGE_FFMPEG_NONFREE=y
|
BR2_PACKAGE_FFMPEG_NONFREE=y
|
||||||
BR2_PACKAGE_FFMPEG_SWSCALE=y
|
BR2_PACKAGE_FFMPEG_SWSCALE=y
|
||||||
|
BR2_PACKAGE_FFMPEG_RPI_HW_CODECS=y
|
||||||
BR2_PACKAGE_LIBWEBCAM=y
|
BR2_PACKAGE_LIBWEBCAM=y
|
||||||
BR2_PACKAGE_MOTION=y
|
BR2_PACKAGE_MOTION=y
|
||||||
BR2_PACKAGE_STREAMEYE=y
|
BR2_PACKAGE_STREAMEYE=y
|
||||||
|
@ -28,6 +28,7 @@ BR2_PACKAGE_FFMPEG=y
|
|||||||
BR2_PACKAGE_FFMPEG_GPL=y
|
BR2_PACKAGE_FFMPEG_GPL=y
|
||||||
BR2_PACKAGE_FFMPEG_NONFREE=y
|
BR2_PACKAGE_FFMPEG_NONFREE=y
|
||||||
BR2_PACKAGE_FFMPEG_SWSCALE=y
|
BR2_PACKAGE_FFMPEG_SWSCALE=y
|
||||||
|
BR2_PACKAGE_FFMPEG_RPI_HW_CODECS=y
|
||||||
BR2_PACKAGE_LIBWEBCAM=y
|
BR2_PACKAGE_LIBWEBCAM=y
|
||||||
BR2_PACKAGE_MOTION=y
|
BR2_PACKAGE_MOTION=y
|
||||||
BR2_PACKAGE_STREAMEYE=y
|
BR2_PACKAGE_STREAMEYE=y
|
||||||
|
@ -167,6 +167,12 @@ config BR2_PACKAGE_FFMPEG_OUTDEVS
|
|||||||
bool "Enable output devices"
|
bool "Enable output devices"
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
config BR2_PACKAGE_FFMPEG_RPI_HW_CODECS
|
||||||
|
bool "Enable rpi hardware accelerated codecs"
|
||||||
|
depends on BR2_PACKAGE_RPI_USERLAND
|
||||||
|
help
|
||||||
|
Enable HW accelerated codecs on Raspberry pi.
|
||||||
|
|
||||||
config BR2_PACKAGE_FFMPEG_EXTRACONF
|
config BR2_PACKAGE_FFMPEG_EXTRACONF
|
||||||
string "Additional parameters for ./configure"
|
string "Additional parameters for ./configure"
|
||||||
default ""
|
default ""
|
||||||
|
15
package/ffmpeg/disable-rpi-omx-input-zerocopy.patch
Normal file
15
package/ffmpeg/disable-rpi-omx-input-zerocopy.patch
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
diff --git a/libavcodec/omx.c b/libavcodec/omx.c
|
||||||
|
index 19b4f33836..4641dc79e2 100644
|
||||||
|
--- a/libavcodec/omx.c
|
||||||
|
+++ b/libavcodec/omx.c
|
||||||
|
@@ -644,10 +644,6 @@ static av_cold int omx_encode_init(AVCodecContext *avctx)
|
||||||
|
OMX_BUFFERHEADERTYPE *buffer;
|
||||||
|
OMX_ERRORTYPE err;
|
||||||
|
|
||||||
|
-#if CONFIG_OMX_RPI
|
||||||
|
- s->input_zerocopy = 1;
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
s->omx_context = omx_init(avctx, s->libname, s->libprefix);
|
||||||
|
if (!s->omx_context)
|
||||||
|
return AVERROR_ENCODER_NOT_FOUND;
|
@ -1,2 +1,3 @@
|
|||||||
# Locally calculated
|
# Locally calculated
|
||||||
sha256 54ce502aca10b7e6059f19220ea2f68fa0c9c4c4d255ae13e615f08f0c94dcc5 ffmpeg-3.2.3.tar.xz
|
sha256 54ce502aca10b7e6059f19220ea2f68fa0c9c4c4d255ae13e615f08f0c94dcc5 ffmpeg-3.2.3.tar.xz
|
||||||
|
sha256 1998de1ab32616cbf2ff86efc3f1f26e76805ec5dc51e24c041c79edd8262785 ffmpeg-3.3.2.tar.xz
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
FFMPEG_VERSION = 3.2.3
|
FFMPEG_VERSION = 3.3.2
|
||||||
FFMPEG_SOURCE = ffmpeg-$(FFMPEG_VERSION).tar.xz
|
FFMPEG_SOURCE = ffmpeg-$(FFMPEG_VERSION).tar.xz
|
||||||
FFMPEG_SITE = http://ffmpeg.org/releases
|
FFMPEG_SITE = http://ffmpeg.org/releases
|
||||||
FFMPEG_INSTALL_STAGING = YES
|
FFMPEG_INSTALL_STAGING = YES
|
||||||
@ -26,7 +26,6 @@ FFMPEG_CONF_OPTS = \
|
|||||||
--enable-avdevice \
|
--enable-avdevice \
|
||||||
--enable-avcodec \
|
--enable-avcodec \
|
||||||
--enable-avformat \
|
--enable-avformat \
|
||||||
--disable-x11grab \
|
|
||||||
--enable-network \
|
--enable-network \
|
||||||
--disable-gray \
|
--disable-gray \
|
||||||
--enable-swscale-alpha \
|
--enable-swscale-alpha \
|
||||||
@ -39,7 +38,6 @@ FFMPEG_CONF_OPTS = \
|
|||||||
--disable-dxva2 \
|
--disable-dxva2 \
|
||||||
--enable-runtime-cpudetect \
|
--enable-runtime-cpudetect \
|
||||||
--disable-hardcoded-tables \
|
--disable-hardcoded-tables \
|
||||||
--disable-memalign-hack \
|
|
||||||
--disable-mipsdsp \
|
--disable-mipsdsp \
|
||||||
--disable-mipsdspr2 \
|
--disable-mipsdspr2 \
|
||||||
--disable-msa \
|
--disable-msa \
|
||||||
@ -473,6 +471,11 @@ else ifneq ($(call qstrip,$(BR2_GCC_TARGET_ARCH)),)
|
|||||||
FFMPEG_CONF_OPTS += --cpu=$(BR2_GCC_TARGET_ARCH)
|
FFMPEG_CONF_OPTS += --cpu=$(BR2_GCC_TARGET_ARCH)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BR2_PACKAGE_FFMPEG_RPI_HW_CODECS),y)
|
||||||
|
FFMPEG_DEPENDENCIES += rpi-userland
|
||||||
|
FFMPEG_CONF_OPTS += --enable-omx --enable-omx-rpi --enable-mmal --extra-cflags=-I../../staging/usr/include/IL/
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
FFMPEG_CONF_OPTS += $(call qstrip,$(BR2_PACKAGE_FFMPEG_EXTRACONF))
|
FFMPEG_CONF_OPTS += $(call qstrip,$(BR2_PACKAGE_FFMPEG_EXTRACONF))
|
||||||
|
|
||||||
|
40
package/motion/0011-do-not-force-keyframe.patch
Normal file
40
package/motion/0011-do-not-force-keyframe.patch
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
diff --git a/ffmpeg.c b/ffmpeg.c
|
||||||
|
index 739bcb3..aa17ddc 100644
|
||||||
|
--- a/ffmpeg.c
|
||||||
|
+++ b/ffmpeg.c
|
||||||
|
@@ -349,8 +349,6 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
//Packet is freed upon failure of encoding
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
- if (ffmpeg->picture->key_frame == 1)
|
||||||
|
- ffmpeg->pkt.flags |= AV_PKT_FLAG_KEY;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
@@ -373,9 +371,6 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (ffmpeg->picture->key_frame == 1)
|
||||||
|
- ffmpeg->pkt.flags |= AV_PKT_FLAG_KEY;
|
||||||
|
-
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
@@ -399,12 +394,16 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Encoder did not provide metadata, set it up manually
|
||||||
|
ffmpeg->pkt.size = retcd;
|
||||||
|
ffmpeg->pkt.data = video_outbuf;
|
||||||
|
|
||||||
|
if (ffmpeg->picture->key_frame == 1)
|
||||||
|
ffmpeg->pkt.flags |= AV_PKT_FLAG_KEY;
|
||||||
|
|
||||||
|
+ ffmpeg->pkt.pts = ffmpeg->picture->pts;
|
||||||
|
+ ffmpeg->pkt.dts = ffmpeg->pkt.pts;
|
||||||
|
+
|
||||||
|
free(video_outbuf);
|
||||||
|
|
||||||
|
return 0;
|
182
package/motion/0012-decouple-avcodec-send-receive.patch
Normal file
182
package/motion/0012-decouple-avcodec-send-receive.patch
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
commit 2220065f0e2240e963aeb9bc99fd7c233ea2834d
|
||||||
|
Author: Joo Aun Saw <jasaw@dius.com.au>
|
||||||
|
Date: Mon Sep 18 14:21:36 2017 +1000
|
||||||
|
|
||||||
|
decouple avcodec send receive
|
||||||
|
|
||||||
|
diff --git a/ffmpeg.c b/ffmpeg.c
|
||||||
|
index 560e7d4..aa06bef 100644
|
||||||
|
--- a/ffmpeg.c
|
||||||
|
+++ b/ffmpeg.c
|
||||||
|
@@ -341,6 +341,15 @@ 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))
|
||||||
|
@@ -348,25 +357,41 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
int retcd = 0;
|
||||||
|
char errstr[128];
|
||||||
|
|
||||||
|
+ av_init_packet(&ffmpeg->pkt);
|
||||||
|
+ ffmpeg->pkt.data = NULL;
|
||||||
|
+ ffmpeg->pkt.size = 0;
|
||||||
|
+
|
||||||
|
retcd = avcodec_send_frame(ffmpeg->ctx_codec, ffmpeg->picture);
|
||||||
|
if (retcd < 0 ){
|
||||||
|
av_strerror(retcd, errstr, sizeof(errstr));
|
||||||
|
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
+ while (retcd >= 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 {
|
||||||
|
+ 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;
|
||||||
|
|
||||||
|
#elif (LIBAVFORMAT_VERSION_MAJOR >= 55) || ((LIBAVFORMAT_VERSION_MAJOR == 54) && (LIBAVFORMAT_VERSION_MINOR > 6))
|
||||||
|
@@ -375,11 +400,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){
|
||||||
|
@@ -388,6 +417,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
|
||||||
|
@@ -396,6 +434,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);
|
||||||
|
|
||||||
|
@@ -421,8 +463,18 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
ffmpeg->pkt.pts = ffmpeg->picture->pts;
|
||||||
|
ffmpeg->pkt.dts = ffmpeg->pkt.pts;
|
||||||
|
|
||||||
|
- free(video_outbuf);
|
||||||
|
+ 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;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -759,35 +811,16 @@ static int ffmpeg_set_outputfile(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
retcd = ffmpeg_encode_video(ffmpeg);
|
||||||
|
- if (retcd != 0){
|
||||||
|
- 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");
|
||||||
|
- ffmpeg_free_context(ffmpeg);
|
||||||
|
- return -1;
|
||||||
|
+ if (retcd < 0){
|
||||||
|
+ if (retcd != -2)
|
||||||
|
+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "Error while encoding picture");
|
||||||
|
}
|
||||||
|
return retcd;
|
||||||
|
|
140
package/motion/0013-drain-codec.patch
Normal file
140
package/motion/0013-drain-codec.patch
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
commit ff55aecd6fb88a030790b494dcd55bd99cace52b
|
||||||
|
Author: Joo Aun Saw <jasaw@dius.com.au>
|
||||||
|
Date: Mon Sep 18 16:25:44 2017 +1000
|
||||||
|
|
||||||
|
drain codec at end of recording
|
||||||
|
|
||||||
|
diff --git a/ffmpeg.c b/ffmpeg.c
|
||||||
|
index aa06bef..ecdc3e5 100644
|
||||||
|
--- a/ffmpeg.c
|
||||||
|
+++ b/ffmpeg.c
|
||||||
|
@@ -350,7 +350,7 @@ static int ffmpeg_write_packet(struct ffmpeg *ffmpeg){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
+static int ffmpeg_encode_video(struct ffmpeg *ffmpeg, AVFrame *picture){
|
||||||
|
|
||||||
|
#if (LIBAVFORMAT_VERSION_MAJOR >= 58) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR >= 41))
|
||||||
|
//ffmpeg version 3.1 and after
|
||||||
|
@@ -361,7 +361,7 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
ffmpeg->pkt.data = NULL;
|
||||||
|
ffmpeg->pkt.size = 0;
|
||||||
|
|
||||||
|
- retcd = avcodec_send_frame(ffmpeg->ctx_codec, ffmpeg->picture);
|
||||||
|
+ retcd = avcodec_send_frame(ffmpeg->ctx_codec, picture);
|
||||||
|
if (retcd < 0 ){
|
||||||
|
av_strerror(retcd, errstr, sizeof(errstr));
|
||||||
|
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "Error sending frame for encoding:%s",errstr);
|
||||||
|
@@ -370,10 +370,15 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
}
|
||||||
|
while (retcd >= 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 (picture == NULL) {
|
||||||
|
+ if (retcd == AVERROR_EOF)
|
||||||
|
+ break;
|
||||||
|
+ } else {
|
||||||
|
+ 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));
|
||||||
|
@@ -385,7 +390,11 @@ static int ffmpeg_encode_video(struct ffmpeg *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);
|
||||||
|
+ /* Do not free ffmpeg context if we are draining codec. We still
|
||||||
|
+ * need to write trailer even if draining fails.
|
||||||
|
+ */
|
||||||
|
+ if (picture != NULL)
|
||||||
|
+ ffmpeg_free_context(ffmpeg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -404,7 +413,7 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
ffmpeg->pkt.data = NULL;
|
||||||
|
ffmpeg->pkt.size = 0;
|
||||||
|
|
||||||
|
- retcd = avcodec_encode_video2(ffmpeg->ctx_codec, &ffmpeg->pkt, ffmpeg->picture, &got_packet_ptr);
|
||||||
|
+ retcd = avcodec_encode_video2(ffmpeg->ctx_codec, &ffmpeg->pkt, 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);
|
||||||
|
@@ -421,7 +430,11 @@ static int ffmpeg_encode_video(struct ffmpeg *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);
|
||||||
|
+ /* Do not free ffmpeg context if we are draining codec. We still
|
||||||
|
+ * need to write trailer even if draining fails.
|
||||||
|
+ */
|
||||||
|
+ if (picture != NULL)
|
||||||
|
+ ffmpeg_free_context(ffmpeg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -441,7 +454,7 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
video_outbuf_size = (ffmpeg->ctx_codec->width +16) * (ffmpeg->ctx_codec->height +16) * 1;
|
||||||
|
video_outbuf = mymalloc(video_outbuf_size);
|
||||||
|
|
||||||
|
- retcd = avcodec_encode_video(ffmpeg->video_st->codec, video_outbuf, video_outbuf_size, ffmpeg->picture);
|
||||||
|
+ retcd = avcodec_encode_video(ffmpeg->video_st->codec, video_outbuf, video_outbuf_size, picture);
|
||||||
|
if (retcd < 0 ){
|
||||||
|
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "Error encoding video");
|
||||||
|
my_packet_unref(ffmpeg->pkt);
|
||||||
|
@@ -457,11 +470,12 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
ffmpeg->pkt.size = retcd;
|
||||||
|
ffmpeg->pkt.data = video_outbuf;
|
||||||
|
|
||||||
|
- if (ffmpeg->picture->key_frame == 1)
|
||||||
|
- ffmpeg->pkt.flags |= AV_PKT_FLAG_KEY;
|
||||||
|
-
|
||||||
|
- ffmpeg->pkt.pts = ffmpeg->picture->pts;
|
||||||
|
- ffmpeg->pkt.dts = ffmpeg->pkt.pts;
|
||||||
|
+ if (picture) {
|
||||||
|
+ if (picture->key_frame == 1)
|
||||||
|
+ ffmpeg->pkt.flags |= AV_PKT_FLAG_KEY;
|
||||||
|
+ ffmpeg->pkt.pts = picture->pts;
|
||||||
|
+ ffmpeg->pkt.dts = ffmpeg->pkt.pts;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
retcd = ffmpeg_write_packet(ffmpeg);
|
||||||
|
if (retcd < 0) {
|
||||||
|
@@ -469,7 +483,11 @@ static int ffmpeg_encode_video(struct ffmpeg *ffmpeg){
|
||||||
|
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "Error while writing video frame");
|
||||||
|
my_packet_unref(ffmpeg->pkt);
|
||||||
|
free(video_outbuf);
|
||||||
|
- ffmpeg_free_context(ffmpeg);
|
||||||
|
+ /* Do not free ffmpeg context if we are draining codec. We still
|
||||||
|
+ * need to write trailer even if draining fails.
|
||||||
|
+ */
|
||||||
|
+ if (picture != NULL)
|
||||||
|
+ ffmpeg_free_context(ffmpeg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -817,7 +835,7 @@ static int ffmpeg_put_frame(struct ffmpeg *ffmpeg, const struct timeval *tv1){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
- retcd = ffmpeg_encode_video(ffmpeg);
|
||||||
|
+ retcd = ffmpeg_encode_video(ffmpeg, ffmpeg->picture);
|
||||||
|
if (retcd < 0){
|
||||||
|
if (retcd != -2)
|
||||||
|
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "Error while encoding picture");
|
||||||
|
@@ -957,6 +975,7 @@ void ffmpeg_close(struct ffmpeg *ffmpeg){
|
||||||
|
#ifdef HAVE_FFMPEG
|
||||||
|
|
||||||
|
if (ffmpeg != NULL) {
|
||||||
|
+ ffmpeg_encode_video(ffmpeg, NULL); // drain codec
|
||||||
|
if (ffmpeg->tlapse != TIMELAPSE_APPEND) {
|
||||||
|
av_write_trailer(ffmpeg->oc);
|
||||||
|
}
|
13
package/motion/enable-h264-omx-codec.patch
Normal file
13
package/motion/enable-h264-omx-codec.patch
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
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;
|
||||||
|
|
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
MOTIONEYE_VERSION = 9d546ec1aa8da1fe27ad5c0ad212bdb2baf8dce1
|
MOTIONEYE_VERSION = a6601e3a2fd714284a1e10b3b330f9230d93a17d
|
||||||
MOTIONEYE_SITE = $(call github,ccrisan,motioneye,$(MOTIONEYE_VERSION))
|
MOTIONEYE_SITE = $(call github,ccrisan,motioneye,$(MOTIONEYE_VERSION))
|
||||||
MOTIONEYE_SOURCE = $(MOTIONEYE_VERSION).tar.gz
|
MOTIONEYE_SOURCE = $(MOTIONEYE_VERSION).tar.gz
|
||||||
MOTIONEYE_LICENSE = GPLv3
|
MOTIONEYE_LICENSE = GPLv3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user