Contents |
This is to put the content of files in directory '16' into subdirectories of '2016' of the form 'month-day' with filenames given by the time of day with a last index to allow for several pictures with the same timestamp (if taken within the same second):
exiftool -r '-FileName<CreateDate' -d '%Y/%m-%d/%H_%M_%S%%-.nc.%%le' 16
The main task is to collect pictures in the same format, say 1200x800 pixels (for a high-definition result) and numbered in their order of appearance, padded, starting from 1. We put these frames in a directory with the same name:
mkdir frames
Then we run the script renamenum on all directories where are the images, with extension JPG, to be part of the blitz-lapse.
You could go for something like that:
find . -type d -execdir ~/renamenum "{}" ';'
But I find it usually safer and more convenient to generate a file (ls) with the list of directories to process:
ls -1 > ls # Edit ls with you editor of choice cat ls | xargs -i ./renamenum 2016/{}
where renamenum is given below (check paths, etc.; it needs a file 2015index that starts with 1. This file will keep the indexing from one directory to the next):
#!/bin/bash echo Doing $1; cd $1; mkdir done for file in *.JPG; do convert $file -resize 1200 1200px-$file; done; i=$(<~/2015index); for f in 1200*JPG; do mv "$f" "$( printf "2015-%07d" $i ).jpg"; ((++i)); done mv 2015*jpg "/media/laussy/Seagate Expansion Drive/Penta/pics/20/15/all-fotos/frames/"; rm ~/2015index; echo $i>>~/2015index; echo Done.
If you have only one directory you can simply:
~/renamenum MyPhotosDirectory
If for whatever reason, there is a glitch in the numbering, you can re-order the frames with this command: (first only proposing the output):
i=1; for f in 2015*jpg; do echo mv "$f" "$( printf "2015-%07d.jpg" $i )"; ((i++)); done
If everything went well, you'll have the same filenames at the last line. If not, either investigate what happened, or force the new sequence by removing the echo.
Typical pictures are as shown on the left (in landscape format). Some will be shot rotated, as shown on the right:
Of course in most cases it would be disgraceful to display the image tilted. It must be rotated back, but also padded with a background to be in the same format as the rest of the frames.
First we put these files apart (it can also allow you to select manually those that possibly display equally (or sufficiently) well horizontally, which might then be preferable as it occupies all the screen), putting them in a directory notHorizontal:
mkdir notHorizontal
and then copying there all file whose exif information say are not horizontal:
for f in *.jpg; do ~/selectvertical "$f"; done
where selectvertical is the script:
#!/bin/bash orientation=`exiftool -Orientation -s3 -n $1`; if (($orientation != "1")) then echo Found $1 not horizontal cp $1 notHorizontal/ fi
Hypothetically, delete first files you wish to keep displayed horizontally. Then run the following to rotate, resize and pad (keeping the result in a folder "rotated":
for f in *.jpg; do ~/rotateblack "$f"; done
where rotateblack is:
#!/bin/bash convert $1 -auto-orient rot$1 convert rot$1 -resize 533 rsrot$1 convert rsrot$1 -gravity center -background black -extent 1200x800 final-$1
Then, if the result is okay, copy these files back to the main directory, overwriting the older version.
Then, for 10 frame per second blitz lapse, go for:
avconv -f image2 -r 10 -i 2015-%07d.jpg -vcodec libx264 2015-10fps.mp4