如何使用ffmpeg从视频文件中提取高质量的JPEG图像? [英] How can I extract a good quality JPEG image from a video file with ffmpeg?

查看:210
本文介绍了如何使用ffmpeg从视频文件中提取高质量的JPEG图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前我正在使用以下命令提取图像:

Currently I am using this command to extract the images:

ffmpeg -i input.mp4 output_%03d.jpeg

但是如何提高JPEG图像质量?

But how can I improve the JPEG image quality?

推荐答案

使用 -qscale:v 控制质量


使用 -qscale:v (或别名 -q:v )作为输出选项。

Use -qscale:v to control quality

Use -qscale:v (or the alias -q:v) as an output option.


  • JPEG的正常范围是2-31,质量最差的是31。

  • 缩放比例是线性的,而qscale的两倍是比特率的一半。

  • 建议尝试使用2-5的值。

  • 您可以使用值1,但必须添加 -qmin 1 输出选项(因为默认值为 -qmin 2 )。

  • Normal range for JPEG is 2-31 with 31 being the worst quality.
  • The scale is linear with double the qscale being roughly half the bitrate.
  • Recommend trying values of 2-5.
  • You can use a value of 1 but you must add the -qmin 1 output option (because the default is -qmin 2).
ffmpeg -i input.mp4 -qscale:v 2 output_%03d.jpg

请参见图像混合器文档

要在约60秒的时间内输出单个图像,请执行以下操作:


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

这将适用于任何视频输入。

This will work with any video input. See below if your input is MJPEG.

如果您输入的是MJPEG(Motion JPEG),则可以提取图像而不会造成任何质量损失。

If your input is MJPEG (Motion JPEG) then the images can be extracted without any quality loss.

ffmpeg ffprobe 控制台输出可以告诉您输入的内容是否为MJPEG:

The ffmpeg or ffprobe console output can tell you if your input is MJPEG:

$ ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=nw=1 input.avi
codec_name=mjpeg

然后您可以使用 mjpeg2jpeg 比特流过滤器

Then you can extract the frames using the mjpeg2jpeg bitstream filter:

$ ffmpeg -i input.avi -codec:v copy -bsf:v mjpeg2jpeg output_%03d.jpg




另请参见


查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆