Flash duration

Is there a way in Rails to get the duration (minutes, seconds, etc.) of
a flash video? I want to display the amount of time to the users before
they start playing it or downloading it.

I control the flash video and it is in my public directory.

There are many video clips and they change frequently and I don’t want
to
have to look at them and store the length when I copy the file over.

On 19 March 2011 16:47, Ralph S. [email protected] wrote:

Is there a way in Rails to get the duration (minutes, seconds, etc.) of
a flash video? I want to display the amount of time to the users before
they start playing it or downloading it.

Do you know a way of determining the time via command line?

Colin

Saturday, March 19, 2011, 11:12:58 AM, you wrote:

CL> On 19 March 2011 16:47, Ralph S. [email protected] wrote:

Is there a way in Rails to get the duration (minutes, seconds, etc.) of
a flash video? I want to display the amount of time to the users before
they start playing it or downloading it.

CL> Do you know a way of determining the time via command line?

Colin, I do not know how to do so.

I was hoping there was a gem to help me do it.

For those who may need the answer to this question I will outline my
OS-independent solution.

The file format of an .flv file is documented in
http://download.macromedia.com/f4v/video_file_format_spec_v10_1.pdf

To spare you the effort of reading the documentation …

Read the metadata header into a string. Reading 10K should be way more
than enough.

Search for the string “duration” (without the quotes). “duration” is
null terminated.

The next 16 bytes are a double and can be interpreted as
String.unpack(“G”).

The double so interpreted is the duration in seconds.

On Mar 19, 6:30pm, Ralph S. [email protected] wrote:

Colin, I do not know how to do so.

I was hoping there was a gem to help me do it.

Have you checked the flvtool2 gem to see if that gets you what you
need ?

Katie

http://www.coderstack.co.uk/python-developer-jobs

The mediainfo CLI app, or ffmpeg if that doesn’t work. You can shell
out to the CLI with the back-tick operator, and the return from either
of these will be plain text, suitable for further regular-expression-
bashing.

Walter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs