| 79 | |
| 80 | |
| 81 | def _postprocess_scene_list(context: CliContext, scene_list: SceneList) -> SceneList: |
| 82 | # Handle --merge-last-scene. If set, when the last scene is shorter than --min-scene-len, |
| 83 | # it will be merged with the previous one. |
| 84 | if ( |
| 85 | context.merge_last_scene |
| 86 | and context.min_scene_len is not None |
| 87 | and context.min_scene_len > 0 |
| 88 | and len(scene_list) > 1 |
| 89 | and (scene_list[-1][1] - scene_list[-1][0]) < context.min_scene_len |
| 90 | ): |
| 91 | new_last_scene = (scene_list[-2][0], scene_list[-1][1]) |
| 92 | scene_list = [*scene_list[:-2], new_last_scene] |
| 93 | |
| 94 | # Handle --drop-short-scenes. |
| 95 | if ( |
| 96 | context.drop_short_scenes |
| 97 | and context.min_scene_len is not None |
| 98 | and context.min_scene_len > 0 |
| 99 | ): |
| 100 | scene_list = [s for s in scene_list if (s[1] - s[0]) >= context.min_scene_len] |
| 101 | |
| 102 | return scene_list |
| 103 | |
| 104 | |
| 105 | def _detect(context: CliContext) -> tuple[SceneList, CutList] | None: |