I am trying to save a video file as MP4 format in ubuntu16.04 using videoWriter function as below
int frame_width = cap.get(CV_CAP_PROP_FRAME_WIDTH);
int frame_height = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
VideoWriter video("/home/Desktop/1.mp4",CV_FOURCC('M','J','P','G'),10, Size(frame_width,frame_height));
But I am getting the error as below:
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 8 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x0000006c/'l???
When I change my output file extension to .avi, I get no error but VLC player doesn't display any video. I tried different players also but in vain.
I even did the following thinking my VLC might be a problem but didn't work. Really in need of a solution
sudo apt-get ubuntu-restricted-extras