iowatcher: iowatcher: support png2theora for videos
authorEric Sandeen <sandeen@redhat.com>
Thu, 18 Oct 2012 21:42:38 +0000 (15:42 -0600)
committerChris Mason <clm@fb.com>
Wed, 24 Sep 2014 19:02:07 +0000 (12:02 -0700)
ffmpeg is not available on all distributions, so include Theora
as an option, via png2theora, if the output movie filename ends
in .ogg or .ogv

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
iowatcher/README
iowatcher/main.c

index 09dd91d868c202480f5594de20206424f075686d..f91fb6c08980ff6305f9a000b688d3d8072bd4e4 100644 (file)
@@ -16,8 +16,8 @@ Output:
 
 Building:
 
-       Type make and make install.  We need ffmpeg and librsvg to make
-       movies, otherwise there are no dependencies.
+       Type make and make install.  We need ffmpeg or png2theora, and
+       librsvg to make movies, otherwise there are no dependencies.
 
 The basic options:
 
@@ -35,9 +35,12 @@ The basic options:
        -l Sets a label in the graph for a trace file.  The labels are added in
           the same order the trace files are added.
 
-       -m Create a movie.  This defaults to the mp4 file format, and you
-          should also use -o filename.mp4.  You can use any other filename,
-          but the end result will be an mp4.
+       -m Create a movie.  The file format depends on the extension used in the
+          -o filename.* option.  If you specify an .ogv or .ogg extension, the
+          result will be Ogg Theora video, if png2theora is available.
+          If you use an .mp4 extension, the result will be an mp4 video if
+          ffmpeg is avilable.  You can use any other extension, but the end
+          result will be an mp4.
 
           You can use --movie=spindle or --movie=rect, which changes the
           style of the IO mapping.
index 1f2f278261f457f8aa4018d12112dd80bf34fa07..44cbb81bf1dec1e94346c6a8cd682b9d472e4cfa 100644 (file)
@@ -870,12 +870,31 @@ static void convert_movie_files(char *movie_dir)
 
 static void mencode_movie(char *movie_dir)
 {
-       fprintf(stderr, "Creating movie %s\n", movie_dir);
+       fprintf(stderr, "Creating movie %s with ffmpeg\n", movie_dir);
        snprintf(line, line_len, "ffmpeg -r 20 -y -i %s/%%10d-%s.svg.png -b:v 250k "
                 "-vcodec libx264 %s", movie_dir, output_filename, output_filename);
        system(line);
 }
 
+static void tencode_movie(char *movie_dir)
+{
+       fprintf(stderr, "Creating movie %s with png2theora\n", movie_dir);
+       snprintf(line, line_len, "png2theora -o %s %s/%%010d-%s.svg.png",
+                       output_filename, movie_dir, output_filename);
+       system(line);
+}
+
+static void encode_movie(char *movie_dir)
+{
+       char *last_dot = strrchr(output_filename, '.');
+
+       if (last_dot &&
+           (!strncmp(last_dot, ".ogg", 4) || !strncmp(last_dot, ".ogv", 4))) {
+               tencode_movie(movie_dir);
+       } else
+               mencode_movie(movie_dir);
+}
+
 static void cleanup_movie(char *movie_dir)
 {
        fprintf(stderr, "Removing movie dir %s\n", movie_dir);
@@ -1002,7 +1021,7 @@ static void plot_io_movie(struct plot *plot)
                free_all_plot_history(&movie_history);
        }
        convert_movie_files(movie_dir);
-       mencode_movie(movie_dir);
+       encode_movie(movie_dir);
        cleanup_movie(movie_dir);
        free(movie_dir);
 }