reprostim.capture.nosignal

Provides functionality to search no-signal/rainbow frames in the video files (*.mkv) recorded by reprostim-videocapture utility.

Functions

auto_fix_video(video_path, temp_path)

Fixes *.mkv video file with invalid audio/video timing by copying only video stream data.

calc_color_diff(color1, color2)

Calculates the color difference between two colors based on their RGB components.

find_no_signal(video_path[, step, ...])

Scans a video *.mkv file to detect frames that contain a rainbow pattern (no signal frames).

has_rainbow(frame)

Detects the presence of rainbow colors in a given frame.

has_rainbow2(frame)

Detects the presence of rainbow colors in a given frame (recommended).

init_grid_colors(ref_image_path)

Initializes rainbow screen image color table based on frame reference image.

Classes

VideoInfo(*[, error, is_invalid_timing, ...])

Class representing information about a video file.

class reprostim.capture.nosignal.VideoInfo(*, error: str = None, fps: float, width: int, height: int, is_invalid_timing: bool = False, is_truncated: bool = False, frames_count: int, nosignal_count: int, nosignal_rate: float, scanned_count: int)[source]

Class representing information about a video file.

error: str

Error message if any.

fps: float

Video frame rate (FPS).

frames_count: int

Specifies total number of frames.

height: int

Video frame height in px.

is_invalid_timing: bool

Specifies if video has invalid duration and needs in fixup (when calculated duration is 0 or greater than 2 days).

is_truncated: bool

Specifies truncated video which needs in fixup.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

nosignal_count: int

Specifies total number of nosignal frames.

nosignal_rate: float

Specifies rate of nosignal frames in fraction of total frames.

scanned_count: int

Specifies total number of scanned frames.

width: int

Video frame width in px.

reprostim.capture.nosignal.auto_fix_video(video_path: str, temp_path: str)[source]

Fixes *.mkv video file with invalid audio/video timing by copying only video stream data.

Note: audio data will be lost in generated file with fixup.

Parameters:
  • video_path – The path to the video file that needs to be fixed.

  • temp_path – The temporary path where the fixed video will be saved.

Example

>>> auto_fix_video("path/to/video.mp4", "path/to/fixed_video.mp4")
reprostim.capture.nosignal.calc_color_diff(color1, color2)[source]

Calculates the color difference between two colors based on their RGB components.

The color difference is computed as the sum of the absolute differences between the red, green, and blue channels of the two colors.

Parameters:
  • color1 – The first color, which should be in the format of a NumPy array or tuple containing the blue, green, and red components of the color.

  • color2 – The second color, which should also be in the same format as color1.

Returns:

The absolute sum of the differences between the red, green, and blue components of color1 and color2.

reprostim.capture.nosignal.find_no_signal(video_path: str, step: int = 1, number_of_checks: int = 0, show_progress_sec: float = 0.0, check_first_frames: int = 0) VideoInfo[source]

Scans a video *.mkv file to detect frames that contain a rainbow pattern (no signal frames).

This function opens a video file, scans frames for a specific nosignal image pattern, and returns statistics on the frames scanned, the frames with no signal, and the rate of no-signal frames.

Parameters:
  • video_path – The path to the video *.mkv file to scan.

  • step – The step size for frame scanning. The function skips frames by this step.

  • number_of_checks – The number of checks to perform. If greater than 0, this limits the number of frames to check in the video in range from 1st to the last one.

  • show_progress_sec – The interval (in seconds) to display progress during the scan in stdout. Progress is shown when show_progress_sec is greater than 0.0.

  • check_first_frames – The number of frames to check at the start of the video. If greater than 0, the scan will stop right after analyzing these frames.

Returns:

A VideoInfo object with scan details.

Example

video_info = find_no_signal("path/to/video.mp4", number_of_checks=5)
print(video_info.nosignal_rate)
reprostim.capture.nosignal.has_rainbow(frame)[source]

Detects the presence of rainbow colors in a given frame.

Note: produce false positive results on real data and was improved in has_rainbow2 API implementation.

Parameters:

frame – The input frame (image) in as a NumPy array.

Returns:

True if a significant number of rainbow pixels are detected, False otherwise.

reprostim.capture.nosignal.has_rainbow2(frame)[source]

Detects the presence of rainbow colors in a given frame (recommended).

Match nosignal grid colors using custom algorithm based on reference rainbow image sample data.

Parameters:

frame – The input frame (image) in as a NumPy array.

Returns:

True if a significant number of rainbow pixels are detected, False otherwise.

reprostim.capture.nosignal.init_grid_colors(ref_image_path: str)[source]

Initializes rainbow screen image color table based on frame reference image.

Note: necessary for has_rainbow2 API only.

Parameters:

frame – The reference image path.