Project

yamdi

0.0
No commit activity in last 3 years
No release in over 3 years
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).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.5.2
>= 0
~> 2.3.0

Runtime

~> 1.4.4
 Project Readme

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

  • time

    float, in seconds

  • file_position

    integer

Contributing to yamdi¶ ↑

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 Bob Burbach. See LICENSE.txt for further details.