diff --git a/.gitignore b/.gitignore index 4a8d37b..0461e1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ www/pictures +gps +logs diff --git a/www/.gitignore b/www/.gitignore index 3186007..f3abae4 100644 --- a/www/.gitignore +++ b/www/.gitignore @@ -5,3 +5,6 @@ public_html/videos/*.ogg public_html/videos/*.webm public_html/metadata/*.json logs/*.log +tmp_metadata +tmp_videos +tmp_pictures diff --git a/www/pict-converter.sh b/www/pict-converter.sh index e22c682..b1bde93 100755 --- a/www/pict-converter.sh +++ b/www/pict-converter.sh @@ -1,17 +1,37 @@ -#!/bin/sh +#!/bin/bash # Bachir Soussi Chiadmi 06/2016 # https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images # needs ffmep and exiftool -function convertVideo(){ +function convert { + + now=$(date +"%Y-%m-%d--%T") + echo "Timelaps conversion | $now" + + mkdir ~/hehe-rover/www/tmp_videos + mkdir ~/hehe-rover/www/tmp_metadata + mkdir ~/hehe-rover/www/tmp_pictures + + rm -f tmp_pictures/* + + x=1 + for i in public_html/pictures/*.jpg; do + counter=$(printf %03d $x) + ln "$i" tmp_pictures/img"$counter".jpg + x=$(($x+1)) + done + + pf=12 + vf=24 + + echo "pictframerate:$pf, videoframerate=$vf" + echo 'Video conversion' - pf=$1 - vf=$2 echo "creating raw timelaps" ffmpeg -y \ -framerate $pf \ - -pattern_type glob -i 'public_html/pictures/*.jpg' \ - -r $vf -pix_fmt yuv420p -c:v libx264 \ + -i tmp_pictures/img%03d.jpg \ + -r $vf -pix_fmt yuv420p -vcodec libx264 \ tmp_videos/timelaps-raw.mp4 echo "optimizing responsive videos" @@ -23,17 +43,15 @@ function convertVideo(){ echo "updating production videos" rsync -r tmp_videos/ public_html/videos/ -} -function exportData(){ echo "metadata export" - pf=$1 - vf=$2 f=0 - echo -e "{" > tmp_metadata/frames.json + echo -e '{' > tmp_metadata/frames.json echo -e '\t"frames":[' >> tmp_metadata/frames.json for pict in public_html/pictures/*.jpg; do + # SRC + src="${pict/public_html\/pictures\//}" # TIME # time="${pict/pictures\/hehe-/}" # time="${time/.jpg/}" @@ -43,7 +61,7 @@ function exportData(){ # FRAME frame=$(((60/$vf)*$f)) - echo -e "\t\t{\"pict\":\"$pict\", \"time\":\"$time\", \"gps\":\"$gps\", \"frame\":\"$frame\"}," >> tmp_metadata/frames.json + echo -e "\t\t{\"src\":\"$src\", \"time\":\"$time\", \"gps\":\"$gps\", \"frame\":\"$frame\"}," >> tmp_metadata/frames.json f=$(($f+1)) done @@ -51,24 +69,8 @@ function exportData(){ echo -e "}" >> tmp_metadata/frames.json rsync -r tmp_metadata/ public_html/metadata/ -} -function convert(){ - now=$(date +"%Y-%m-%d--%T") - echo "Timelaps conversion | $now" - - - mkdir ~/hehe-rover/www/tmp_videos - mkdir ~/hehe-rover/www/tmp_metadata - - pictframerate=12 - videoframerate=24 - - echo "pictframerate:$pictframerate, videoframerate=$videoframerate" - - convertVideo $pictframerate $videoframerate - exportData $pictframerate $videoframerate }