乐闻世界logo
搜索文章和话题

How to extract 1 screenshot for a video with ffmpeg at a given time?

1个答案

1

When using ffmpeg to capture screenshots from videos, ensure that ffmpeg is installed first. After installation, you can use the following command to extract a screenshot at a specified time point from a video:

bash
ffmpeg -ss [time] -i [video file path] -frames:v 1 [output file path]

Here is an explanation of the command parameters:

  • -ss [time]: This parameter sets the time point for the screenshot. The time format is typically HH:MM:SS, representing hours, minutes, and seconds.
  • -i [video file path]: This specifies the input video file path.
  • -frames:v 1: This parameter indicates that you want to extract only one video frame.
  • [output file path]: This is the path and filename for the output image. You can specify any image format you prefer, such as .jpg or .png.

For example, if you want to extract a screenshot at the 5-minute mark (i.e., 00:05:00) from the video example.mp4 and save it as output.jpg, you can use the following command:

bash
ffmpeg -ss 00:05:00 -i example.mp4 -frames:v 1 output.jpg

This will capture a screenshot at the 5-minute mark and save it as a JPEG file. This method is highly effective for quickly obtaining images at specific time points from videos.

Additionally, if you are concerned about the quality of the screenshot, you can add the -q:v parameter to adjust the output image quality. For example, -q:v 2 specifies a higher quality.

2024年8月9日 01:48 回复

你的答案