how to modify video using pixel array or shader?
Crossposted from this link https://python-forum.io/Thread-How-to...
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()
opencv is a computer-vision library, while you are trying to build a video editing software.
Ah well I get you want also some conversion on a pixel level, so you can do it with OpenCV but you are doing a
cvtColor
without checking if the frame is actually read and has content. Furthermore, without defining what filter you want, we cannot provide you with suggestions on what filters to use :D