In order to encode the video in Python, a four characters string is used to define the coding method. I tried to set the code to ‘MP4V’, as suggested by online references
But it’s not working. I got an error message saying ,
OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 13 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x00000020/' ???'
Encoding avi video works by setting the FOURCC code to ‘XVID’. For example,
Thanks WayneWWW. I tried “X264” as suggested but still failed.
OpenCV: FFMPEG: tag 0x34363258/'X264' is not supported with codec id 28 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x00000021/'!???'
Any other thoughts?
PS. Perhaps I should ask, is there a better way to write out mp4 than what I did like below:
fourcc = cv2.VideoWriter_fourcc(*'X264')
voObj = cv2.VideoWriter('output.mp4',fourcc, 15.0, (1280,360))
while True:
# . . . some settings . . .
ret_val0, dispBuf = cap.read();
voObj.write(dispBuf)
# . . . more stuff
I Google searched the FOURCC thing, couldn’t find an official statement besides a general disclaimer in docs of OpenCV 3.0 saying that “FourCC is a 4-byte code used to specify the video codec. The list of available codes can be found in fourcc.org. It is platform dependent.” OpenCV: Getting Started with Videos
FI also went to OURCC.org, it has a list of ton of codecs to choose, I tried “X264”, “H264”, “MP4V”, “mp4v” . . .none of those worked on TX2. Best Online Casinos - Four Countries Casinos
Some people hinted to give up on cv2.VideoWriter_fourcc(). Alternatively, plug in the ASCII number directly to cv2.VideoWriter(). So, here is what I tried:
This accepted “solution” is circular. You claim in comment #3 that that your write fails, with OpenCV telling you “OpenCV: FFMPEG: fallback to use tag 0x00000021/‘!???’”. Then in your comment #4 you simply hard coded in the tag 0x00000021/‘!???’ (which is what OpenCV was doing for you prior) and you claim the solution now works.
@GWAVE, I plugged in the code “0x00000021” directly to my Python code (instead of generating the fourcc using cv2.VideoWriter_fourcc function, see the code in comment #4). It seems working. I haven’t experimented it on the latest version of Jetson.