reprostim.capture.nosignal¶
Provides functionality to search no-signal/rainbow frames in
the video files (*.mkv) recorded by reprostim-videocapture
utility.
Functions
|
Fixes |
|
Calculates the color difference between two colors based on their RGB components. |
|
Scans a video |
|
Detects the presence of rainbow colors in a given frame. |
|
Detects the presence of rainbow colors in a given frame (recommended). |
|
Initializes rainbow screen image color table based on frame reference image. |
Classes
|
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
*.mkvvideo 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, andbluechannels 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, andredcomponents 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, andbluecomponents ofcolor1andcolor2.
- 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
*.mkvfile 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
*.mkvfile 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_secis 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
VideoInfoobject 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:
Trueif a significant number of rainbow pixels are detected,Falseotherwise.
- 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:
Trueif a significant number of rainbow pixels are detected,Falseotherwise.