Returns a list of tuples of start/end FrameTimecodes for each scene based on a list of detected scene cuts/breaks. This function is called when using the :meth:`SceneManager.get_scene_list` method. The scene list is generated from a cutting list (:meth:`SceneManager.get_cut_list`),
(
cut_list: CutList,
start_pos: int | FrameTimecode,
end_pos: int | FrameTimecode,
)
| 141 | |
| 142 | |
| 143 | def get_scenes_from_cuts( |
| 144 | cut_list: CutList, |
| 145 | start_pos: int | FrameTimecode, |
| 146 | end_pos: int | FrameTimecode, |
| 147 | ) -> SceneList: |
| 148 | """Returns a list of tuples of start/end FrameTimecodes for each scene based on a |
| 149 | list of detected scene cuts/breaks. |
| 150 | |
| 151 | This function is called when using the :meth:`SceneManager.get_scene_list` method. |
| 152 | The scene list is generated from a cutting list (:meth:`SceneManager.get_cut_list`), |
| 153 | noting that each scene is contiguous, starting from the first to last frame of the input. |
| 154 | If `cut_list` is empty, the resulting scene will span from `start_pos` to `end_pos`. |
| 155 | |
| 156 | Arguments: |
| 157 | cut_list: List of FrameTimecode objects where scene cuts/breaks occur. |
| 158 | num_frames: The number of frames, or FrameTimecode representing duration, of the video that |
| 159 | was processed (used to generate last scene's end time). |
| 160 | start_frame: The start frame or FrameTimecode of the cut list. Used to generate the first |
| 161 | scene's start time. |
| 162 | Returns: |
| 163 | List of tuples in the form (start_time, end_time), where both start_time and |
| 164 | end_time are FrameTimecode objects representing the exact time/frame where each |
| 165 | scene occupies based on the input cut_list. |
| 166 | """ |
| 167 | |
| 168 | # Scene list, where scenes are tuples of (Start FrameTimecode, End FrameTimecode). |
| 169 | scene_list = [] |
| 170 | if not cut_list: |
| 171 | scene_list.append((start_pos, end_pos)) |
| 172 | return scene_list |
| 173 | # Initialize last_cut to the first frame we processed,as it will be |
| 174 | # the start timecode for the first scene in the list. |
| 175 | last_cut = start_pos |
| 176 | for cut in cut_list: |
| 177 | scene_list.append((last_cut, cut)) |
| 178 | last_cut = cut |
| 179 | # Last scene is from last cut to end of video. |
| 180 | scene_list.append((last_cut, end_pos)) |
| 181 | |
| 182 | return scene_list |
| 183 | |
| 184 | |
| 185 | ## |
no outgoing calls
no test coverage detected