FD- / RPiPlay

An open-source AirPlay mirroring server for the Raspberry Pi. Supports iOS 9 and up.
GNU General Public License v3.0
4.93k stars 353 forks source link

[Feature Request] Custom gstreamer pipeline #205

Open medicalwei opened 3 years ago

medicalwei commented 3 years ago

I found it useful to combine it with v4l2loopback and render it on OBS or other software that takes V4L2 feed, and make my phone an effective webcam with app like Filmic Pro that can output clean camera feed on external output, without the need of HDMI dongle and capture card, which is also compressed video anyways.

That was tricky because v4l2loopback seems cannot take feeds with resolution change, so I have to chain a videobox and fix the output resolution to 1920x1080 with black box surrounding it like television.

Anyways, we can provide parameters to customize gstreamer pipeline. However, this would sacrifice rotations and flips parameters.

medicalwei commented 3 years ago

Here's my changeset to redirect the video feed to v4l2loopback:

diff --git a/renderers/video_renderer_gstreamer.c b/renderers/video_renderer_gstreamer.c
index dee6d50..df4c5fc 100644
--- a/renderers/video_renderer_gstreamer.c
+++ b/renderers/video_renderer_gstreamer.c
@@ -69,7 +69,7 @@ video_renderer_t *video_renderer_gstreamer_init(logger_t *logger, video_renderer

     // Begin the video pipeline
     GString *launch = g_string_new("appsrc name=video_source stream-type=0 format=GST_FORMAT_TIME is-live=true !"
-                                   "queue ! decodebin ! videoconvert ! ");
+                                   "queue ! h264parse ! vaapih264dec ! videoconvert ! ");
     // Setup rotation
     if (config->rotation != 0) {
         switch (config->rotation) {
@@ -112,7 +112,9 @@ video_renderer_t *video_renderer_gstreamer_init(logger_t *logger, video_renderer
     }

     // Finish the pipeline
-    g_string_append(launch, "autovideosink name=video_sink sync=false");
+    g_string_append(launch, "videobox autocrop=true ! video/x-raw,width=1920,height=1080 ! ");
+    //g_string_append(launch, "autovideosink name=video_sink sync=false");
+    g_string_append(launch, "v4l2sink name=video_sink sync=false device=/dev/video9");

     renderer->pipeline = gst_parse_launch(launch->str, &error);
     g_assert(renderer->pipeline);
~