Hi all,
I am trying to open a pipeline and create a VideoWriter object with OpenCV:
VideoCapture cap(" v4l2src ! video/x-raw,framerate=30/1,width=1920,height=1080 ! vpuenc_h264 ! avimux ! appsink ",CAP_GSTREAMER);
if(!cap.isOpened()){
std::cout<<"VideoCapture not opened";
exit(-1);
}
VideoWriter writer(" appsrc ! filesink location=video.avi ",0,30,Size(1920,1080),true);
It compiles, but when executed on the board i get:
Seems to be creating the pipeline but it gets stuck there.
Do you have any idea what could be happening?
Regards
已解决! 转到解答。
Still not working this way, however, cross compiling OpeCV with Gstreamer and FFmpeg support, i am able to run scripts I had no been able to run on Navq and it seems is using Gstreamer caps. The instructions on how I achieved it are under my gitbook https://hovergames.gitbook.io/hovergames2/
Still not working this way, however, cross compiling OpeCV with Gstreamer and FFmpeg support, i am able to run scripts I had no been able to run on Navq and it seems is using Gstreamer caps. The instructions on how I achieved it are under my gitbook https://hovergames.gitbook.io/hovergames2/
Hey Fabian,
It seems as if you just created a VideoWriter object, but you aren't writing to that object. Is the source code you supplied the entirety of what you've compiled?
You need to add the following to your code in a loop:
Mat frame;
cap.read(frame);
writer.write(frame);
Hi!!
Right, the code i shared was not complete.
The complete code is:
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
VideoCapture cap("v4l2src ! video/x-raw,framerate=30/1,width=1920,height=1080 ! vpuenc_h264 ! avimux ! appsink",CAP_GSTREAMER);
if(!cap.isOpened()){
cout<<"VideoCapture not opened";
return -1;
}
VideoWriter writer("appsrc ! filesink location=video.avi",VideoWriter::fourcc('M','J','P','G'),15,Size(1920,1080),true);
if(!writer.isOpened()){
cout<<"VideoWriter not opened";
return -1;
}
while(1){
Mat frame;
cap.read(frame);
writer.write(frame);
if(waitKey(1) == 27){
break;
}
}
cap.release();
writer.release();
return 0;
}