FlashComGuru Home InfluxisCDNImediaseeUvault
                                                                                       Forum Index | Active Topics | Register
                                                                                                          List Overview | List Archives
                                                                                                                           About this site | Advertise
 

home

Adobe AIR (11)
Applications (40)
Books & Training (11)
Collaboration (18)
Components (10)
Events (80)
Flash Player (35)
Flex (39)
FMS (110)
General (123)
Hosting (6)
Jobs (17)
Off topic (36)
OSMF (3)
Press Releases (23)
Site Check (11)
Tools (53)
Videos & Players (74)

Follow me on Twitter

 
This is probably a task that every Flashcom developer will have to tackle at some stage: how to extract thumbnails images from an flv file, ideally automating this process with a free commandline tool such as ffmpeg.

I've had a shot at this once before, probably a year or two ago and I was somewhat successful. One key thing that I could not crack was the -ss flag in ffmpeg which allows you to seek to a position. Whenever I used that flag the jpg extraction/conversion wouldn't work, instead it returned something like 'unknown option -ss'.

But recently a user in my forum suggested to give this another try. I grabbed the ffmpeg executable from Riva Encoder and tried again - this time it worked, probably due to a newer version of ffmpeg.

For reference the syntax I used is below. This will produce an output file with the name of 1.jpg. It's also possible to add other text to the filename but ffmpeg insists to have a numbering system in there.

ffmpeg -i video.flv -an -ss 00:00:03 -an -r 1 -vframes 1 -y %d.jpg

the options are as follow: -i input file -an Disable audio recording -ss seek to (in this case second 3 to avoid black frame at start) -vframes no idea what this does, could be framerate? Anyone know? -y overwrite output file

Note: I am not sure if this will work reliably or at all with VP6 encoded files. Please post a comment if you know if it does or not.

My version of ffmpeg can be downloaded here.

Comments
[Add Comment]
very nice.
# Posted By phil | 4/26/06 2:22 AM
As far as I know ffmpeg does not support VP6 and will not support it in the near future (as it is a proprietary codec).

(just tried it and got nothing but a lot of "unsupported video codec" errors.. )
# Posted By Carina | 5/3/06 1:55 PM
Ah, I forgot: -r sets frame rate, I've never used -vframes but google tells me it "sets the number of video frames to record".

Simply using "-r 1" usually works too but sometimes this records two frames so it's a good idea to set both -r and -vframes to 1.
# Posted By Carina Stumpf | 5/3/06 2:02 PM
I got it working for .png export:

-i pathToStream.flv -vcodec png -vframes 1 -an -f rawvideo -s 106x106 pathToImage.png

//Pim
# Posted By Philippe Maegerman | 5/9/06 12:43 PM
Btw, I have some code for jpeg export that is slightly different than yours, and working too :)

ffmpeg.exe -i stream_1146848749371.flv -y -f singlejpeg -ss 0.001 -vframes 1 -an test.jpg

//Pim
# Posted By Philippe Maegerman | 5/9/06 12:46 PM
Hi,

It looks like it is possible to use ON2 VP6 to encode FLV files :
http://sh0dan.blogspot.com/2006/09/command-line-fl...

The question is can it be done to encode all formats (qt, wmv, mpeg4, ...)

Pod
# Posted By Al | 10/18/06 1:02 PM
very cool, thanks for posting this. It still seems quite a lot of work though don't you think? It would be a different story if AviSynth wasn't required on top of ffmpeg. I'm also not sure about the legality if you would indeed use this commercially.

nice though.
# Posted By Stefan | 10/18/06 1:27 PM
Yes, AviSynth is needed in this case.

BTW, here is another interesting thread :
http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2...

The commercial aspect needs to be investated further.

Pod.
# Posted By Podawan | 10/18/06 1:38 PM
Hi All,

I realize this thread is quite old, but, I thought I'd ask any ways. Is there an easy technique to grab the middle frame or atleast figure out at what time the middle of the video occurs at?

Thanks,
Matt
# Posted By Matt Powell | 6/26/07 1:14 AM
An <a href="http://kevin.vanzonneveld.net/techblog/article/cre...">ffmpeg flv tutorial</a> for beginners
# Posted By kvz | 9/6/07 3:58 PM
The singlejpeg codec has been deprecated, now to extract jpeg thumbnail use mjpeg instead:
http://gallery.menalto.com/node/34767
# Posted By Hai | 11/3/07 4:59 PM
I am getting the following error:

[flv @ 0040F954]Unsupported video codec (4)
[flv @ 0040F954]Unsupported video codec (4)
[flv @ 0040F954]Unsupported video codec (4)
[flv @ 0040F954]Unsupported video codec (4)
test.flv: could not find codec parameters

I typed in the following:

C:\ffmpeg>ffmpeg.exe -i test.flv -y -f singlejpeg -ss 0.001 -vframes 1 -an test.
jpg

Does anyone know what I am doing wrong?
# Posted By Matthew | 3/26/08 12:55 AM
If you add "-f image2" to the parameter list, you don't have to put %d in the output filename.
# Posted By Morris Jones | 5/22/08 7:16 PM
In order to correct the 'Unsupported video codec' error you have to recompile ffmpeg with binary codec installed :

- download ffmpeg source
- download 'all' codec from mplayer site
- install codec in /usr/lib/codecs
- compile ffmpeg

You should now have an VP6 support
# Posted By Julien | 6/12/08 10:16 AM
I need to add a video conversion support to a website we are developing. I installed ffmpeg by yum utility. FLV's created with Flex (SWF8 or later) are throwing "Unsupported video codec" error. How can I add support for vc6? The rpm that is installed is ffmpeg-0.4.9-0.3.20051207.2.fc4. A quick response will be highly appreciated.
# Posted By WebTenet Solutions | 7/18/08 12:32 PM
For those running into "codec unsupported" issues, you should download the latest Windows build of ffmpeg here: http://ffdshow.faireal.net/mirror/ffmpeg/ and then give things a shot.

With the latest release (ffmpeg.rev12665.7z) I'm successfully producing PNG's from FLV's that use the VP6F codec.

Thank you to Julien and Stefan, as without either of you I'd have never found this solution.
# Posted By Nick | 9/1/08 5:38 AM
how can we convert a thumbnail from flv in asp.net
# Posted By harjot singh chopra | 11/21/08 9:04 AM
Though its very old post, I am replying to Carina's Post "As far as I know ffmpeg does not support VP6 and will not support it in the near future (as it is a proprietary codec)". Does ffmpeg needs to encode while creating a thumbnail from a frame. And it has support to decode vp6 codec
# Posted By Navraj | 12/12/08 8:36 AM
How to enable/ check ffmpeg support on my server. Plz reply quickly.
It's urgent.

Regards,
Salman Ghouri
# Posted By Salman | 3/4/09 4:13 PM
Checking if you have ffmpeg support is easy if you have shell access. SSH to the box, log in and just type "ffmpeg [enter]".
If you get an echo with all sorts of ffmpeg information, then you have it.

If you don't have shell access, try it with a simple PHP script:

<?php echo shell_exec("ffmpeg 2>&1"); ?>

You'll get the same info as you would get via shell access.
# Posted By OverSoft | 4/17/09 4:03 PM
how to hide the process after pass the argument , means i don't want to show command prompt process to user
# Posted By avinash | 7/22/09 12:31 PM
Solve the problem
# Posted By avinash | 7/22/09 1:34 PM
i am working on automating framegrabbing on an input theora (.ogv) file using ffmpeg..

im using a command like:

ffmpeg -ss 00:20:00 -i UGM001_Bobby-Nasha.ogv -r 1 -vframes 1 -s 128x72 -f image2 UGM%03d.jpeg

where -ss is the starting seek position.

This works fine, but only when im lucky enough to hit a keyframe! otherwise ffmpeg gives an error: "first frame is not a keyframe"..

Since the location of keyframes will vary according to whatever the encoder deems is optimal, is there any way to tell ffmpeg to grab from the next available keyframe?

thanks
# Posted By kim | 2/7/10 10:46 PM