Skip to content

Commit

Permalink
Refactor resolution handling to convert environment variable to boole…
Browse files Browse the repository at this point in the history
…an and pass target resolution to video conversion function
  • Loading branch information
GoldenAnpu committed Dec 16, 2024
1 parent de37ddb commit cdbdf6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from fastapi import FastAPI
from supervisely.app.fastapi import create
from supervisely.app.content import get_data_dir
from distutils.util import strtobool


app_root_directory = os.getcwd()
Expand All @@ -26,7 +27,7 @@
WORKSPACE_ID = int(os.environ['context.workspaceId'])
PROJECT_ID = int(os.environ['modal.state.slyProjectId'])
DATASET_ID = int(os.environ['modal.state.slyDatasetId'])
CHANGE_RESOLUTION = os.environ['modal.state.changeResolution']
CHANGE_RESOLUTION = bool(strtobool(os.environ['modal.state.changeResolution']))
TARGET_HEIGHT = int(os.environ['modal.state.targetResolutionHeight'])
TARGET_WIDTH = int(os.environ['modal.state.targetResolutionWidth'])
target_resolution = (TARGET_WIDTH, TARGET_HEIGHT)
Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def change_framerate(api: sly.Api, target_fps, result_project_name):

api.video.download_path(video_info.id, in_fpath)
sly.logger.debug(f'Downloaded video to {in_fpath!r}')
convert_video(target_fps, in_fpath, out_fpath)
convert_video(target_fps, in_fpath, out_fpath, g.target_resolution)
sly.logger.debug(f'Converted video to {out_fpath!r}')
api.video.upload_paths(res_dataset.id, (video_info.name,), (out_fpath,))
sly.logger.debug('Uploaded video')
Expand Down

0 comments on commit cdbdf6e

Please sign in to comment.