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

Oleg K Dzhimiev oleg at elphel.com
Thu Mar 3 22:56:13 PST 2011


Oh, I'm sorry - my fault. Here's the code
(note: in windows you might need to replace all the "/" in the path to "\"):

#!/usr/local/sbin/php -q
> <?php
>
> /*!*******************************************************************************
> *! FILE NAME  : split_mov.php
> *! DESCRIPTION: splits a *.mov file into frames naming them by the
> timestamp
> *! Copyright (C) 2011 Elphel, Inc
> *!
> -----------------------------------------------------------------------------**
> *!  This program is free software: you can redistribute it and/or modify
> *!  it under the terms of the GNU General Public License as published by
> *!  the Free Software Foundation, either version 3 of the License, or
> *!  (at your option) any later version.
> *!
> *!  This program is distributed in the hope that it will be useful,
> *!  but WITHOUT ANY WARRANTY; without even the implied warranty of
> *!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> *!  GNU General Public License for more details.
> *!
> *!  The four essential freedoms with GNU GPL software:
> *!  * the freedom to run the program for any purpose
> *!  * the freedom to study how the program works and change it to make it
> do what you wish
> *!  * the freedom to redistribute copies so you can help your neighbor
> *!  * the freedom to distribute copies of your modified versions to others
> *!
> *!  You should have received a copy of the GNU General Public License
> *!  along with this program.  If not, see <http://www.gnu.org/licenses/>.
> *!
> -----------------------------------------------------------------------------**
> *!  $Log: split_mov.php,v $
> *!
> */
>
> $chunksize=10000000; // 10MB
>
> $startMarkerWithExif=chr(hexdec("ff")).chr(hexdec("d8")).chr(hexdec("ff")).chr(hexdec("e1"));
>
> echo "<pre>\n";
>
> if (!isset($_GET['path']) || !isset($_GET['ext'])) {
>     echo "Usage
> split_mov.php?path=<path_of_the_mov_file>&ext=<extension>";
>     //echo "Usage split_mov.php?path=path_of_the_mov_file&ext=extension";
>     echo "</pre>\n";
>     exit (1);
> }
>
> $path_with_name=$_GET['path'];
> $extension = $_GET['ext'];
>
> echo "Splitting $path_with_name into {$extension}s\n";
>
> $last_slash_position = strrpos($path_with_name,"/");
>
> if (!$last_slash_position) {
>     $path = "";
>     $mov_file = $path_with_name;
> }else{
>     $path = substr($path_with_name,0,$last_slash_position+1);
>     $mov_file = substr($path_with_name,$last_slash_position+1);
> }
>
> split_mov($path,$mov_file,$extension,$startMarkerWithExif,$chunksize);
>
> function split_mov($path,$mov_file,$ext,$startMarkerWithExif,$chunksize) {
>
>     $path_with_name = $path.$mov_file;
>
>     if (!is_file($path_with_name)) {
>         return -1;
>     }
>
>     $file=fopen($path_with_name,'r');
>
>     $markers=array(0);
>     $offset=0;
>
>     while (!feof($file)) {
>         fseek($file,$offset);
>         $s = fread($file,$chunksize);
>         $index=0;
>         while (true) {
>             $pos=strpos($s,$startMarkerWithExif,$pos);
>             if ($pos === false) break;
>             $markers[count($markers)]=$offset+$pos;
>             $pos++;
>         }
>         $offset+=(strlen($s)-strlen($startMarkerWithExif)+1); // so each
> marker will appear once
>     }
>
>     $markers[count($markers)]=$offset+strlen($s); // full length of the
> file
>
>     for ($i=1;$i<(count($markers)-1);$i++) {
>         fseek($file,$markers[$i]);
>         $s = fread($file,$markers[$i+1]-$markers[$i]);
>
>         $old_file_name= $path."tmp.".$ext;
>
>         $outFile=fopen($old_file_name,'w');
>         fwrite($outFile,$s);
>         fclose($outFile);
>
>         //read exif & rename
>         $exif_data = exif_read_data($old_file_name);
>
>         //converting GMT a local time GMT+7
>
> $DateTimeOriginal_local=strtotime($exif_data['DateTimeOriginal']);/*-25200;*/
>         $new_file_name =
> $path.$DateTimeOriginal_local."_".$exif_data['SubSecTimeOriginal'].".".$ext;
>
>         rename($old_file_name,$new_file_name);
>     }
>     return 0;
> }
>
> ?>
>





On 3 March 2011 22:40, Brian Burke <burke.brian.a at gmail.com> wrote:

> Thanks for uploading split_mov.php.  I'd like to check it out, but as it's
> a .php file, clicking the link executes the script (and just gives the
> "usage" message).  "Save link as" gives the same thing.  What am I missing?
>
> Thanks.
>
>
>
> On Wed, Mar 2, 2011 at 12:23 PM, Oleg K Dzhimiev <oleg at elphel.com> wrote:
>
>> - I was wondering with regards to splitting the JPEGs with the EXIF data
>>> (the geotag information), is there by any chance another solution that is
>>> more friendly for someone with little technical expertise? Is there a way of
>>> running Movie2dng on windows? I'm a very fast learner but I really could not
>>> understand how to get the process going.
>>>
>>
>> I never tried compiling Movie2dng in windows but
>> you could try split_mov.php (
>> http://community.elphel.com/files/php_scripts/)? - I've just uploaded it.
>> Check the folder permissions when you launch the script.
>>
>> BTW, can you see GPS data in the camera interface? Or does "
>> http://192.168.0.9:8081/meta" print the coordinates?
>>
>> Best regards,
>> Oleg
>>
>>
>> _______________________________________________
>> 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/20110303/53312f20/attachment-0002.html>


More information about the Support-list mailing list