answered
2020-04-17 21:06:47 +0200
I just found this question because I also wanted to use the phone's camera image on another computer.
For me, even your first example fails twice for me:
> gst-launch-1.0 -v droidcamsrc mode=2 ! video/x-raw ! fakesink
[...]
** (gst-launch-1.0:20467): CRITICAL **: 19:52:03.716: gst_pad_set_caps: assertion 'caps != NULL && gst_caps_is_fixed (caps)' failed
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstDroidCamSrc:droidcamsrc0: The stream is in the wrong format.
Additional debug info:
gstdroidcamsrcmode.c(202): gst_droidcamsrc_mode_negotiate_pad (): /GstPipeline:pipeline0/GstDroidCamSrc:droidcamsrc0:
failed to negotiate vidsrc.
[...]
Freeing pipeline ...
double free or corruption (out)
Aborted
(I played around with different commands and gstreamer seems to have memory management issues - it also has some memory leaks which quickly use up all memory when using "incorrect" pipelines)
I tried (but failed) to replicate the pipeline from there: https://github.com/sailfishos/gst-droidcamsrc/blob/master/test/video.c as command line:
> gst-launch-1.0 droidcamsrc mode=2 ! filesink location=foo.yuv
[...]
** (gst-launch-1.0:20913): CRITICAL **: 19:56:59.176: gst_pad_set_caps: assertion 'caps != NULL && gst_caps_is_fixed (caps)' failed
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstDroidCamSrc:droidcamsrc0: The stream is in the wrong format.
Additional debug info:
gstdroidcamsrcmode.c(202): gst_droidcamsrc_mode_negotiate_pad (): /GstPipeline:pipeline0/GstDroidCamSrc:droidcamsrc0:
failed to negotiate vidsrc.
Even when directly attacking the Pads as described in https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html :
> gst-launch-1.0 droidcamsrc.vidsrc mode=2 ! filesink.sink location=foo.yuv
ERROR: pipeline could not be constructed: unexpected reference "droidcamsrc" - ignoring.
Interestingly, the following at least runs (but shows an garbled image):
ssh MYPHONEHOSTNAME gst-launch-1.0 droidcamsrc ! videoconvert ! rtpvrawpay ! filesink location=/dev/stdout | gst-launch-1.0 filesrc location=/dev/stdin ! videoparse ! autovideoconvert ! autovideosink
edit: I guess this is related to the fact that droidcamsrc
has start-capture
/stop-capture
actions, which need to be triggered in video mode (mode=2
) to actually record a video. For taking photos (i.e., no mode specified) no such action needs to be called.
Unfortunately, afaik, we can't do such dynamic stuff via the command line. -> Use C or Python.
edit2:Confirm previous edit; also see example at https://github.com/sailfishos/gst-droidcamsrc/blob/master/test/video.c#L35