diff options
Diffstat (limited to 'thumbnailer/shotwell-video-thumbnailer.vala')
-rw-r--r-- | thumbnailer/shotwell-video-thumbnailer.vala | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/thumbnailer/shotwell-video-thumbnailer.vala b/thumbnailer/shotwell-video-thumbnailer.vala index db5a096..5974934 100644 --- a/thumbnailer/shotwell-video-thumbnailer.vala +++ b/thumbnailer/shotwell-video-thumbnailer.vala @@ -19,6 +19,21 @@ class ShotwellThumbnailer { uint8[]? pngdata; int64 duration, position; Gst.StateChangeReturn ret; + OutputStream out; + + if (args.length != 3) { + stdout.printf("usage: %s <filename> <output> \n Writes video thumbnail to output\n", args[0]); + return 1; + } + + var out_file = File.new_for_commandline_arg (args[2]); + try { + out = out_file.append_to(FileCreateFlags.NONE); + debug("Writing thumbnail to %s", args[2]); + } catch (Error err) { + warning("Failed to append to image file %s", err.message); + return 1; + } if (Posix.nice (19) < 0) { debug ("Failed to reduce thumbnailer nice level. Continuing anyway"); @@ -36,10 +51,6 @@ class ShotwellThumbnailer { registry.remove_feature (feature); } - if (args.length != 2) { - stdout.printf("usage: %s [filename]\n Writes video thumbnail to stdout\n", args[0]); - return 1; - } descr = "playbin uri=\"%s\" audio-sink=fakesink video-sink=\"gdkpixbufsink name=sink\"".printf(File.new_for_commandline_arg(args[1]).get_uri()); @@ -120,7 +131,7 @@ class ShotwellThumbnailer { pixbuf = pixbuf.rotate_simple(direction); } pixbuf.save_to_buffer(out pngdata, "png"); - stdout.write(pngdata); + out.write(pngdata); // cleanup and exit. pipeline.set_state(Gst.State.NULL); |