host: split write_image into GIF and MP4 (fails!)
authorSebastian <git@sraa.de>
Mon, 25 Aug 2014 16:51:52 +0000 (16:51 +0000)
committerSebastian <git@sraa.de>
Mon, 25 Aug 2014 16:51:52 +0000 (16:51 +0000)
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.

d2q9/hsrc/data.c
d2q9/hsrc/main.c

index 8e709a19b3afd81b4b6367cb8f334da7a7ebe2b6..dfe2392be7b68cef2dac2245d2098fe8c2322ec4 100644 (file)
@@ -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)
 {
index 712feb19914a53026148ebb985f7189247b17f83..f69be76d29e8711d15244caa91fb204c5ba2cfd9 100644 (file)
 /* 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);
 }