[Elphel-support] EXIF data from .mov file + other questions

Brian Burke burke.brian.a at gmail.com
Tue Mar 1 11:52:57 PST 2011


I don't know if this is the "best" way, but I extracted individual .jpg's (including EXIF data) from a .mov container for a project I did.  I used PHP (and the disclaimer - I'm no PHP pro, so please excuse any bad form).  It's worth noting - I did this processing off-camera, as it's a little processor-intensive.  Also - I was working with .mov clips with no more than 10,000 individual jpg's in them.  If you're recording ~30 fps, then that's a clip only ~5 min long.

First, I read in the .mov:

  //Open the mov
  $fp = @fopen($filename, 'rb');

  if ($fp) {
    //Read the mov
    $mov = fread($fp, filesize($filename));
    fclose($fp);

Then I found all the SOI (Start Of Image) and EOI (End Of Image) markers in the .mov:

    //Find all SOI markers; record them in $soi
    $soiCount = preg_match_all ('/\xff\xd8/', $mov, $soi, PREG_OFFSET_CAPTURE);
    if ($soiCount) {

      //Find all EOI markers; record them in $eoi
      $eoiCount = preg_match_all ('/\xff\xd9/', $mov, $eoi, PREG_OFFSET_CAPTURE);
      if ($eoiCount) {

Then I was able to use the SOI and EOI locations to grab each jpg "chunk" from the .mov:

        //Make sure number of SOI's and EOI's matches
        if ($soiCount == $eoiCount) {

          for ($i=0; $i<count($soi[0]) ; $i++) {

            //This will be a jpg, in binary, parsed from the $mov
            $jpg = substr($mov, $soi[0][$i][1], $eoi[0][$i][1] - $soi[0][$i][1] + 2);

            //Write that image to disk here
  
          }
        }

Now, I didn't implement that "Write that image to disk here" section above, but it should be (but I haven't tried it) as simple as:

      //Write the jpg to the disk
      $tmpImage = 'tmp' . microtime(true) . '.jpg';
      file_put_contents($tmpImage, $jpg);

Once the image is on the disk, you should be able to read the EXIF data into an array (assuming you have the PHP package "exif" installed) with something like:

      $exif = exif_read_data($tmpImage, 'IFD1');

I was only interested in the date/time info, but assuming the Geo info is there, it should just be a matter of reading the correct array element.  For the date/time the image was captured, I used:

      //DateTimeOriginal is in the format "YYYY:MM:DD HH:MM:SS"
      list($date, $time) = explode(" ", $exif['DateTimeOriginal']);

Hope that helps get you started.


  ----- Original Message -
  ---- 
  From: Bader AlKahtani 
  To: support-list 
  Sent: Tuesday, March 01, 2011 9:24 AM
  Subject: [Elphel-support] EXIF data from .mov file + other questions


  Dear All,


  I hope all is well.


  Thanks a lot for all the support on the mailing list. I have been reading the threads trying to answer my questions and I was hoping if I could get some additional help with the following.


  1) Splitting a video file to individual jpegs and linking Geo information to each jpeg. What is the best practice for doing so? I read that recording a .mov then extracting the exif data is a solution but how would that be done - I would really love a step-by-step (I read that there is a php that does this, can you forward that to me?).


  2) If I would like to have an ultimate end product of a series of jpegs (multiple per second) with Geo information attached, would be taking a video and then linking the geo data post production the best approach?


  3) I read in one of the threads about not needing to record a KML file in order to geotag video frames and it also because it might make the processor to go over capacity. What would I need to do to disable the KML file? Do I uncheck geotagging in the Disk writing tool? Or do I uncheck 'Save Exif Data' in the advanced tab?


  4) How do I upgrade the SD Card? Where is the slot? Do I need to actually take apart the case?




  Thanks a lot and looking forward to hearing back from you.


  -- 


  ________________________________
  Bader K. AlKahtani  

  E-mail: Bader at Kahtani.com

  +=========================================================+

  This message may contain confidential and/or privileged

  information.  If you are not the addressee or authorized to

  receive this for the addressee, you must not use, copy,

  disclose or take any action based on this message or any

  information herein.  If you have received this message in

  error, please advise the sender immediately by reply e-mail

  and delete this message.  Thank you for your cooperation.

  +=========================================================+






------------------------------------------------------------------------------


  _______________________________________________
  Support-list mailing list
  Support-list at support.elphel.com
  http://support.elphel.com/mailman/listinfo/support-list_support.elphel.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://support.elphel.com/pipermail/support-list_support.elphel.com/attachments/20110301/23e3cbf4/attachment-0002.html>


More information about the Support-list mailing list