def capture_frame(timecode, output_file = nil)
      t = calculate_time(timecode)
      unless output_file
        output_file = "#{TEMP_PATH}/#{File.basename(@full_filename, ".*")}-#{timecode.gsub("%","p")}.jpg"
      end
      # do the work
      # mplayer $input_file$ -ss $start_time$ -frames 1 -vo jpeg -o $output_file$
      # ffmpeg -i $input_file$ -v nopb -ss $start_time$ -b $bitrate$ -an -vframes 1 -y $output_file$
      command = "ffmpeg -i #{@full_filename} -ss #{t} -t 00:00:01 -r 1 -vframes 1 -f image2 #{output_file}"
      Transcoder.logger.info("\nCreating Screenshot: #{command}\n")
      frame_result = `#{command} 2>&1`
      
      # Different versions of ffmpeg report errors differently when a screenshot cannot be extracted from
      # a video given its set of options. Some versions return a non-zero exit code and report errors while
      # others simply
      unless File.exists?(output_file)
        msg = <<-EOT.gsub(/(^\s+|\n)/, '')
          This means that ffmpeg could not extract a screenshot from the video. It may indicate that
          the video file was corrupt or that the requested frame to be captured was outside the length
          of the video. Full command: #{command}
        EOT
        Transcoder.logger.error msg
        raise TranscoderError::OutputFileNotFound, msg
      end
      
      Transcoder.logger.info("\nScreenshot results: #{frame_result}")
      output_file
    end
def capture_frame(timecode, output_file = nil)
      t = calculate_time(timecode)
      unless output_file
        output_file = "#{TEMP_PATH}/#{File.basename(@full_filename, ".*")}-#{timecode.gsub("%","p")}.jpg"
      end
      # do the work
      # mplayer $input_file$ -ss $start_time$ -frames 1 -vo jpeg -o $output_file$
      # ffmpeg -i $input_file$ -v nopb -ss $start_time$ -b $bitrate$ -an -vframes 1 -y $output_file$
      command = "ffmpeg -i #{@full_filename} -ss #{t} -t 00:00:01 -r 1 -vframes 1 -f image2 #{output_file}"
      Transcoder.logger.info("\nCreating Screenshot: #{command}\n")
      frame_result = `#{command} 2>&1`
      
      # Different versions of ffmpeg report errors differently when a screenshot cannot be extracted from
      # a video given its set of options. Some versions return a non-zero exit code and report errors while
      # others simply
      unless File.exists?(output_file)
        msg = <<-EOT.gsub(/(^\s+|\n)/, '')
          This means that ffmpeg could not extract a screenshot from the video. It may indicate that
          the video file was corrupt or that the requested frame to be captured was outside the length
          of the video. Full command: #{command}
        EOT
        Transcoder.logger.error msg
        raise TranscoderError::OutputFileNotFound, msg
      end
      
      Transcoder.logger.info("\nScreenshot results: #{frame_result}")
      output_file
    end
Take a screengrab of a movie. Requires an input file and a time parameter, and optionally takes an output filename. If no output filename is specfied, constructs one.

 Three types of time parameters are accepted - percentage (e.g. 3%), time in seconds (e.g. 60 seconds), and raw frame (e.g. 37). Will raise an exception if the time in seconds or the frame are out of the bounds of the input file.

 Types:
   37s (37 seconds)
   37f (frame 37)
   37% (37 percent)
   37  (default to seconds)

 If a time is outside of the duration of the file, it will choose a frame at the 99% mark.

 Example:

   t = RVideo::Transcoder.new('path/to/input_file.mp4')
   t.capture_frame('10%') # => '/path/to/screenshot/input-10p.jpg'