Converting numpy array to video
See original GitHub issueI’m using OpenCV for processing a video, saving the processed video
Example:
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
frame = cv2.flip(frame,0)
# write the flipped frame
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()
Source file is FULL HD 2 minutes
clip in avi
format with Data Rate 7468kbps
Saved file is FULL HD 2 minutes
clip in avi
format with Data Rate 99532kbps
this is confusing
if i save each frame and give it to input, I get an error in the .output
saving there is no such file
import ffmeg
(
ffmpeg
.input('/path/to/jpegs/*.jpg', pattern_type='glob', framerate=25)
.output('movie.mp4')
.run()
)
How do i save the video as the same size as the source using ffmeg-python
?
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (1 by maintainers)
Top Results From Across the Web
python - Generate video from numpy arrays with openCV
I am trying to use the openCV VideoWriter class to generate a video from numpy arrays. I am using the following code:
Read more >Create Video from Images or NumPy Array using Python ...
In this Python OpenCV Tutorial, explain how to create a video using NumPy array and images. Video From NumPy Array ...
Read more >Python OpenCV – Create Video from Images
In this tutorial, we shall learn how to create a video from image numpy arrays. We shall go through two examples. The first...
Read more >How to make video from images and NumPy Array in OpenCV
In Python OpenCV Tutorial, Explained how to create video using Numpy Array and Images.Get the answers of below questions:1. how to make ...
Read more >Write Videos From Images using Scikit Video - ML Hive
Now we iterate over all images in directory and read images using pillow. After we read an image, we can convert it to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
not sure if this is what you were asking, but here is some code to save frames from memory straight to a video file. if you chop this up a little you could hack it into your initial code and avoid writing the jpgs to disk:
Edit 2020-01-28: My working version of this function is backed by a small class, implemented in my python-utils/ffmpeg.py
[Error 32] Broken Pipe
means the process errored and closed so there was no pipe to pipe input into. You can figure out what the error was by looking in process.stderr, like so:In my case , it was just
because I hadnt’t installed that library