Hi,
I’m using Gstreamer from OpenCV to read a video, undistort it (in opencv) and write it back on disk. Instead of letting OpenCV do the reading and writing automatically, I am building a Gstreamer pipeline to ensure I’m using the GPU (Nvidia).
This is running on two different targets: my desktop and a Jetson Orin NX (an ARM-based edge computer with an Nvidia GPU)
Here’s how I read and write the video on my PC:
VideoCapture vid_capture("filesrc location=./input.mp4 ! qtdemux ! h264parse ! nvh264dec ! videoconvert ! appsink sync=false");
int h264 = VideoWriter::fourcc('H', '2', '6', '4');
VideoWriter video_writer("appsrc ! video/x-raw, format=BGR ! videoconvert ! nvh264enc bitrate=4000 ! filesink location=out.avi", h264, 25, video_size);
Because the plugins are slightly different on the edge computer, here is what I am running on the Jetson:
VideoCapture vid_capture("filesrc location=./input.mp4 ! qtdemux ! queue ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink sync=false");
int h264 = VideoWriter::fourcc('H', '2', '6', '4');
VideoWriter video_writer("appsrc ! video/x-raw, format=BGR ! queue ! videoconvert ! video/x-raw,format=RGBA ! nvvidconv ! nvv4l2h264enc ! filesink location=out.mp4", h264, 25, video_size);
The encoding and decoding is pretty fast thanks to the GPU plugins. However, the resulting video has a couple of issues:
- vlc doesn’t manage to open it
- On both platforms, the file’s properties are not set properly: no duration or framerate is set.
- Opening the desktop’s video with another video player works and I can see the video is exactly as expected. However when I open the video generated by the edge computer it plays at about 10 times the normal speed. It doesn’t look like there are missing frames, just that the framerate is not respected.
Does someone have any idea why ? Any help would be appreciated!
Thanks,
Antoine