2

I wrote a program that reads frames from a gstreamer pipeline, processes them with opencv libraries and then writes back to the gstreamer pipeline.

Code snippet:

cv::VideoCapture cap("v4l2src ! video/x-raw, framerate=30/1, width=640, height=480, format=RGB ! videoconvert ! appsink");
if (!cap.isOpened()) {
    printf("=ERR= can't create video capture\n");
    return -1;
}

cv::VideoWriter writer;
writer.open("appsrc ! videoconvert ! x264enc noise-reduction=10000 tune=zerolatency byte-stream=true threads=4 key-int-max=15 ! mpegtsmux ! udpsink host=localhost port=9999"
            , 0, (double)15, cv::Size(640, 480), true);
if (!writer.isOpened()) {
    printf("=ERR= can't create video writer\n");
    return -1;
}

/* Read/write frames as usual */
// Mat frame
// while true
//     cap >> frame
//     process the frame
//     writer << frame

The program works great on my ubuntu 14.04 64bit VM. When I trying to run it on Jetson TK1, however, VideoCapture and VideoWriter always return false on isOpened().

I was using Opencv4Tegra, then I built opencv from source and installed it. Both were having the same problem. Does anyone know why VideoCapture can't open gstreamer pipeline on Jetson TK1? Is it because it doesn't work on 32bit machines?

Note that I'm using Opencv 2.4.13 and Gstreamer 1.2 and camera Logitech C310.

j0e1in
  • 696
  • 2
  • 8
  • 18
  • 1
    my personal feeling is that appsin/appsrc is blocked for either empty buffer or full buffer.. having appsrc and appsink is usually very tricky - do you have your processing logic in same thread as the pipelines live in(that is main thread?)? try adding queues and then try adding parameter max-bytes (be aware that it may eat whole RAM!) .. also debuging is very important - learn how to debug gstreamer (hint GST_DEBUG) - gl – nayana Jun 20 '16 at 07:47
  • @otopolsky Thank you for your reply. I didn't think adding `queue` and `max-bytes` to the pipeline helps. (I tried, but still the same.) Since it fails on constructing the capture object (it's not opened), it doesn't run the gstreamer pipeline. I think it's the problem between opencv and gstreamer, but not the pipeline. And because it doesn't run the pipeline, so I can't debug it with GST_DEBUG. Will try to run the program on another 32 bit machine. – j0e1in Jun 29 '16 at 18:00
  • It produced the same error when I tried to execute it on a Ubuntu 14.04 32 bit VM. So I'm almost certain it's the problem with 32 bit opencv, which cannot open a gstreamer pipeline using `VideoCapture` or `VideoWriter`. – j0e1in Jun 30 '16 at 04:49
  • Maybe its because the 64bit machine is more powerfull and will not load the buffers that much.. I think the same that your design of appsrc+appsink is blocking itself.. and the blocking behavior is triggered by the fact that you use it on weaker machine.. – nayana Jun 30 '16 at 06:17
  • also it may be a linking problem.. maybe the gstreamer libraries or opencv are not found or whatever.. you must check all this yourself ;) – nayana Jun 30 '16 at 10:12

0 Answers0