Open duanegi opened 6 years ago
The message really means "matched the codec/fourcc pair from the fallback list rather than the list associated with the file extension" ... not really sure why such a message needs to be printed to stderr
The current message "OpenCV:: FFMPEG: tag 0x%0dx/'%c%c%c%c%c' is not supported with codec id %d and format %s/%x\n" really does not seem to indicate correctly was is going on...
This issue can up because the .avi based mpeg1 encoder does not support file concatenation; whereas, the fallback mpeg1 decoder does correctly support this. Hence, for mpeg1, one is forced to live with this error message.
System information (version)
Detailed description
When one runs the following code:
fourcc = cv2.VideoWriter_fourcc(*'PIM1') out = cv2.VideoWriter('output.mpeg',fourcc, 20.0, (640,480))
The code complains about an invalid fourcc value, but still runs correctly.
Steps to reproduce
The problem seems to be in cap_ffmpeg_impl.hpp ( CvVideoWrite_FFMPEG::open )
This code first uses the file extension (av_guess_format) to find an appropriate list of fourcc's to check for. If it does not find the fourcc in this list, it then uses a default list of fourcc's ( avformat_get_mov_video_tags). The fourcc checks are using av_codec_get_id().
After if finds a fourcc match, it then validates that the fourcc is in the original list from the file extension, and prints an error message if this is the case. When the fourcc is from the default list, it does not match the original list, so an error message is always printed in this case. The error message is just informational and does not change the program flow.
There seems to be two solutions: (1) remove the final valid step (not sure why needed) (2) validate against the default list when use default list (this seems to be the easier of the two)
The change for (2) is quite small: