Crate extract_frames

Source

Structsยง

Args ๐Ÿ”’
Command line argument parser using clap derive macro Defines the CLI interface for the frame extraction application

Constantsยง

FRAMES_BETWEEN_EXTRACTED ๐Ÿ”’
Number of frames to skip between extracted frames For 30fps video, skipping 30 frames extracts 1 frame per second Adjust this value to control extraction frequency and output size
FRAME_FILES_PATTERN ๐Ÿ”’
Glob pattern to match all PNG frame images in the frames directory Used for cleanup operations and file enumeration
SEGMENTED_FILES_PATTERN ๐Ÿ”’
Glob pattern to match all MP4 segment files in the segments directory Used for finding and cleaning up temporary segment files after processing
SEGMENT_DURATION_SECONDS ๐Ÿ”’
Duration in seconds for each video segment when splitting videos for parallel processing. Default is 5 seconds per segment.
SEGMENT_OUTPUT_PATTERN ๐Ÿ”’
File naming pattern for ffmpeg segment output files using printf-style formatting %09d creates zero-padded 9-digit numbers (e.g., output_000000001.mp4)

Functionsยง

cleanup_temporary_files ๐Ÿ”’
Cleans up the working directories by removing all PNG images in the frames folder and all MP4 segments in the segments folder. Logs the result.
decode_frames_dropping ๐Ÿ”’
Decodes video frames by dropping frames according to FRAMES_BETWEEN_EXTRACTED constant.
decode_frames_seeking ๐Ÿ”’
Decodes one frame per second by seeking to specific timestamps.
get_files ๐Ÿ”’
Finds all files matching the given glob pattern and returns their paths.
main ๐Ÿ”’
Main entry point for the frame extraction application.
remove_files ๐Ÿ”’
Attempts to remove all files in the specified slice with batch error handling.
remove_folder ๐Ÿ”’
Removes a directory and all its contents recursively.
save_rgb_to_image ๐Ÿ”’
Saves raw RGB pixel data as a PNG image at the specified path.
split_into_segments ๐Ÿ”’
Uses ffmpeg to split the source video file into several segments.