<commit_before>= vidibus-tempfile

The extended Temfile class allows temporary files with correct mime type and file extension. This is useful for processing temporary files. Parts of the Tempfile extensions were copied from Paperclip. Thank you!

This gem is part of the open source SOA framework Vidibus: http://vidibus.org


== Installation

Add the dependency to the Gemfile of your application:

  gem "vidibus-tempfile"

Then call `bundle install` on your console.


== Usage

This is an example for extracting image stills from a video through a Tempfile:

  # Extract video still using FFmpeg
  def extract_image(video, seconds = 10)
    basename = File.basename(video).gsub(/\.\w+$/,'')
    tmpfile = Vidibus::Tempfile.new("#{basename}.jpg")
    tmpfile.binmode
    cmd = %(ffmpeg -itsoffset -#{seconds} -i "#{video}" -y -vcodec mjpeg -qscale 1 -vframes 1 -an -f rawvideo #{File.expand_path(tmpfile.path)} 2>/dev/null)
    `#{cmd}`
    tmp
  end

The next example shows how to assign an image by setting its path:

  class Image
    include Mongoid::Document
    include Paperclip

    field :image_file_name
    field :image_content_type
    field :image_file_size, :type => Integer

    has_attached_file :image

    def image=(path)
      self.write_attribute(:image, Vidibus::Tempfile.new(path))
    end
  end


== TODO

  * Write specs


== Copyright

Copyright (c) 2010 <NAME>. See LICENSE.txt for further details.<commit_msg>Fix todo list markup<commit_after>= vidibus-tempfile

The extended Temfile class allows temporary files with correct mime type and file extension. This is useful for processing temporary files. Parts of the Tempfile extensions were copied from Paperclip. Thank you!

This gem is part of the open source SOA framework Vidibus: http://vidibus.org


== Installation

Add the dependency to the Gemfile of your application:

  gem "vidibus-tempfile"

Then call `bundle install` on your console.


== Usage

This is an example for extracting image stills from a video through a Tempfile:

  # Extract video still using FFmpeg
  def extract_image(video, seconds = 10)
    basename = File.basename(video).gsub(/\.\w+$/,'')
    tmpfile = Vidibus::Tempfile.new("#{basename}.jpg")
    tmpfile.binmode
    cmd = %(ffmpeg -itsoffset -#{seconds} -i "#{video}" -y -vcodec mjpeg -qscale 1 -vframes 1 -an -f rawvideo #{File.expand_path(tmpfile.path)} 2>/dev/null)
    `#{cmd}`
    tmp
  end

The next example shows how to assign an image by setting its path:

  class Image
    include Mongoid::Document
    include Paperclip

    field :image_file_name
    field :image_content_type
    field :image_file_size, :type => Integer

    has_attached_file :image

    def image=(path)
      self.write_attribute(:image, Vidibus::Tempfile.new(path))
    end
  end


== TODO

* Write specs


== Copyright

Copyright (c) 2010 <NAME>. See LICENSE.txt for further details.
{'fraction_non_alphanumeric': 0.09213716660893662, 'fraction_numerical': 0.006234845860755109, 'mean_word_length': 3.6731391585760518, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5949384', 'n_tokens_mistral': 925, 'n_tokens_neox': 862, 'n_words': 328}