#!/usr/bin/make -f-

# sourced for functions
# or copied, or whatever
#
# run from inside a directory, makes (or remakes with -f) either all
# targets or given targets

ALL=$(wildcard *.mov *.mp4 *.ogg)

# IF in the media or incoming directory, make thumbs, recodes, etc.
# IF in a thumb, video, etc, remake?

# assume we're making

# set BASE to the original file name
BASE?=null
USERDIR=/var/www/granicus.if.org/gallery/users
LOCKFILE=$(USERDIR)/.lock.tc

FFMPEG=/var/www/granicus.if.org/gallery/ffmpeg
# Set DEST to dest dir

../thumb/%.png : %.jpg
	convert $< -thumbnail '160x90>' -background skyblue \
		-gravity center -extent 160x90 \
		$@.tmp
	        mv $@.tmp $@

../video/%.webm: %.mov
	#$(FFMPEG) -i $< -vf "scale=iw*min(405/iw\,320/ih):ih*min(405/iw\,320/ih),pad=405:320:(405-iw)/2:(320-ih)/2" $@
	$(FFMPEG) -i $< -vf "scale=iw*min(800/iw\,450/ih):ih*min(800/iw\,450/ih)" $@

../video/%.ogg: %.mov

../video/%.mp4: %.mov

MAXX=800
MAXY=450

#../../../ffmpeg -i bc71ce3ed90e787e9c52f9e997d13df88eef2c74.mov -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 ../video/bc71ce3ed90e787e9c52f9e997d13df88eef2c74.ogg
#	ffprobe -i bc71ce3ed90e787e9c52f9e997d13df88eef2c74.mov -show_format  -v quiet
# .mov.ogg:
# 	{flock -n $(DEST) && $(FFMPEG) -i $< $(DEST)/$@} || true

