dotfiles

My dotfiles, nothing really interesting to see ...
git clone https://git.onna.be/dotfiles.git
Log | Files | Refs | README

commit 9760f5b724e80f7b61a6ddaadd04f36f798003fa
parent 043a8b15d029a086104fd05bbc48f6d8e02a07bd
Author: Paco Esteban <paco@onna.be>
Date:   Sat, 11 Aug 2018 18:28:13 +0200

timelapses for gopro

Diffstat:
bin/bin/timelapse.sh | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+), 0 deletions(-)

diff --git a/bin/bin/timelapse.sh b/bin/bin/timelapse.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +usage() { + echo "Converts a series of images into a video (timelapse). + Output is 1080p/30fps (h264/MP4). + + Usage $0 [options] + + Options: + -h Show this help. + -f <n> Framerate of the timelapse (images per second). Default: 30 + -i <string> Input format of the images. Default 'G%07d.JPG' + -o <file> Output file. Default 'output.mp4' + -c <string> Crop. Default: '4000:2250:0:375'. See tutorial urls for details. + -s <string> Scale. Default: '1920:-1'. See tutorial urls for details. + + Tutorial urls: + http://www.biodiversityshorts.com/advanced-photography/command-line-tools-scripts-and-processing-for-photography/ffmpeg-tutorial-examples + http://lukemiller.org/index.php/2014/10/ffmpeg-time-lapse-notes/ + " +} + +FRAMERATE=30 +INPUT="G%07d.JPG" +OUTPUT="output.mp4" +CROP="4000:2250:0:375" +SCALE="1920:-1" +FFMPEG=$(command -v ffmpeg) + +while getopts "hf:i:o:c:s:" opt; do + case $opt in + h ) + usage + exit 0 + ;; + f ) + FRAMERATE=${OPTARG} + ;; + i ) + INPUT=${OPTARG} + ;; + o ) + OUTPUT=${OPTARG} + ;; + c ) + CROP=${OPTARG} + ;; + s ) + SCALE=${OPTARG} + ;; + *) + echo "[!!] Option does not exist." >&2 + echo "" + usage + exit 1 + ;; + esac +done + +if [ -z "$FFMPEG" ]; then + echo "[!!] ffmpeg not installed" >&2 + exit 1 +fi + +$FFMPEG \ + -framerate "$FRAMERATE" \ + -i "$INPUT" \ + -c:v libx264 \ + -vf crop="$CROP",scale="$SCALE" \ + -r 30 \ + "$OUTPUT"