OpenCV 4 for Java, random error with VideoWriter [closed]
I am using JRE 1.8.0_191 and Open CV 4 for Java and my application is able to grab to a file, on user demand, a video stream from an IP camera. The application starts, opens the ip stream, creates a thread and continuously grab frames into a circular buffer. When it is asked by the user to grab video, creates a new thread where the specific videowriter is created, and saves the frames into a file, closing the videowriter after a given time. The frames grabbing thread and the disk thread communicates via a blocking queue, for optimal separation. When finished a grabbin request, the whole app returns grabbin' frames until it receives the next command to save the video. The fps is 25 per second and the resolution is 640x480; a single video can last up to 10 minutes but can be also closed before this timeout, if the user asks to do so..
So, each time a video is saved a new thread with a videowriter is built (this is due to internals of the architecture of the whole app). Concerning videowriter, this is the code "theVideoWriter = new VideoWriter(fileName, VideoWriter.fourcc('H', '2', '6', '4'), fps, frameSize); theVideoWriter.set(Videoio.CAP_PROP_FOURCC, fourcc);". Concerning writing frames I use: "theVideoWriter.write(theGrabbedFrame)" in the same thread.
Everything works really fine and I can execute the app for days and everything work fine. During dry runs I successfully grabbed even more than 2k video files.
The point is that, sometimes (10 times on more than 2k of video files), i got the following error: [libopenh264 @ 00000000207edd80] Incorrect library version loaded Could not open codec 'libopenh264': Unspecified error OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
It really seems to be a random error since there are no evident causes which make it happen. Moreover, a lot of video files are saved with the same settings (H264 and mp4) during the same session.
Do someone has some clue/suggestions on that?
Thank you, Luca