made converter working on my bedian server
This commit is contained in:
@@ -1 +1,3 @@
|
||||
www/pictures
|
||||
gps
|
||||
logs
|
||||
|
||||
@@ -5,3 +5,6 @@ public_html/videos/*.ogg
|
||||
public_html/videos/*.webm
|
||||
public_html/metadata/*.json
|
||||
logs/*.log
|
||||
tmp_metadata
|
||||
tmp_videos
|
||||
tmp_pictures
|
||||
|
||||
+30
-28
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user