从视频中提取图像(ffmpeg)

时间:2015-04-08 08:58:29

标签: ffmpeg

我正尝试使用ffmpeg

从视频中提取图片
ffmpeg -i sample.mp4 -vf fps=1/30 img%03d.jpg

但我收到以下错误

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

最后要求的是我需要以fps 30提取图像。

1 个答案:

答案 0 :(得分:-1)

用于从视频中提取图像:

ffmpeg -i sample.mp4 -r 30 -s WxH -f image2 image%03d.jpg

-r标志定义每秒提取的图像帧。它将在名为image001.jpegimage002.jpeg等的文件中输出它们。可选的-s标志将重新缩放图像以适应新的WxH值。

如果您只想提取有限数量的帧,可以将上述命令与-vframes-t选项结合使用,或与-ss结合使用以开始提取从某个时间点开始。

有关更多信息,请查看documentation