add a script to extract thumbnails images from videos

This commit is contained in:
Sami Samhuri 2016-08-06 17:44:14 -07:00
parent 4a0932d241
commit 58eb4b7338

23
extract-thumbnail-from-video Executable file
View file

@ -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} <video-path> <thumbnail-path> [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