I’m using EmguCv and I’m trying to use VideoWriter to create video from Mat frames.
I have tried to create VideoWriter objects using multiple FourCC codecs like XVID, DIVX, MJPG, MPEG … No one works for me.
How can I see codecs available on my Windows 10? I have also tried with codec 0 or codec -1 and no popup is shown to selec codec.
I’m always getting this Exception
“Unable to create VideoWriter. Make sure you have specific Codec installed”
call cv::getBuildInformation() and check the video I/O section.
MJPG in an .AVI container always works because it’s built-in.
you need to present a MRE. so far, you haven’t presented any code. there’s nothing to debug for anyone.
If you have an issue with Emgu, contact those people. they aren’t just a wrapper around OpenCV. they changed the API in non-trivial ways. it’s up to them to support their stuff.
what Mats are you trying to write? shape (mind the order of width and height), element type, …
also remember to release() the writer.
your code snippet asks for an .mp4 file. ffmpeg should handle that but it’s not built-in. only .AVI container carrying MJPG is built-in. if there’s an issue with ffmpeg, that will matter. if the issue is with the frames you try to write, it will not matter.
Hi,
The exception is thrown on VideoWriter creation, I’m not able to write any Mat object into de writer.
I’ll try to explain better what I want to do. I’m reading frames from an Intel.RealSense camera and do some processing like motion detection with OpenCv (or EmguCv or OpenCvSharp).
After that I want to stream the processed frames using RTSP, so other clients can play the processed images with the motion detection applied (rectangles inside the image).
Also I need the streaming to be multicast (multiple clients at same time have to be able to play streaming).
For the streaming I think that FFMEPG or GStreamer can do the work (I’m not an expert on that) but I think that RTSP is the commonly used protocol for my target.
I’m open to other options or alternatives if you think that I’m on the wrong way.
I have seen this message in the console when trying to create VideoWriter with MJPG.
Also I have try with OpenCvSharp and the message is the same.
OpenCV: FFMPEG: tag 0x47504a4d/‘MJPG’ is not supported with codec id 7 and format ‘mp4 / MP4 (MPEG-4 Part 14)’
OpenCV: FFMPEG: fallback to use tag 0x7634706d/‘mp4v’
Also I have try to create VideoWriter with OpenCvSharp with codec -1 and this is the codec list in the console.
OpenCV: FFMPEG: format mp4 / MP4 (MPEG-4 Part 14)
fourcc tag 0x7634706d/‘mp4v’ codec_id 000C
fourcc tag 0x31637661/‘avc1’ codec_id 001B
fourcc tag 0x33637661/‘avc3’ codec_id 001B
fourcc tag 0x31766568/‘hev1’ codec_id 00AD
fourcc tag 0x31637668/‘hvc1’ codec_id 00AD
fourcc tag 0x7634706d/‘mp4v’ codec_id 0002
fourcc tag 0x7634706d/‘mp4v’ codec_id 0001
fourcc tag 0x7634706d/‘mp4v’ codec_id 0007
fourcc tag 0x7634706d/‘mp4v’ codec_id 003D
fourcc tag 0x7634706d/‘mp4v’ codec_id 0058
fourcc tag 0x312d6376/‘vc-1’ codec_id 0046
fourcc tag 0x63617264/‘drac’ codec_id 0074
fourcc tag 0x7634706d/‘mp4v’ codec_id 00A3
fourcc tag 0x39307076/‘vp09’ codec_id 00A7
fourcc tag 0x31307661/‘av01’ codec_id 801D
fourcc tag 0x6134706d/‘mp4a’ codec_id 15002
fourcc tag 0x63616c61/‘alac’ codec_id 15010
fourcc tag 0x6134706d/‘mp4a’ codec_id 1502D
fourcc tag 0x6134706d/‘mp4a’ codec_id 15001
fourcc tag 0x6134706d/‘mp4a’ codec_id 15000
fourcc tag 0x332d6361/‘ac-3’ codec_id 15003
fourcc tag 0x332d6365/‘ec-3’ codec_id 15028
fourcc tag 0x6134706d/‘mp4a’ codec_id 15004
fourcc tag 0x61706c6d/‘mlpa’ codec_id 1502C
fourcc tag 0x43614c66/‘fLaC’ codec_id 1500C
fourcc tag 0x7375704f/‘Opus’ codec_id 1503C
fourcc tag 0x6134706d/‘mp4a’ codec_id 15005
fourcc tag 0x6134706d/‘mp4a’ codec_id 15018
fourcc tag 0x6134706d/‘mp4a’ codec_id 15803
fourcc tag 0x7334706d/‘mp4s’ codec_id 17000
fourcc tag 0x67337874/‘tx3g’ codec_id 17005
fourcc tag 0x646d7067/‘gpmd’ codec_id 18807
fourcc tag 0x316d686d/‘mhm1’ codec_id 15817
You said that only .AVI container carrying MJPG is built-in. What is the FourCC code for Avi container with MJPG? I tried with MPEG, AVC1, MP4V, ut seems none of those working.
Your problem is probably in the output video file suffix, which should match MJPG codec for AVI - now the library tries to find a codec for .mp4 files, and fails. Try .avi for the suffix.
FFMPEG can’t do the work? why? Is there any other option different than using VideoWriter? I was exploring first FFMPEG because is built-in in the Windows compilation, to include GStreamer backend it seems to be neccesary to rebuild OpenCv.
Thanks for your reply.
What do you think is the best way to create an RTSP server from Mat frames? I’m trying to use VideoWriter because it’s the way that I’ve found, but I’m not an expert on that.
To use Gstreamer I think it’s a little bit complicated because I have to rebuild OpenCv distribution for Windows.
Do you know some good guide to follow it?