Skip to content

Commit

Permalink
Add tools directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hermann-SW committed Dec 14, 2017
1 parent 9cd88af commit ce1839a
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tools/double.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>
#include <assert.h>
#include <string.h>

int main(int argc, char *argv[])
{
FILE *src = fopen(argv[1],"rb");
char line[1999];
int w,h,f,i;

assert(src);
fgets(line, 1999, src); assert(0 == strcmp(line, "P6\n"));
fgets(line, 1999, src); assert(2 == sscanf(line, "%d %d", &w, &h));
fgets(line, 1999, src); assert(1 == sscanf(line, "%d", &f));
assert(3*w < 1999);
assert(9 <= printf("P6\n%d %d\n%d\n",w,2*h,f));

for(i=0; i<h; ++i)
{
assert(3*w == fread(line, 1, 3*w, src));
assert(3*w == fwrite(line, 1, 3*w, stdout));
assert(3*w == fwrite(line, 1, 3*w, stdout));
}

h=ftell(src); fseek(src, 0, SEEK_END); assert(h == ftell(src));

fclose(src);
return 0;
}
12 changes: 12 additions & 0 deletions tools/gifenc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

# doc: http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
# needs: ffmpeg

palette="/tmp/palette.png"

#filters="fps=15,scale=320:-1:flags=lanczos"
filters="fps=25,scale=640:-1:flags=lanczos"

ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
44 changes: 44 additions & 0 deletions tools/raw2ogg2anim
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# needs: dcraw, double, netpbm tools, gstreamer, gifenc.sh

echo "copying /dev/shm/out.????.raw files"
for((f=100; f<200; ++f))
do
# cp /dev/shm/out.0$f.raw .
cat hd0.raw /dev/shm/out.0$f.raw > out.0$f.raw
echo -en "$f \r"
done
echo

echo "dcraw each .raw file (to .ppm)"
for f in *.raw
do
dcraw $f
echo -en "$f \r"
done
echo

echo ".ppm -> .ppm.d"
for f in *.ppm
do
double $f > $f.d
echo -en "$f \r"
done
echo

echo ".ppm.d -> .ppm.d.png"
for f in *.ppm.d
do
pnmtopng $f > $f.png
echo -en "$f \r"
done
echo

echo "now creating $1.ogg"
gst-launch-1.0 multifilesrc location="out.%04d.ppm.d.png" index=1 caps="image/png,framerate=\(fraction\)25/1" ! pngdec ! videorate ! videoconvert ! videorate ! theoraenc ! oggmux ! filesink location="$1.ogg"

echo "now creating $1.anim.gif"
gifenc.sh $1.ogg $1.anim.gif

echo "done"

0 comments on commit ce1839a

Please sign in to comment.