OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.48k stars 2.18k forks source link

OpenCV: FFMPEG: tag is not supported with codec id 12 and format 'mp4 / MP4 #809

Open alexpavlidespyrra opened 1 year ago

alexpavlidespyrra commented 1 year ago

This error happens when calling:

detections = self.video_detector.detectObjectsFromVideo(input_file_path=input_data,
                                        output_file_path=output_video_path,
                                        frames_per_second=frames_per_second,
                                        minimum_percentage_probability=min_percent_prob,
                                        video_complete_function=self.get_output)

I had a look under the hood and this line caused the problem:


output_video = cv2.VideoWriter(output_video_filepath, cv2.VideoWriter_fourcc(*"MP4V"),
                                            frames_per_second,
                                            (frame_width, frame_height))

According to this post https://stackoverflow.com/questions/57792837/opencv-ffmpeg-tag-is-not-supported-with-codec-id-12-and-format-mp4-mp4 changing MP4V to lowercase mp4v fixes the problem. I tried it and it fixed the problem. Please can you make this change? Thanks.

OlafenwaMoses commented 10 months ago

@alexpavlidespyrra thanks, will effect this change in next update.