91 lines
3.4 KiB
Diff
91 lines
3.4 KiB
Diff
From a7fabf2b02ae99611d2c06ab85fc0f0c6275a9bf Mon Sep 17 00:00:00 2001
|
|
From: Jiajian Wu <jair.wu@rock-chips.com>
|
|
Date: Tue, 11 Jul 2023 16:10:23 +0800
|
|
Subject: [PATCH] camera: use H264 encoder and matroska muxer
|
|
|
|
Signed-off-by: Jiajian Wu <jair.wu@rock-chips.com>
|
|
---
|
|
libcheese/cheese-camera.c | 25 ++++++++++++++++---------
|
|
libcheese/cheese-fileutil.h | 2 +-
|
|
2 files changed, 17 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
|
|
index 2185892b..0201898a 100644
|
|
--- a/libcheese/cheese-camera.c
|
|
+++ b/libcheese/cheese-camera.c
|
|
@@ -441,12 +441,12 @@ cheese_camera_set_video_recording (CheeseCamera *camera, GError **error)
|
|
const gchar *video_preset;
|
|
gboolean res;
|
|
|
|
- /* Check if we can use global preset for vp8enc. */
|
|
- video_enc = gst_element_factory_make ("mppvp8enc", "vp8enc");
|
|
+ /* Check if we can use global preset for h264enc. */
|
|
+ video_enc = gst_element_factory_make ("mpph264enc", "videnc");
|
|
video_preset = (gchar *) &CHEESE_VIDEO_ENC_PRESET;
|
|
res = gst_preset_load_preset (GST_PRESET (video_enc), video_preset);
|
|
if (res == FALSE) {
|
|
- g_warning("Can't find vp8enc preset: \"%s\", using alternate preset:"
|
|
+ g_warning("Can't find h264enc preset: \"%s\", using alternate preset:"
|
|
" \"%s\". If you see this, make a bug report!",
|
|
video_preset, CHEESE_VIDEO_ENC_ALT_PRESET);
|
|
|
|
@@ -456,7 +456,7 @@ cheese_camera_set_video_recording (CheeseCamera *camera, GError **error)
|
|
video_preset = (gchar *) &CHEESE_VIDEO_ENC_ALT_PRESET;
|
|
res = gst_preset_load_preset (GST_PRESET (video_enc), video_preset);
|
|
if (res == FALSE) {
|
|
- g_warning ("Can't find vp8enc preset: \"%s\", "
|
|
+ g_warning ("Can't find h264enc preset: \"%s\", "
|
|
"creating new userspace preset.", video_preset);
|
|
|
|
/* Seems like we do first run and userspace preset do not exist.
|
|
@@ -469,14 +469,14 @@ cheese_camera_set_video_recording (CheeseCamera *camera, GError **error)
|
|
}
|
|
gst_object_unref(video_enc);
|
|
|
|
- /* create profile for webm encoding */
|
|
- caps = gst_caps_from_string("video/webm");
|
|
- prof = gst_encoding_container_profile_new("WebM audio/video",
|
|
- "Standard WebM/VP8/Vorbis",
|
|
+ /* create profile for matroska encoding */
|
|
+ caps = gst_caps_from_string("video/x-matroska");
|
|
+ prof = gst_encoding_container_profile_new("Matroska audio/video",
|
|
+ "Standard Matroska/H264/Vorbis",
|
|
caps, NULL);
|
|
gst_caps_unref (caps);
|
|
|
|
- caps = gst_caps_from_string("video/x-vp8");
|
|
+ caps = gst_caps_from_string("video/x-h264");
|
|
v_prof = gst_encoding_video_profile_new(caps, NULL, NULL, 0);
|
|
gst_encoding_video_profile_set_variableframerate(v_prof, TRUE);
|
|
gst_encoding_profile_set_preset((GstEncodingProfile*) v_prof, video_preset);
|
|
@@ -772,6 +772,13 @@ cheese_camera_set_new_caps (CheeseCamera *camera)
|
|
g_object_set (priv->effects_capsfilter, "caps", caps, NULL);
|
|
}
|
|
gst_caps_unref (caps);
|
|
+
|
|
+ caps = gst_caps_from_string ("audio/x-raw,rate=44100,channels=1,format=F32LE");
|
|
+ if (caps)
|
|
+ {
|
|
+ g_object_set (priv->camerabin, "audio-capture-caps", caps, NULL);
|
|
+ gst_caps_unref (caps);
|
|
+ }
|
|
}
|
|
|
|
void
|
|
diff --git a/libcheese/cheese-fileutil.h b/libcheese/cheese-fileutil.h
|
|
index 87f827f6..0e420ef7 100644
|
|
--- a/libcheese/cheese-fileutil.h
|
|
+++ b/libcheese/cheese-fileutil.h
|
|
@@ -36,7 +36,7 @@
|
|
*
|
|
* The filename suffix for videos saved by Cheese.
|
|
*/
|
|
-#define CHEESE_VIDEO_NAME_SUFFIX ".webm"
|
|
+#define CHEESE_VIDEO_NAME_SUFFIX ".mkv"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
--
|
|
2.25.1
|
|
|