When trying to write MP4 file (H264), I tired code of
1 2 3 4 |
fourcc = cv2.VideoWriter_fourcc(*'MP4V') //or fourcc = cv2.VideoWriter_fourcc(*'X264') voObj = cv2.VideoWriter('output.mp4',fourcc, 15.0, (1280,360)) |
And I got error saying:
1 |
<span class="pln">FFMPEG</span><span class="pun">:</span><span class="pln"> tag </span><span class="lit">0x5634504d</span><span class="pun">/</span><span class="str">'MP4V'</span> <span class="kwd">is</span> <span class="kwd">not</span><span class="pln"> supported </span><span class="kwd">with</span><span class="pln"> codec id </span><span class="lit">13</span> <span class="kwd">and</span><span class="pln"> format </span><span class="str">'mp4 / MP4 (MPEG-4 Part 14)'</span> |
This problem is solved by changing the fourcc to the ASCII number directly to cv2.VideoWriter(), i.e.
1 |
outputVideo.open(writeName, 0x00000021, texHelper->caps[0].get(cv::CAP_PROP_FPS), S, true); |
reference: