import numpy
import cv2
import random
image=cv2.imread(r"C:\Users\Sriram\Desktop/img.png")
print(image.shape)
image=cv2.resize(image,(1080,600))
fourcc=cv2.VideoWriter_fourcc(*"MP4V")
def rand():
n=random.randrange(0,255,15)
x=random.randrange(0,255,15)
y=random.randrange(0,255,15)
return cv2.copyMakeBorder(image,40,40,40,40,cv2.BORDER_CONSTANT,None,(x,n,y))
#cv2.imwrite(r"C:\Users\Sriram\Desktop/new.jpg",image)
l=[rand() for i in range(30)]
print(l)
video=cv2.VideoWriter(r"C:\Users\Sriram\Desktop/video.mp4",fourcc,25,(1080,600))
for i in l:
video.write(i)
cv2.destroyAllWindows()
video.release()
this is my code to create a video from image just by changing border of images and it worked and outputs a video file.but the video file does not open in my pc when i try to play video it syas incorrect compression code fourcc i tried different fourcc "xvid","mpv4","mpjg"nothing worked out