I'm grabbing frames from a video file as following:
def capture_frame(file):
capture = cv.CaptureFromFile("video.mp4")
cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_POS_MSEC)
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_MSEC, 90000)
frame = cv.QueryFrame(capture)
return frame
The frame type is cv2.cv.iplimage
. How can I convert this type of image to jpeg image without saving?
Thanks,
Did you try just writing chunks?
with open('filename.jpeg', 'wb+') as destination:
for chunk in image_file.chunks():
destination.write(chunk)
Here's one worth looking at too that uses opencv natively http://answers.opencv.org/question/115/opencv-python-save-jpg-specifying-quality-gives-systemerror/. Although, not sure why you're trying to save .mp4
to .jpeg
...