Yamdi is a project mainly written in Ruby, based on the MIT license.
Yamdi is a ruby wrapper around the command line tool yamdi (github.com/ioppermann/yamdi) for extracting metadata from flv files.
= yamdi
Yamdi is a ruby wrapper around the command line tool yamdi (github.com/ioppermann/yamdi). You'll need yamdi installed in order for the gem to be of any use. If you are on OSX I recommend using homebrew (brew install yamdi).
The Yamdi command line tool expects to receive a path to an flv file and will return XML file of the extracted metadata that we then wrap in a ruby object and use to expose the metadata.
The current gem version only supports the reading of metadata. The command line tool also supports the writing of the metadata into a new .flv file but this is not yet supported in this gem.
Tested under ruby 1.8.7 and 1.9.2
== Usage
@metadata = Yamdi.new('path/to/file.flv')
@metadata.duration #=> 6.02
@metadata.key_frames.each do |key_frame| key_frame.time #=> 5.87 key_frame.file_position #=> 13467 end
=== Paperclip Processor
You can also use Yamdi in a Paperclip processor. I've provided a simple example in lib/paperclip_processors/metadata_extractor.rb
This is useful for adding things like video duration to your db when a user uploads a video.
class Video has_attached_file :video, :styles => {:orginal => {}}, :processors => [:metadata_extractor] end
Be sure you add the styles hash even if it is empty as above or your paperclip processors won't run.
=== Refreshing Exisitng Videos
Perhaps you're adding yamdi to your current set up, want to refresh the data in your models or add a new column to present to your users.
This is easily accomplished of you are using Paperclip. I've added an example rake task in lib/tasks/metadata_refresh.rake
== Supported methods
duration :: float, in seconds
has_keyframes? :: boolean has_video? :: boolean has_audio? :: boolean has_metadata? :: boolean has_cue_points? :: boolean can_seek_to_end? :: boolean
audio_codec_id :: integer audio_sample_rate :: integer audio_data_rate :: integer audio_sample_size :: integer audio_delay :: float, in seconds
stereo? :: boolean
video_codec_id :: integer frame_rate :: float, in seconds video_data_rate :: integer
height :: integer width :: integer
data_size :: integer audio_size :: integer video_size :: integer file_size :: integer
last_timestamp :: float, in seconds last_video_frame_timestamp :: float, in seconds last_key_frame_timestamp :: float, in seconds last_key_frame_location :: integer
key_frames :: Array of key frame data, each item contains the following
== Contributing to yamdi
== Copyright
Copyright (c) 2011 Bob Burbach. See LICENSE.txt for further details.