Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Unable to save a video file

$
0
0
Hi everyone, first time here so please be gentle ;) Here it goes I try to open a video file, do some detection inside, draw contours and then save everything in a new file with the same properties everything works as intended except the creating and writing in a new file part I try to set the fourcc manualy by using H264 MPG4 etc I always get an error like : encoder not found I tried -1 so i can choose from available codec but i don't get any choice i don't get it, I can open a video file but not create a new one ? when i use
out.isOpened()
it's always False so I have no idea what I do wrong here but I really can't find a wait to create a new file originaly i intended to use cv2.CAP_PROP_XXXX to get the properties from my file and use this information to create my new file. After reading and trying , a lot, i'm stuck with a FOURCC in double format and i really don't know how to convert it in char format
fps = int(cap.get(cv2.CAP_PROP_FPS))
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cap.get(cv2.CAP_PROP_FOURCC)

out = cv2.VideoWriter('C:\Users\John\Desktop\Test\output.mp4',fourcc, fps, (width,height))
I find two way to do this in C++ unfortunately I'm not experienced enough to figure out how to do this in python
 char EXT[] = {ex & 0XFF , (ex & 0XFF00) >> 8,(ex & 0XFF0000) >> 16,(ex & 0XFF000000) >> 24, 0};
union { int v; char c[5];} uEx ;
uEx.v = ex;                              // From Int to char via union
uEx.c[4]='\0';
anyway i'm stuck and i need some help

Viewing all articles
Browse latest Browse all 41027

Trending Articles