Crossposted from this link https://python-forum.io/Thread-How-to-modify-video-using-pixel-array-or-shader
Hello guys I am trying to apply some effects to my video.. what I need is to apply some effects to the realvideo file.. I dont need to display the video.
I am trying to read .mp4 video then apply some effects with out showing GUI.. I just want to save it in my local file.. my codes looks like this.
import numpy as np import cv2
cap = cv2.VideoCapture('test.mp4')
fourcc = cv2.VideoWriter_fourcc(*'MP4V') #mpeg
width = int(cap.get(3)) height = int(cap.get(4)) out = cv2.VideoWriter('output.mp4',fourcc, 20.0, (width,height))
while(cap.isOpened()): ret, frame = cap.read() hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) if ret==True: frame = cv2.flip(frame,1) #0 = upside down , 1 = normal
#I need some pixel array or shader code here to apply effects to my video.
out.write(frame)
#cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
Release everything if job is finished
cap.release() out.release() cv2.destroyAllWindows()