mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-27 05:06:39 +00:00
Enable hwaccel h264 encoding on raspberry pi
Enable hardware accelerated H264 and MPEG4 video encoding on raspberry pi via libopenmax.
This commit is contained in:
parent
f3f1b6c292
commit
267f056e49
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
|
@ -29,6 +29,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 ""
|
||||||
|
@ -473,6 +473,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))
|
||||||
|
|
||||||
|
19
package/motion/0003-prefer-omx-encoders.patch
Normal file
19
package/motion/0003-prefer-omx-encoders.patch
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
diff --git a/ffmpeg.c b/ffmpeg.c
|
||||||
|
index e7cab9f..3f48db8 100644
|
||||||
|
--- a/ffmpeg.c
|
||||||
|
+++ b/ffmpeg.c
|
||||||
|
@@ -380,7 +380,13 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename,
|
||||||
|
ffmpeg->video_st = NULL;
|
||||||
|
if (ffmpeg->oc->oformat->video_codec != MY_CODEC_ID_NONE) {
|
||||||
|
|
||||||
|
- codec = avcodec_find_encoder(ffmpeg->oc->oformat->video_codec);
|
||||||
|
+ codec = NULL;
|
||||||
|
+ if (ffmpeg->oc->oformat->video_codec == AV_CODEC_ID_H264)
|
||||||
|
+ codec = avcodec_find_encoder_by_name("h264_omx");
|
||||||
|
+ else if (ffmpeg->oc->oformat->video_codec == AV_CODEC_ID_MPEG4)
|
||||||
|
+ codec = avcodec_find_encoder_by_name("mpeg4_omx");
|
||||||
|
+ if (!codec)
|
||||||
|
+ codec = avcodec_find_encoder(ffmpeg->oc->oformat->video_codec);
|
||||||
|
if (!codec) {
|
||||||
|
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Codec %s not found", ffmpeg_video_codec);
|
||||||
|
ffmpeg_cleanups(ffmpeg);
|
25
package/motion/0004-h264-best-crf-quality.patch
Normal file
25
package/motion/0004-h264-best-crf-quality.patch
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
diff --git a/ffmpeg.c b/ffmpeg.c
|
||||||
|
index 3f48db8..1819e35 100644
|
||||||
|
--- a/ffmpeg.c
|
||||||
|
+++ b/ffmpeg.c
|
||||||
|
@@ -419,6 +419,8 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename,
|
||||||
|
c->codec_id = ffmpeg->oc->oformat->video_codec;
|
||||||
|
c->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
|
c->bit_rate = bps;
|
||||||
|
+ if (ffmpeg->oc->oformat->video_codec == AV_CODEC_ID_H264)
|
||||||
|
+ av_opt_set(c->priv_data, "crf", "1", AV_OPT_SEARCH_CHILDREN);
|
||||||
|
c->width = width;
|
||||||
|
c->height = height;
|
||||||
|
c->time_base.num = 1;
|
||||||
|
diff --git a/ffmpeg.h b/ffmpeg.h
|
||||||
|
index ccdc0f1..7067569 100644
|
||||||
|
--- a/ffmpeg.h
|
||||||
|
+++ b/ffmpeg.h
|
||||||
|
@@ -13,6 +13,7 @@
|
||||||
|
#include <libavformat/avformat.h>
|
||||||
|
#include <libavutil/imgutils.h>
|
||||||
|
#include <libavutil/mathematics.h>
|
||||||
|
+#include <libavutil/opt.h>
|
||||||
|
|
||||||
|
#if (LIBAVFORMAT_VERSION_MAJOR >= 56)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user