can't open capture from gstreamer loopback
This is maybe a bit obscure as it involves a problem with several tools together rather than just CV; I don't know where else to ask other than the CV forum though so maybe someone could at least point me to something:
I just want to play an mp4 video file into two independent CV programs so that they are synced to see the same frames. It seems remarkably hard to do this! I'm also trying to avoid passing ROS messages of raw images around as they are raw and big and slow.
I am running OpenCV3 in ROS (which is needed for other things) so I am using the CV version that comes with ROS and is not compiled with gstreamer.
My plan was to use gstreamer to pipe the file into a V4L loopback device, then have the two CV programs open captures from that device. This works very nicely if I do it with the gstreamer testcard:
gst-launch-1.0 -v videotestsrc ! tee ! v4l2sink device=/dev/video1
and then run two CV programs which both open the capture:
ret,frame = cv2.VideoCapture(1)
However if I try to do the same with the file,
gst-launch-1.0 filesrc location=~/in.mp4 ! decodebin ! videoconvert ! videorate ! video/x-raw, framerate=25/5 ! v4l2sink device=/dev/video1
then my CV programs barf, my line ret,frame = cv2.VideoCapture(1) returns False and no data, and prints, V4L2: Pixel format of incoming image is unsupported by OpenCV
Using v4l-ctl to test the formats shows the webcam version is using YUYV format and this file stream version is giving YU12 format so maybe this is the problem? But I'm utterly stumped how to convert that using gstreamer (and it's wonderful errors messages) and/or CV.
What a nightmare ... any ideas? Suggestions for completely alternative solutions also very welcome!