Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract metadata from a Video/Image

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:

  1. Extract the frames from the video and then access them to access the time stamp.
  2. 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.

like image 911
praxmon Avatar asked Mar 14 '14 05:03

praxmon


2 Answers

if there is any metadata attached to the (single image) file, opencv will discard it, unfortunately.

also, the mjpeg protocol does not have any timestamps on its own (it's just a http-multi-part-form interleaved with images [pretty similar to email-attachments], so content-type and content-length is all you get there [and that only if you're using http1.1]).

sorry for the negative answer, but you'll have to look into image-processing tools apart from opencv for this.

like image 190
berak Avatar answered Oct 07 '22 12:10

berak


For Java, you can use Metadata Extractor. Besides, this you can use ImageMagick and Exiflib, both are excellent(excellent defined as highly stable, robust and actively developed) libraries, however these are command-line tools. For imagemagick, you can find other language bindings.

like image 24
saurabheights Avatar answered Oct 07 '22 13:10

saurabheights