Vidoe2Jpg

probe_video_dimensions(video_path:Union[str, os.PathLike])
Uses ffprobe to get the width and height of the first video stream.
Parameters:
Returns:
Tuple[int, int]: Tuple of (width, height) in pixels.
Labels:

src_PyThon_FFMpeg_Vidoe2Jpg_probe_video_dimensions

prepare_output_directory(output_pattern:Path, wipe:bool)
Ensures output directory exists and wipes existing files if requested. Returns the directory Path.
Parameters:
Returns:
Path: The output directory path.
Labels:

src_PyThon_FFMpeg_Vidoe2Jpg_prepare_output_directory

build_vf_filter(fps:int, height:int, min_height:int, grayscale:bool)
Constructs the ffmpeg -vf filter string, adding padding if height < min_height, and converting to grayscale if requested.
Parameters:
Returns:
str: The constructed filter string for ffmpeg.
Todo:
- Add support Rotation and maybe save the rotated video
Labels:

src_PyThon_FFMpeg_Vidoe2Jpg_build_vf_filter

run_ffmpeg_extraction(input_path:Path, output_pattern:Path, vf_filter:str, use_cuda:bool, grayscale:bool)
Executes ffmpeg with the given filters and codec settings.
Parameters:
Raises:
Labels:

src_PyThon_FFMpeg_Vidoe2Jpg_run_ffmpeg_extraction

health_check_frames(directory:Path, ext:str)
Attempts to open and verify each image file in directory with Pillow. Raises RuntimeError if any are corrupted.
Parameters:
Returns:
list: list of corrupted frame paths.
Raises:
Warning:
If any frame files are corrupted, listing their paths.
Labels:

src_PyThon_FFMpeg_Vidoe2Jpg_health_check_frames

ffmpeg_frame_extractor(input_video_path:Union[str, os.PathLike], output_frame_pattern:Optional[Union[str, os.PathLike]], fps:int, wipe:bool, use_cuda:bool, grayscale:bool, health_check:bool, min_height:int)
High-level frame extractor that orchestrates probing, directory setup, filter construction, FFmpeg extraction, and optional post-check.
Parameters:
Returns:
None: Frames are saved to the specified output pattern.
Raises:
Labels:

src_PyThon_FFMpeg_Vidoe2Jpg_ffmpeg_frame_extractor

get_mp4_files(root_dir: Union[str, os.PathLike], max_depth:int)
Recursively scans a directory for .mp4 files up to a specified depth.
Parameters:
Returns:
list: A sorted list of paths to .mp4 files found within the specified depth.
Raises:
Labels:

src_PyThon_FFMpeg_Vidoe2Jpg_get_mp4_files

check_AllVideosHaveSameDimensions(video_root:str, max_depth:int)
Checks if all videos in the provided list have the same dimensions. Returns True if they do, False otherwise.
Parameters:
Returns:
bool: True if all videos have the same dimensions, False otherwise.
Labels:

src_PyThon_FFMpeg_Vidoe2Jpg_check_AllVideosHaveSameDimensions

fix_corrupted_frames(corrupted:list[os.PathLike], grey:bool)
Detects corrupted frames via health_check_frames and interpolates replacements using the nearest valid neighboring frames.
Parameters:
Returns:
None: Replaces corrupted frames with interpolated images..
Raises:
Labels:

src_PyThon_FFMpeg_Vidoe2Jpg_fix_corrupted_frames