Currently I am using this command to extract the images:
ffmpeg -i input.mp4 output_%03d.jpeg
But how can I improve the JPEG image quality?
Join Stack Overflow to learn, share knowledge, and build your career.
Currently I am using this command to extract the images:
ffmpeg -i input.mp4 output_%03d.jpeg
But how can I improve the JPEG image quality?
-qscale:v to control qualityUse -qscale:v (or the alias -q:v) as an output option.
-qmin 1 output option (because the default is -qmin 2).ffmpeg -i input.mp4 -qscale:v 2 output_%03d.jpg
See the image muxer documentation for more options involving image outputs.
ffmpeg -ss 60 -i input.mp4 -qscale:v 4 -frames:v 1 output.jpg
Use -update 1 image muxer option. Example for once per second from a live streaming input:
ffmpeg -i rtmp://input.foo -q:v 4 -r 1 -update 1 output.jpg
-qmin 1 -qmax 1 in addition to -q:v 1 doubled the file size. And I can seem to see a very slight improvement also.
– complistic
Jun 27 '15 at 0:43
-qmin 1 -qmax 1 resulted in larger file, but gives me an exact same image. I validated this via photoshop, 2 layers and difference filter. The pixels are the same.
– cherouvim
Nov 30 '15 at 15:41
Output the images in a lossless format such as PNG:
ffmpeg.exe -i 10fps.h264 -r 10 -f image2 10fps.h264_%03d.png
Edit/Update: Not quite sure why I originally gave a strange filename example (with a possibly made-up extension).
I have since found that
-vsync 0is simpler than-r 10because it avoids needing to know the frame rate.This is something like what I currently use:
mkdir stills ffmpeg -i my-film.mp4 -vsync 0 -f image2 stills/my-film-%06d.pngTo extract only the key frames (which are likely to be of higher quality post-edit):
ffmpeg -skip_frame nokey -i my-film.mp4 -vsync 0 -f image2 stills/my-film-%06d.png
Then use another program (where you can more precisely specify quality, subsampling and DCT method – e.g. GIMP) to convert the PNGs you want to JPEG.
It is possible to obtain slightly sharper images in JPEG format this way than is possible with -qmin 1 -q:v 1 and outputting as JPEG directly from ffmpeg.
ffmpeg outputs PNG8 files which use only 256 colors (same as GIF). so it is actually very lossy.
– lapin
Feb 17 '20 at 6:51
ffmpeg] command, I get high quality png's that are of identical quality to the original video." What version of ffmpeg are you using that is outputting PNG8 files, and what is your input format?
– Jake
Feb 20 '20 at 0:29
identify image.png gives result "8-bit" when actually its not really single channel 8-bit, but 8-bit for R, G and B. IDK how the average identify user is supposed to understand that tho.
– lapin
Feb 20 '20 at 11:12
ffmpeg.
– Jake
Dec 10 '20 at 6:18