From 5b3def098d97e9930bbface3c30aee4bf5ae0434 Mon Sep 17 00:00:00 2001 From: "zejian.su" Date: Mon, 6 Nov 2023 16:14:19 +0800 Subject: [PATCH] Fix the bug in libcamera-vid. It prompt: failed to open v4l2 H264 encoder. The reason is loss if encoder options and definement. Sign-off-by: zejian.su --- ...0004-Make-libcamera-vid-run-normally.patch | 67 +++++++++++++++++-- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/package/starfive/libcamera-apps/0004-Make-libcamera-vid-run-normally.patch b/package/starfive/libcamera-apps/0004-Make-libcamera-vid-run-normally.patch index 7c40709c..0238a85e 100644 --- a/package/starfive/libcamera-apps/0004-Make-libcamera-vid-run-normally.patch +++ b/package/starfive/libcamera-apps/0004-Make-libcamera-vid-run-normally.patch @@ -1,9 +1,11 @@ -From 687ce90d3cccfef1ef6207e4856212d244fddabc Mon Sep 17 00:00:00 2001 +From 1ef1752d44921737247635ba028821332d053aef Mon Sep 17 00:00:00 2001 From: "zejian.su" -Date: Thu, 12 Oct 2023 13:59:07 +0800 -Subject: [PATCH 4/4] Make libcamera-vid run normally +Date: Mon, 6 Nov 2023 13:43:41 +0800 +Subject: [PATCH] Make libcamera-vid run normally --- + core/libcamera_encoder.hpp | 1 + + core/video_options.hpp | 20 +- encoder/CMakeLists.txt | 7 +- encoder/encoder.cpp | 6 +- encoder/h265_encoder.cpp | 422 ++++++ @@ -26,7 +28,7 @@ Subject: [PATCH 4/4] Make libcamera-vid run normally encoder/mjpeg_encoder.cpp | 19 +- encoder/yuv420_encoder.cpp | 80 ++ encoder/yuv420_encoder.hpp | 41 + - 22 files changed, 8287 insertions(+), 4 deletions(-) + 24 files changed, 8296 insertions(+), 16 deletions(-) create mode 100755 encoder/h265_encoder.cpp create mode 100755 encoder/h265_encoder.hpp create mode 100755 encoder/include/khronos/OMX_Audio.h @@ -47,6 +49,63 @@ Subject: [PATCH 4/4] Make libcamera-vid run normally create mode 100755 encoder/yuv420_encoder.cpp create mode 100755 encoder/yuv420_encoder.hpp +diff --git a/core/libcamera_encoder.hpp b/core/libcamera_encoder.hpp +index 892b153..293cc58 100644 +--- a/core/libcamera_encoder.hpp ++++ b/core/libcamera_encoder.hpp +@@ -16,6 +16,7 @@ + typedef std::function EncodeOutputReadyCallback; + typedef std::function MetadataReadyCallback; + ++ + class LibcameraEncoder : public LibcameraApp + { + public: +diff --git a/core/video_options.hpp b/core/video_options.hpp +index 395d0a8..b3f9469 100644 +--- a/core/video_options.hpp ++++ b/core/video_options.hpp +@@ -23,17 +23,13 @@ struct VideoOptions : public Options + // clang-format off + options_.add_options() + ("bitrate,b", value(&bitrate)->default_value(0), +- "Set the video bitrate for encoding, in bits/second (h264 only)") +- ("profile", value(&profile), +- "Set the encoding profile (h264 only)") +- ("level", value(&level), +- "Set the encoding level (h264 only)") ++ "Set the video bitrate for encoding, in bits/second (h265 only)") + ("intra,g", value(&intra)->default_value(0), +- "Set the intra frame period (h264 only)") ++ "Set the intra frame period (h265 only)") + ("inline", value(&inline_headers)->default_value(false)->implicit_value(true), +- "Force PPS/SPS header with every I frame (h264 only)") +- ("codec", value(&codec)->default_value("h264"), +- "Set the codec to use, either h264, " ++ "Force PPS/SPS header with every I frame (h265 only)") ++ ("codec", value(&codec)->default_value("h265"), ++ "Set the codec to use, either h265, " + #if LIBAV_PRESENT + "libav, " + #endif +@@ -123,14 +119,14 @@ struct VideoOptions : public Options + width = 640; + if (height == 0) + height = 480; +- if (strcasecmp(codec.c_str(), "h264") == 0) +- codec = "h264"; +- else if (strcasecmp(codec.c_str(), "libav") == 0) ++ if (strcasecmp(codec.c_str(), "libav") == 0) + codec = "libav"; + else if (strcasecmp(codec.c_str(), "yuv420") == 0) + codec = "yuv420"; + else if (strcasecmp(codec.c_str(), "mjpeg") == 0) + codec = "mjpeg"; ++ else if (strcasecmp(codec.c_str(), "h265") == 0) ++ codec = "h265"; + else + throw std::runtime_error("unrecognised codec " + codec); + if (strcasecmp(initial.c_str(), "pause") == 0) diff --git a/encoder/CMakeLists.txt b/encoder/CMakeLists.txt index a426a45..4f36270 100644 --- a/encoder/CMakeLists.txt