But Don't Fill Your Hard-Drive...

Posted at

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px__2016-01-18_033413

The following line will
- extract (well.. generate) an keyframe representing image, of EVERY keyframe image in your video file,
- a "ratio-correct" 100 pixel width image,
- a loosely JPEG output with quality of 15, which is about 53% (from 0-100) in terms of quality where 100 is highest quality and 0 is lowest quality,
- all total it will be a lot (!) of files, but 100 files will weight (size) in ~67.2 KB,
which if you'll be using this command to generate a way of (let's say..) trimming a video by visually showing the keyframes, and providing a range collector (..for example), will still generate nice output,

you can even stretch it a bit (in client side!) so it will "look bigger" if you'll keep the 100x? ratio (which is easy to remember, right?)

ffmpeg -threads 4 -i my_movie.mp4 -vf "select=eq(pict_type\\,I)" -vsync vfr -filter:v scale=100:-1,crop=iw:ih*0.8 -q:v 15 -qscale:v 15 out%05d.jpg





Here are the first ~~52 frames of this YouTube video:






icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00001

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00002

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00003

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00004

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00005

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00006

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00007

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00008

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00009

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00010

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00011

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00012

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00013

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00014

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00015

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00016

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00017

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00018

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00019

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00020

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00021

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00022

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00023

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00024

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00025

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00026

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00027

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00028

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00029

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00030

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00031

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00032

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00033

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00034

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00035

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00036

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00037

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00038

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00039

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00040

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00041

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00042

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00043

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00044

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00045

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00046

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00047

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00048

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00049

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00050

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00051

icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00052


Looking on one of the images, if you'll keep the ratio you can probably "fake" resize it, still holding the same file size, on reasonable quality

original:
<img src="https://icompile.eladkarako.com/_uploads/2016/01/icompile.eladkarako.com_ffmpeg_keyframes_extraction_100px_00052.jpg" width="100" height="44" />


x1.5
..width="150" height="66"..


x2
..width="200" height="88"..



still looks quite decent :)

naturally you can always scale up:
- image size (by width and ratio -- eventually amount of pixels in the image),
- quality (both -q factors from 1 to 32 where 32 is worst-quality and 1 is best) - to vary the JPEG compression algorithm

', 'FFMPEG - Extract All Keyframes