[FFmpeg-user] Extract N evenly spaced images from a video
Benjamin Black
benblack86 at gmail.com
Tue Feb 17 20:17:33 CET 2015
I've been searching everywhere to work out how to extract N evenly spaced images from a video using FFmpeg. All the answers involve playing with the rate setting (-r). However, I'm having some fundamental problems with the rate. According to the docs, the following should produce one frame per second.
ffmpeg -i input.mov -f image2 -r 1 preview-%d.jpeg
If input.mov is 7 seconds long, I would expect to get 7 images. However, I get 10. I also tried on a video 119 seconds long, but I got 122 images. I'm getting 3 more images than expected. What am I missing?
For example, with this ~3 second video I get six frames https://www.dropbox.com/s/8eke6q2gz1kgk1f/example.mov?dl=0
benblack$ ffmpeg -i example.mov -f image2 -r 1 preview-%d.jpeg
ffmpeg version 2.1.4 Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 2 2014 13:38:24 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'example.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2015-02-11 16:52:01
Duration: 00:00:02.83, start: 0.000000, bitrate: 736 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 638x468 [SAR 1:1 DAR 319:234], 726 kb/s, 59.29 fps, 60 tbr, 6k tbn, 12k tbc (default)
Metadata:
creation_time : 2015-02-11 16:52:01
handler_name : Core Media Data Handler
[swscaler @ 0x7fdb13008c00] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'preview-%d.jpeg':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf55.19.104
Stream #0:0(und): Video: mjpeg, yuvj420p, 638x468 [SAR 1:1 DAR 319:234], q=2-31, 200 kb/s, 90k tbn, 1 tbc (default)
Metadata:
creation_time : 2015-02-11 16:52:01
handler_name : Core Media Data Handler
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
frame= 6 fps=0.0 q=0.0 Lsize=N/A time=00:00:06.00 bitrate=N/A dup=0 drop=162
video:283kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.007598%
Any help or guidance would be much appreciated.
Thanks,
Ben
More information about the ffmpeg-user
mailing list