From: Sebastian Date: Mon, 25 Aug 2014 16:51:52 +0000 (+0000) Subject: host: split write_image into GIF and MP4 (fails!) X-Git-Url: http://sraa.de/git/?a=commitdiff_plain;h=07ed04f2d475eba5df494c5b85631c8d573fd9ad;p=lattice-boltzmann-epiphany.git host: split write_image into GIF and MP4 (fails!) split write_image() into convert_to_gif() (using ImageMagick 'convert') and convert_to_mp4() (using FFMPEG) functions. NOTE: since the Parallella Ubuntu ships with libav instead of ffmpeg, and the ffmpeg/avconv binaries don't support type globs, converting to MP4 does not work - and fails without error message. --- diff --git a/d2q9/hsrc/data.c b/d2q9/hsrc/data.c index 8e709a1..dfe2392 100644 --- a/d2q9/hsrc/data.c +++ b/d2q9/hsrc/data.c @@ -190,7 +190,7 @@ void write_velocity(d2q9_block_t lattice[CORES_Y][CORES_X], int iter) } /* convert image files to animated gif ./tmp/anim.gif */ -void write_animation(void) +void convert_to_gif(void) { int result; @@ -201,6 +201,21 @@ void write_animation(void) return; } +/* convert image files to mp4 ./tmp/anim.mp4 */ +void convert_to_mp4(void) +{ + int result; + + /* call ffmpeg + FIXME: requires ffmpeg binary with '-pattern_type glob' support, + so this will not work on the Parallella without updates! */ + result = system("ffmpeg -v quiet -pattern_type glob -i " + "'./tmp/i*.ppm' ./tmp/anim.mp4"); (void)result; + fixsudo("./tmp/anim.mp4"); + + return; +} + /* write timer values */ void write_timers(uint32_t timers[CORES_Y][CORES_X][TIMERS], uint32_t iter) { diff --git a/d2q9/hsrc/main.c b/d2q9/hsrc/main.c index 712feb1..f69be76 100644 --- a/d2q9/hsrc/main.c +++ b/d2q9/hsrc/main.c @@ -16,9 +16,10 @@ /* helper functions */ void fixsudo(const char *filename); void write_populations(d2q9_block_t lattice[CORES_Y][CORES_X], int iter); -void write_animation(void); void write_density (d2q9_block_t lattice[CORES_Y][CORES_X], int iter); void write_velocity (d2q9_block_t lattice[CORES_Y][CORES_X], int iter); +void convert_to_gif(void); +void convert_to_mp4(void); void write_timers(uint32_t timers[CORES_Y][CORES_X][TIMERS], uint32_t iter); /* globals */ @@ -30,7 +31,7 @@ int main() char *filename = "bin/main.srec"; /* remove old results */ - int dummy = system("rm -f ./tmp/i*.ppm ./tmp/anim.gif populations.dat timers.dat"); + int dummy = system("rm -f ./tmp/i*.ppm ./tmp/anim.gif ./tmp/anim.mp4 populations.dat timers.dat"); (void)dummy; e_epiphany_t dev; @@ -108,7 +109,7 @@ int main() printf("\nProgram finished successfully.\n"); printf("Convert ...\n"); - write_animation(); + convert_to_gif(); return(0); }