3

I'm currently trying to save a video stream into files using gst-launch while simultaneously watching the video itself (using v4l2src). As of now I got this by doing a work around with saving the images to files using ! multifilesink while having a tcl-script that automatically shows the newest file in one folder in an X windows. This works but has of course a bit of a delay I would like to reduce.

Is there a possibility to do this with only using gst-launch? I'm not very experienced with gstreamer unfortunately. Could it be done saving the files with multifilesink while showing them using multifilesrc? Or is it impossible with only gst-launch?

miorli
  • 53
  • 1
  • 5

1 Answers1

7

It is possible, there is the 'tee' element that will replicate the stream in its source pads.

So, for example:

gst-launch-1.0 v4l2src ! tee name=t ! queue ! videoconvert ! autovideosink t. ! queue ! videoconvert ! jpegenc ! multifilesink location=image_%06d.jpg

This should have it displaying and saving to jpg with multifilesink.

Also, it seems that you are using gstreamer 0.10, it is (2 years?) obsolete and unmantained. Please move to 1.x

thiagoss
  • 2,034
  • 13
  • 8
  • Thanks. The vendor of the camera told me to use gstreamer 0.10 because the camera itself is only tested with it. Was wondering about it already. – miorli Sep 22 '14 at 14:13
  • The same solution applies to 0.10. Tee is present in 0.10, replace videoconvert with ffmpegcolorspace. All the rest should be the same. – thiagoss Sep 22 '14 at 17:35
  • Yeah, I actually had to do it like that with 0.10. The camera I'm using seems to have problems when using 1.0. Videoconvert just won't work (It's a monochrome camera). – miorli Sep 23 '14 at 06:39
  • That is weird. Videoconvert can handle grayscale input (as long as it is not really monochrome/binary) it should work. Do you get any error from the pipeline? You could be missing a videoconvert before jpegenc. (I just updated the reply above). It would be great to move to 1.x as you would benefit from updates and bugfixes. – thiagoss Sep 23 '14 at 13:36
  • whenever I use gst-launch 1.0 v4l2src ! videoconvert ! ximagesink it says: Tried to capture in YV12, but device returned format GREY When I add ! video/x-raw,format=GREY ! it says it can't link v4l2src to videconvert. That's why I'm using 0.10. It works with ffmpegcolorspace. – miorli Sep 25 '14 at 13:40
  • The 1.0 caps formats are: GRAY8, GRAY16_BE, GRAY16_LE, and v4l2src code maps GREY to GRAY8. So in the caps filter you should use GRAY8, GREY is from the v4l2 APIs. Do you want to capture in YV12 or GRAY8? Does your device support YV12? And what happens if you don't specify the format? – thiagoss Sep 26 '14 at 18:41
  • If I don't specify the format I get an error that gstreamer tried to get the format in yv12 but encountered GREY, so I tried GREY. Thanks for the hinter, unfortunately I can only try GRAY8 in one week from now. YV12 isn't supported by the device and we are fine with GRAY8. – miorli Sep 27 '14 at 21:41
  • Ok. After reinstallation of the whole system it now works. At least with "ximagesink". "autovideosink" doesn't work at all, I still get the GRAY/YV12 problem there. – miorli Oct 06 '14 at 08:56