I’ve done several posts about extracting JPG and PNG frames using FFmpeg. I’ve received quite a few comments about users having problems with the following command:
ffmpeg -i swing.avi -s 320×240 -vframes 1 -f singlejpeg swing.jpg
This has worked for me time and time again, but possibly it’s not supported in newer versions. Right now I’m running version 4.9-pre1. For all the users having problems with the command above I’ve been shown the following that substitutes mjpeg for singlejpeg. So the command looks like this:
ffmpeg -i swing.avi -s 320×240 -vframes 1 -f mjpeg swing.jpg
I was able to run this command successfully with the same version of FFmpeg. The image looks identical and is the same file size. If you’re having problems extracting frames then I would recommend trying both commands and seeing what works for you. If neither of them do then you should consider upgrading to the latest version of FFmpeg.
Hi, I have a quick question regarding RoR and ffmpeg. Are you running these commands on Windows? Also, I see that most of your examples deal with .avi files. Can ffmpeg deal with all of the other popular file extensions?
No, I’m running these commands on Linux, but am pretty certain they should work on Windows. I haven’t used the Windows version in a while, but it used to do the job quite well.
FFmpeg supports all kinds of file extensions and I’ve rarely found a situation where it didn’t support the video file I was working with.
hi Dennis,
Tried ffmpeg -i Batmanreturns.flv -vframes 1 -f singlejpeg batman.png
with this result..
seems the flv decode support is not complete .. or I’m using the wrong version.
can you confirm this ??
FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard
configuration: –prefix=/usr –libdir=${prefix}/lib –incdir=${prefix}/include/ffmpeg –enable-shared –enable-mp3lame –enable-gpl –enable-faad –mandir=${prefix}/share/man –enable-vorbis –enable-pthreads –enable-faac –enable-xvid –enable-dts –enable-amr_nb –enable-amr_wb –enable-pp –enable-libogg –enable-theora –enable-libgsm –enable-x264 –enable-a52bin –extra-cflags=-Wall -g -fPIC -DPIC
libavutil version: 49.0.0
libavcodec version: 51.9.0
libavformat version: 50.4.0
built on May 10 2006 09:29:58, gcc: 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
[flv @ 0xb7ef20a0]Unsupported video codec (4)
[flv @ 0xb7ef20a0]Unsupported video codec (4)
[flv @ 0xb7ef20a0]Unsupported video codec (4)
[flv @ 0xb7ef20a0]Unsupported video codec (4)
[flv @ 0xb7ef20a0]Unsupported video codec (4)
Seems that stream 1 comes from film source: 1000.00 (1000/1) -> 30.00 (30/1)
Input #0, flv, from ‘BatmanBegins.flv’:
Duration: 00:04:39.1, bitrate: N/A
Stream #0.0: Audio: mp3, 22050 Hz, mono
Stream #0.1, 30.00 fps(r): Video: 0×0004
Output #0, rawvideo, to ‘batman.png’:
Stream #0.0, 30.00 fps(c): Video: png, rgb24, q=2-31, 200 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Unsupported codec (id=0) for input stream #0.1
Try using Mark’s suggestion in the following post: http://www.db75.com/new_blog/?p=121. If that doesn’t work let me know which OS and ffmpeg version you’re using. Good luck!
Hi. I have a project that requires converting mjpeg to flash without loosing quality. My thoughts was to extract the individual frames all at once into a file folder and then import them info flash as a “picture series”. That way, the movie would probably not loose a lot of quality.
What would the commands be to extract ALL frames of a mjpeg movie clip?