Reading .mp4 file with gstreamer and opencv on jetson nano

I use
cap = cv2.VideoCapture(‘filesrc location=Calibration_footage.mp4 ! qtdemux ! queue ! h264parse ! omxh264dec ! nvvidconv ! video/x-raw,format=BGRx ! queue ! videoconvert ! queue ! video/x-raw, format=BGR ! appsink’, cv2.CAP_GSTREAMER)
to read .mp4 file,it can be read successfully but misaligned.

Hi @qun,

What do you mean with misaligned? I seems you are using OpenCV over Python, do you get the same behaviour when executing the pipeline with gst-launch-1.0?

Regards,
Fabian
www.ridgerun.com

sorry,I use c++,below is my code:

std::string local_pipeline(“filesrc location=/home/ap/Documents/jetson/darknet/1.mp4 ! qtdemux ! queue ! h264parse ! omxh264dec ! nvvidconv ! video/x-raw,format=BGRx ! queue ! videoconvert ! queue ! video/x-raw,format=BGR ! appsink”);
cv::VideoCapture cap(local_pipeline,cv::CAP_GSTREAMER);

Misaligned likes
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
change to
1 1 1 1
1 2 2 2
2 2 3 3

can you understand?
Thanks.

I use the below command can display video correctly,

gst-launch-1.0 filesrc location=file.mp4 ! qtdemux name=demux demux.video_0 ! queue ! h264parse ! omxh264dec ! nveglglessink -e

so,I guess the error is in the videoconvert of
std::string local_pipeline(“filesrc location=/home/ap/Documents/jetson/darknet/1.mp4 ! qtdemux ! queue ! h264parse ! omxh264dec ! nvvidconv ! video/x-raw,format=BGRx ! queue ! videoconvert ! queue ! video/x-raw,format=BGR ! appsink”); ?
Thanks.

Hi @qun,

Nvvidconv can be used as a hardware alternative for videoconvert. So may be you can test with:

std::string local_pipeline(“filesrc location=/home/ap/Documents/jetson/darknet/1.mp4 ! qtdemux ! queue ! h264parse ! omxh264dec ! nvvidconv ! video/x-raw,format=BGRx !  appsink”);

Regards,
Fabian
www.ridgerun.com

Thank you very much.
I solve it with adding flip-method.