Extract Sub-Image from Video to BMP with FFmpeg
This article provides a quick and practical guide on how to extract a specific portion of a video frame (a sub-image) at a precise timestamp and save it as a BMP image using the powerful command-line tool FFmpeg. You will learn the exact command syntax and how to configure the cropping coordinates to get the perfect image extract.
To extract a cropped sub-image from a video and save it as a BMP, you need to combine FFmpeg’s seeking capability with its cropping video filter.
The FFmpeg Command
Run the following command in your terminal:
ffmpeg -ss 00:01:30 -i input.mp4 -vf "crop=w=400:h=300:x=100:y=150" -vframes 1 output.bmpParameter Breakdown
-ss 00:01:30: Seeks to the exact timestamp in the video where you want to extract the frame (formatted asHH:MM:SSor in seconds, e.g.,90). Placing this before-iensures fast seeking.-i input.mp4: Specifies the path to your source video file.-vf "crop=w=400:h=300:x=100:y=150": Applies the video crop filter.w: The width of the sub-image you want to extract (e.g., 400 pixels).h: The height of the sub-image you want to extract (e.g., 300 pixels).x: The horizontal coordinate of the top-left corner of the crop area (e.g., 100 pixels from the left edge).y: The vertical coordinate of the top-left corner of the crop area (e.g., 150 pixels from the top edge).
-vframes 1: Instructs FFmpeg to stop processing after exporting exactly one frame.output.bmp: The name of the output file. FFmpeg automatically recognizes the.bmpextension and encodes the image in the uncompressed BMP format.