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
have to look at them and store the length when I copy the file over.
Do you know a way of determining the time via command line?
Saturday, March 19, 2011, 11:12:58 AM, you wrote:
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.
For those who may need the answer to this question I will outline my
The file format of an .flv file is documented in
To spare you the effort of reading the documentation ...
Read the metadata header into a string. Reading 10K should be way more
Search for the string "duration" (without the quotes). "duration" is
The next 16 bytes are a double and can be interpreted as
The double so interpreted is the duration in seconds.
Have you checked the flvtool2 gem to see if that gets you what you