Repository: noppanut15/depthviz

Issue:
Increase video resolution
A user reported that the overlay text breaks a little bit.

We need to increase the video size from 640x360 maybe to 960x540 (with a specific bitrate, e.g., `5000k`) as we need to trade off between quality and processing time.



![Image](https://github.com/user-attachments/assets/3bdd0ffb-7a3e-471e-84c9-646a8aa00f1d)

Alternative solutions:
* Add an option `--resolution <360p|480p|540p|720p|1080p>` -> The `text` must be resized proportionally. (Currently, the video size `360p` has the text size `100px`.)

Discussion:

Patch:
diff --git a/src/depthviz/core.py b/src/depthviz/core.py
index 90d62e5..6bc7f8e 100644
--- a/src/depthviz/core.py
+++ b/src/depthviz/core.py
@@ -17,6 +17,7 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
 DEFAULT_FONT = os.path.abspath(
     os.path.join(BASE_DIR, "assets/fonts/Open_Sans/static/OpenSans-Bold.ttf")
 )
+DEFAULT_VIDEO_SIZE = (960, 540)
 
 
 class DepthReportVideoCreatorError(Exception):
@@ -39,7 +40,6 @@ class DepthReportVideoCreator:
     def __init__(
         self,
         font: str = DEFAULT_FONT,
-        fontsize: int = 100,
         interline: int = -20,
         color: str = "white",
         bg_color: str = "black",
@@ -47,10 +47,13 @@ class DepthReportVideoCreator:
         stroke_width: int = 2,
         align: str = "center",
         size: Tuple[int, int] = (640, 360),
+        bitrate: str = "5000k",
         fps: int = 25,
     ):
         self.font = font
-        self.fontsize = fontsize
+        self.fontsize = int(
+            size[1] * 120 / 360
+        )  # 120 is the default font size for 640x360 resolution
         self.interline = interline
         self.color = color
         self.bg_color = bg_color
@@ -58,6 +61,7 @@ class DepthReportVideoCreator:
         self.stroke_width = stroke_width
         self.align = align
         self.size = size
+        self.bitrate = bitrate
         self.fps = fps
         self.final_video = None
         self.progress_bar_logger_config = {
@@ -200,6 +204,7 @@ class DepthReportVideoCreator:
                 self.final_video.write_videofile(
                     path,
                     fps=self.fps,
+                    bitrate=self.bitrate,
                     logger=DepthVizProgessBarLogger(
                         description="Exporting",
                         unit=self.progress_bar_logger_config["unit"],
diff --git a/src/depthviz/main.py b/src/depthviz/main.py
index 32a3e58..5144b66 100644
--- a/src/depthviz/main.py
+++ b/src/depthviz/main.py
@@ -18,6 +18,7 @@ from depthviz.core import (
     DepthReportVideoCreator,
     DepthReportVideoCreatorError,
     DEFAULT_FONT,
+    DEFAULT_VIDEO_SIZE,
 )
 
 # Banner for the command line interface
@@ -112,7 +113,11 @@ class DepthvizApplication:
             time_data_from_divelog = divelog_parser.get_time_data()
             depth_data_from_divelog = divelog_parser.get_depth_data()
             depth_report_video_creator = DepthReportVideoCreator(
-                fps=25, font=font, bg_color=bg_color, stroke_width=stroke_width
+                fps=25,
+                font=font,
+                bg_color=bg_color,
+                stroke_width=stroke_width,
+                size=DEFAULT_VIDEO_SIZE,
             )
             depth_report_video_creator.render_depth_report_video(
                 time_data=time_data_from_divelog,


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
index c43ba22..51d7cfa 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -13,6 +13,8 @@ from depthviz.parsers.generic.generic_divelog_parser import DiveLogParser
 from depthviz.core import DepthReportVideoCreatorError, DEFAULT_FONT
 
 
+# Mock the DEFAULT_VIDEO_SIZE constant to lower the resolution for faster tests.
+@mock.patch("depthviz.main.DEFAULT_VIDEO_SIZE", (640, 360))
 class TestMainCLI:
     """
     Test suite for the main CLI.