What does the following error message mean?
yxchng opened this issue · 4 comments
OpenCV Error: Assertion failed (image->depth == 8) in writeFrame, file /home/yxchng/OpenCV/modules/videoio/src/cap_ffmpeg.cpp, line 272
I follow the VideoWriter example but I couldnt save a video. Instead I got the above error.
It's an error similar to this one. Be careful about image depth (RGB or grayscale) and the type of video codec you use. Try different options.
@shrubb I tried using XVID, MPEG, H264. All don't work. Image depth is rgb.
If i can do imwrite why i cant do videowriter.write?
Because OpenCV works this way -- every function has constraints on the types of input matrices (images). imwrite
has nothing to do with VideoWriter.write
, they are completely different functions with different constraints.
Image depth can't be RGB. This is the channel layout. Depth is the number of bits per pixel. As far as I remember, VideoWriter typically requires 8 bit per channel pixel. So it should work with ByteTensors.
https://stackoverflow.com/questions/38880740/python-opencv-cv2-videowriter-error
add np.uint8(your_variable) before write