Issue
I have a script which uses OpenCV
and python
and creates a video ( avi
format ) from a set of png
images.
The resolution of these images is good.
The problem is that the resolution of the resulting video is very low.
How can I improve the resolution?
Is the low resolution related to the images format?
CODE:
writer = cv2.VideoWriter( "C:\Users\.../demo3_4.avi", -1, 1, ( width, height ) )
nFrames = 24
for i in range( 1, nFrames ):
img = cv2.imread( os.path.join( str( inf ), "colorraster%d.jpg"%i ) )
writer.write( img )
cv2.destroyAllWindows()
writer.release()
Solution
According to the documentation, cv2.VideoWriter
has fourcc
parameter which specifies the codec, used to compress the frames. You are now specifying '-1' which means some default codec. I would suggest experimenting with different codecs from that list and see what gives the best result.
Update: To translate the codec into an int, the docs recommend this: CV_FOURCC('P','I','M','1')
if you wanted to try codec PIM1.
Answered By - Ashalynd
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.