Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

FFmpeg and FLV Metadata

Apr 26

I received an interesting comment today that I wanted to respond to.  A reader was asking if there’s support for metadata (mainly to retrieve width and height) within the flv format and if it’s generated by FFmpeg.  In a previous post I talked about using Ruby on Rails to call a FFmpeg process to encode an uploaded video.  Newer versions of the flv format support metadata, while FFmpeg encodes an older format (v1.0 I believe) that doesn’t support it.  Click here for more information on flv metadata.

Here are a couple of options to consider when retrieving the width and height of the uploaded video.  My first suggestion would be to stream the output of the FFmpeg command to a text file and then try to read the dimensions from there.  You’ll see a line in the output that looks something like:

Stream #0.0: Video: dvvideo, yuv411p, 720×480, 29.97 fps

The second option would be to capture a frame from the video and use a server-side script to grab the dimensions of the image.  This may not be the most elegant approach, but I’m pretty sure it would work and you could grab the first frame of video extremely fast.  It would be pretty seamless from an end-user’s perspective.  If I get some time I’ll play around with a couple of approaches and post them here.  If you happen to come up with a solution I would love to hear about it.

2 comments

  1. Hey,

    You can use flvtool2 to update the metadata. Just after you’ve executed ffmpeg, run flvtool2 -U FLV_FILE.FLV

    cheers,

  2. Daniel,

    Very nice…that’s the first I’ve heard of flvtool2 and it looks promising. Since it’s written in Ruby it should integrate nicely with Rails! Thanks for the link.

    Dennis

Trackbacks/Pingbacks

  1. [db75] » Blog Archive » Rails and FLV Meta Data - [...] I’ve been playing around with FLV encoding in Rails using FFmpeg.  Daniel Tome recently posted a comment pointing me ...

Leave a Reply