Bachir Soussi Chiadmi 8 роки тому
батько
коміт
24e070d7f3
1 змінених файлів з 26 додано та 11 видалено
  1. 26 11
      www/pict-converter.sh

+ 26 - 11
www/pict-converter.sh

@@ -5,14 +5,20 @@
 
 function convert {
 
+
   now=$(date +"%Y-%m-%d--%T")
   echo "Timelaps conversion | $now"
 
+  pf=12
+  vf=24
+
   mkdir tmp_videos
   mkdir tmp_metadata
   mkdir tmp_pictures
 
   rm -f tmp_pictures/*
+  rm -f tmp_videos/*
+  rm -f tmp_metadata/*
 
   x=1
   for i in public_html/pictures/*.jpg; do
@@ -21,8 +27,6 @@ function convert {
     x=$(($x+1))
   done
 
-  pf=12
-  vf=24
 
   echo "pictframerate:$pf, videoframerate=$vf"
 
@@ -42,7 +46,7 @@ function convert {
   ffmpeg -y -i tmp_videos/timelaps-raw.mp4 -vf "scale=360:-1, crop=in_w:240" tmp_videos/timelaps-240p.mp4
 
   echo "updating production videos"
-  rsync -r tmp_videos/ public_html/videos/
+  mv -f tmp_videos/* public_html/videos/
 
   echo "metadata export"
   l=0
@@ -57,28 +61,39 @@ function convert {
     # SRC
     src="${pict/public_html\/pictures\//}"
     # TIME
-    # time="${pict/public_html\/pictures\/hehe-/}"
-    # time="${time/.jpg/}"
-    datetime=`exiftool 2>/dev/null -S --DateTimeOriginal -p '$DateTimeOriginal' -d %Y-%m-%dT%T "$pict"`
+    datetime="${pict/public_html\/pictures\/hehe-/}"
+    datetime="${datetime/.jpg/}"
+    Y="${datetime:0:4}"
+    m="${datetime:4:2}"
+    d="${datetime:6:2}"
+    h="${datetime:9:2}"
+    min="${datetime:11:2}"
+    sec="${datetime:13:2}"
+    datetime="$Y-$m-$d $h:$min:$sec"
+    datetime="${datetime/ /T}"
+    # echo "datetime : $datetime"
+    # datetime= $($datetime | awk /([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})([0-9]{2})/ {print $1-$2-$3T$4:$5:$6})
+    # datetime=`exiftool 2>/dev/null -S --DateTimeOriginal -p '$DateTimeOriginal' -d %Y-%m-%dT%T "$pict"`
     # GPS
     gps=`exiftool 2>/dev/null -n -p '$GPSLatitude,$GPSLongitude' $pict`
 
     # FRAME
     currenttime=$(((1/$pf)*$f))
 
-    if [[ $f == $(($l-1)) ]]; then
-      echo -e "\t\t{\"src\":\"$src\", \"datetime\":\"$datetime\", \"gps\":\"$gps\", \"currenttime\":\"$currenttime\"}" >> tmp_metadata/frames.json
-    else
-      echo -e "\t\t{\"src\":\"$src\", \"datetime\":\"$datetime\", \"gps\":\"$gps\", \"currenttime\":\"$currenttime\"}," >> tmp_metadata/frames.json
+    frame="\t\t{\"src\":\"$src\", \"datetime\":\"$datetime\", \"gps\":\"$gps\", \"currenttime\":\"$currenttime\", \"id\":\"$f\"}"
+    if [[ $f != $(($l-1)) ]]; then
+      frame="$frame,"
     fi
 
+    echo -e "$frame" >> tmp_metadata/frames.json
+
     f=$(($f+1))
   done
 
   echo -e '\t]' >> tmp_metadata/frames.json
   echo -e '}' >> tmp_metadata/frames.json
 
-  rsync -r tmp_metadata/ public_html/metadata/
+  mv -f tmp_metadata/* public_html/metadata/
 
 
 }