I am getting an MJPEG stream from an IP Camera which I am viewing and saving on my computer. The code of how I am doing it can be found here. The answer explains how to extract the images from the stream and save them.
For extracting the images I am using the method listed in the answer and for saving it I am simply putting the images in an avi container using OpenCV. The code is given below.
writer=cv.CreateVideoWriter("video1.avi", cv.CV_FOURCC('X', '2', '6', '4'), fps, (320,240))
cv_image = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8),cv2.CV_LOAD_IMAGE_COLOR)bitmap=cv.CreateImageHeader((cv_image.shape[1], cv_image.shape[0]), cv.IPL_DEPTH_8U, 3)
cv.SetData(bitmap, cv_image.tostring(), cv_image.dtype.itemsize * 3 * cv_image.shape[1])
cv.WriteFrame(writer, bitmap)
Here bitmap is the image that I am displaying and putting in the avi container.
Since the image is from an IP Camera it must have some metyadata like a time stamp which the camera inserts.
Question: How do I extract the metadata?
I have thought of 2 ways to do this:
- Extract the frames from the video and then access them to access the time stamp.
- Extract the time stamp from the video itself.
How do I proceed? Which method do I use? I am using Python and Opencv and am working on Windows 7.
I also read this like related to what I am trying to do. It did not solve my problem.