Chapters in video

When uploading a video to a site, there’s definitely use for keyframe images as previews.  I was thinking about using the nginx streaming-flv module to feed up individual frames of a video, but I concluded that exporting the required frames as pngs or jpegs is way more practical.  Once again, I’m using ffmpeg to grab individual frames from an flv and xport as pngs.  Heres the code:

ffmpeg -i awards.flv -vcodec png -vframes 1 -ss 120 -an -f rawvideo -s 320×240 testoutput.png

  • -i: the input video
  • -vcodec: the output codec.  In this case png
  • -vframes: the number of frames to output.  I only want 1 frame as the image
  • -ss: number of seconds into the video to grab the screen-shot
  • -an:
  • -f: for the format of the video
  • -s: size of the output
  • testoutput.png is the name of the resulting image.

Batch video conversion with ffmpeg and Ruby

Decided to write a simple script for exporting all my video content to streaming .flvs:

in batchconvert.rb

path = “.”
#contains = Dir.new(basedir).entries
videos = Dir["#{path}/*.mov"]
videos.each do |f|
puts “converting #{f}”
newFile = f.gsub(“.mov”, “.flv”)
system(“ffmpeg -i #{f} -ar 22050 -s 640×480 -b 500000 #{newFile}”)
system(“flvtool2 -U #{newFile}”)
end

To run this command, open up the Terminal and navigate to your video directory.  Then run:

ruby batchconvert.rb

This script doesn’t include any switches or options for files other than .movs.

Files: batchconvert