Closed DhananjayHuidrom closed 3 years ago
Failed to create a video file from live ip camer. Please help.
C#, visual studio 2019, .net core 3.1, OpenCvSharp4 (4.5.1.20210208)
1) .mjpg: Video is created with size of 0 kb 2) .avi: Video is failed to create
const string OutVideoFile = "E:\output.mjpg"; var url = "rtsp://user:pass@ipaddress:554/cam/realmonitor?channel=1&subtype=0"; OpenCvSharp.Size dsize = new OpenCvSharp.Size(640, 480); VideoCapture capture = new VideoCapture(url); using (VideoWriter writer = new VideoWriter(OutVideoFile, FourCC.MJPG, 25, dsize)) { if(writer.IsOpened() == false) { Console.WriteLine("Failed to open writer."); return; }
Console.WriteLine("Converting each movie frames..."); Mat frame = new Mat(); while (true) { // Read image capture.Read(frame); if (frame.Empty() || capture.PosFrames > 100) { writer.Release(); break; } //Cv2.ImShow("v", frame); Console.CursorLeft = 0; Console.Write("{0} / {1}", capture.PosFrames, capture.FrameCount); writer.Write(frame); Cv2.WaitKey(50); } Console.WriteLine(); }
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mjpeg / raw MJPEG video'
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Summary of your issue
Failed to create a video file from live ip camer. Please help.
Environment
C#, visual studio 2019, .net core 3.1, OpenCvSharp4 (4.5.1.20210208)
Issue / problem?
1) .mjpg: Video is created with size of 0 kb 2) .avi: Video is failed to create
Example code:
const string OutVideoFile = "E:\output.mjpg"; var url = "rtsp://user:pass@ipaddress:554/cam/realmonitor?channel=1&subtype=0"; OpenCvSharp.Size dsize = new OpenCvSharp.Size(640, 480); VideoCapture capture = new VideoCapture(url); using (VideoWriter writer = new VideoWriter(OutVideoFile, FourCC.MJPG, 25, dsize)) { if(writer.IsOpened() == false) { Console.WriteLine("Failed to open writer."); return; }
Output:
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mjpeg / raw MJPEG video'
What did you intend to be?