aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2012-10-18 15:42:38 -0600
committerChris Mason <chris.mason@fusionio.com>2012-10-19 12:37:43 -0400
commite274d7b926da0b52f1a542a3e14a963ac52ffb58 (patch)
treeb80be5724b2f9ff3e3cae30364a3da6d35a67e05
parent68d25bc003876ec2a681f8220d8e6f8be259f6cd (diff)
downloadiowatcher-e274d7b926da0b52f1a542a3e14a963ac52ffb58.tar.gz
iowatcher: support png2theora for videos
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>
-rw-r--r--README13
-rw-r--r--main.c23
2 files changed, 29 insertions, 7 deletions
diff --git a/README b/README
index 09dd91d..f91fb6c 100644
--- a/README
+++ b/README
@@ -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.
diff --git a/main.c b/main.c
index 1f2f278..44cbb81 100644
--- a/main.c
+++ b/main.c
@@ -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);
}