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

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

问题描述

目前我正在使用此命令来提取图像:

Currently I am using this command to extract the images:


ffmpeg.exe -i 10fps.h264 -r 10 -f image2 10fps.h264_%03d.jpeg

ffmpeg.exe -i 10fps.h264 -r 10 -f image2 10fps.h264_%03d.jpeg

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

But how can I improve the JPEG image quality?

推荐答案

使用 -qscale:v



code> -qscale:v (或别名 -q:v )作为输出选项。 JPEG的有效范围是2-31,31是最差的质量。我建议尝试2-5的值。

Use -qscale:v

Use -qscale:v (or the alias -q:v) as an output option. Effective range for JPEG is 2-31 with 31 being the worst quality. I recommend trying values of 2-5.

输出一系列图像:

ffmpeg -i input.mp4 -qscale:v 2 output_%03d.jpg

要以约60秒的时间输出单张图像:

To output a single image at ~60 seconds duration:

ffmpeg -ss 60 -i input.mp4 -qscale:v 2 -vframes 1 output.jpg

这将适用于任何视频输入。如果您的输入是MJPEG,请参阅下文。

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

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

If you 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天全站免登陆