diff --git a/tsmark/video_annotator.py b/tsmark/video_annotator.py index c6cf04f..e260b79 100755 --- a/tsmark/video_annotator.py +++ b/tsmark/video_annotator.py @@ -861,10 +861,10 @@ class World: w2 = max(1, a[3] / 2) h2 = max(1, a[4] / 2) return { - "x0": int(a[1] - w2), - "y0": int(a[2] - h2), - "x1": int(a[1] + w2), - "y1": int(a[2] + h2), + "x0": max(0, int(a[1] - w2)), + "y0": max(0, int(a[2] - h2)), + "x1": min(self.video_res[0] - 1, int(a[1] + w2)), + "y1": min(self.video_res[1] - 1, int(a[2] + h2)), "type": "interp", "visible": visible, }