add a script to extract thumbnails images from videos
This commit is contained in:
parent
4a0932d241
commit
58eb4b7338
1 changed files with 23 additions and 0 deletions
23
extract-thumbnail-from-video
Executable file
23
extract-thumbnail-from-video
Executable 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
|
||||
Loading…
Reference in a new issue