something very wrong

Something's very wrong...

I maintain NBD

I have an irrational emotional dislike for python. (I know, I know).

I needed to build nbd in a clean environment. So I set up the environment, install openssh-client (to get the sources across) and then do apt-get build-dep nbd.

That pulls in python.

Something is wrong with this world.

Posted
povanim.mk

include povanim.mk

I was finding myself to be running the same povray command lines over and over again. And then ffmpeg2theora. And occasionally forget to update one or two .png files in the mean time, because I was trying and trying and trying some stuff all the time, and forgot that one frame in the final render. That's silly; that's why we have make.

So I wrote me a makefile.

START := $(shell grep 'Initial_Frame' $(INIFILE) | cut -d'=' -f 2)
STOP := $(shell grep 'Final_Frame' $(INIFILE) | cut -d'=' -f 2)
NUMBERS := $(shell seq -w $(START) $(STOP) )
POVFILE := $(shell grep 'Input_File_Name' $(INIFILE) | cut -d'"' -f 2)
ifeq ($(OUTPUT),)
OUTPUT := $(basename $(shell grep 'Output_File_Name' $(INIFILE) | cut -d'"' -f 2))
endif
ifeq ($(OUTPUT),)
OUTPUT := $(basename $(INIFILE))_$(basename $(POVFILE))
endif
PNGFILES := $(foreach nr, $(NUMBERS), $(OUTPUT)$(nr).png)
LEN := $(shell echo "$(STOP)" | wc -m)

$(OUTPUT).ogv : PATTERN := $(OUTPUT)%$(LEN)d
$(OUTPUT).ogv : $(PNGFILES)
	ffmpeg2theora -f image2 -i '$(PATTERN)'.png -o $@

$(OUTPUT)%.png : ONAME := $(OUTPUT)
$(OUTPUT)%.png : INAME := $(INIFILE)
$(OUTPUT)%.png: $(POVFILE) $(INIFILE)
	povray $(INAME) -D +SF'$*' +EF'$*' +O$(ONAME)

ifeq ($(CLEANFILES),)
clean:
	$(RM) $(CLEANFILES)
endif

CLEANFILES := $(CLEANFILES) $(PNGFILES)

The first part, to just write the makefile so that it would work, was easy. The second bit, write it so that you can include it in the same Makefile several times and have it generate patterns for the files you need, without having them conflict with eachother, was... slightly harder. But not impossible, apparently, with GNU make.

Use like this:

INIFILE=foo.ini
include povanim.mk
INIFILE=bar.ini
OUTPUT=bar
include povanim.mk

with povanim.mk containing the above Makefile

Now just run 'make' or 'make bar.ogv', wait for the rendering and encoding to complete, and you have an animation film. You can even use make's '-j' option to speed up processing by using multiple processors. Which will no longer be useful when povray 3.7 comes out (since that uses multithreading to use all cores with a single povray instance, anyway), but it is for now.

Posted