From 58eb4b7338de9940a02993dae62d45a8f97639b3 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sat, 6 Aug 2016 17:44:14 -0700 Subject: [PATCH] add a script to extract thumbnails images from videos --- extract-thumbnail-from-video | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 extract-thumbnail-from-video diff --git a/extract-thumbnail-from-video b/extract-thumbnail-from-video new file mode 100755 index 0000000..306faa0 --- /dev/null +++ b/extract-thumbnail-from-video @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby + +video_path = ARGV[0] +thumbnail_path = ARGV[1] +time = ARGV[2] || "00:00:00.000" + +unless video_path && thumbnail_path + $stderr.puts "Usage: #{$0} [HH:MM:SS.MMM]" + exit 10 +end + +unless File.exists?(video_path) + $stderr.puts "Input video does not exist: #{video_path}" + exit 20 +end + +if File.exists?(thumbnail_path) + $stderr.puts "Cowardly refusing to overwrite existing file at thumbnail path: #{thumbnail_path}" + exit 30 +end + +`ffmpeg -i '#{video_path}' -ss '#{time}' -vframes 1 '#{thumbnail_path}'` +exit $?.exitstatus