Reputation: 51
I am trying to extract images from video using ffmpeg
:
ffmpeg -i sample.mp4 -vf fps=1/30 img%03d.jpg
But I am getting this following error
ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 13 2014 13:00:18 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/sites/filemanager.dev/public_html/wout/image/sample.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp42mp41
creation_time : 2009-05-25 21:58:02
Duration: 00:04:03.12, start: 0.000000, bitrate: 309 kb/s
Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 26 kb/s (default)
Metadata:
creation_time : 2009-05-25 21:58:02
handler_name : Apple Sound Media Handler
Stream #0:1(eng): Video: mpeg4 (Advanced Simple Profile) (mp4v / 0x7634706D), yuv420p, 480x320 [SAR 1:1 DAR 3:2], 120 kb/s, 30.12 fps, 30.12 tbr, 2500 tbn, 1k tbc (default)
Metadata:
creation_time : 2009-05-25 21:58:02
handler_name : Apple Video Media Handler
Stream #0:2(eng): Data: none (rtp / 0x20707472), 128 kb/s
Metadata:
creation_time : 2009-05-25 21:58:02
handler_name : hint media handler
Stream #0:3(eng): Data: none (rtp / 0x20707472), 29 kb/s
Metadata:
creation_time : 2009-05-25 21:58:02
handler_name : hint media handler
[NULL @ 0x1d25ea0] Unable to find a suitable output format for 'image2'
image2: Invalid argument
The final out required is I need to extract image at fps 30.
Upvotes: 4
Views: 4741
Reputation: 1002
For extracting images from a video:
ffmpeg -i sample.mp4 -r 30 -s WxH -f image2 image%03d.jpg
The -r flag defines extracted image frames per second. It will output them in files named image001.jpeg
, image002.jpeg
, etc. The optional -s flag will rescale images to fit the new WxH
values.
If you want to extract just a limited number of frames, you can use the above command in combination with the -vframes
or -t
option, or in combination with -ss
to start extracting from a certain point in time.
For more informations, check documentation.
Upvotes: 2