Skip to content

Commit

Permalink
Update docker image and add dataset ID handling in video framerate ch…
Browse files Browse the repository at this point in the history
…ange
  • Loading branch information
GoldenAnpu committed Dec 16, 2024
1 parent 4a52dc0 commit 580b8eb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"data operations"
],
"description": "Change video framerate with preserving duration (recodes video)",
"docker_image": "supervisely/data-operations:6.72.157",
"docker_image": "supervisely/data-operations:6.73.256",
"instance_version": "6.12.12",
"main_script": "src/main.py",
"modal_template": "src/modal.html",
"modal_template_state": {
Expand All @@ -24,7 +25,8 @@
"headless": true,
"context_menu": {
"target": [
"videos_project"
"videos_project",
"videos_dataset"
]
},
"poster": "https://github.com/supervisely-ecosystem/change-video-framerate/releases/download/v0.1.0/app-poster.png"
Expand Down
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
supervisely[apps]==6.72.157
supervisely[apps]==6.73.256
ffmpeg_python==0.2.0
1 change: 1 addition & 0 deletions src/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
TEAM_ID = int(os.environ['context.teamId'])
WORKSPACE_ID = int(os.environ['context.workspaceId'])
PROJECT_ID = int(os.environ['modal.state.slyProjectId'])
DATASET_ID = int(os.environ['modal.state.slyDatasetId'])

TARGET_FPS = float(os.environ['modal.state.targetFps'])
RES_PROJECT_NAME = os.getenv('modal.state.resultProjectName', None)
8 changes: 7 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

@sly.timeit
def change_framerate(api: sly.Api, target_fps, result_project_name):

if g.DATASET_ID and g.PROJECT_ID is None:
datasets = [api.dataset.get_info_by_id(g.DATASET_ID)]
g.PROJECT_ID = datasets[0].project_id
else:
datasets = api.dataset.get_list(g.PROJECT_ID)

if not result_project_name:
project_info = api.project.get_info_by_id(g.PROJECT_ID)
result_project_name = f'{project_info.name} {target_fps:.6g} FPS'
Expand All @@ -29,7 +36,6 @@ def change_framerate(api: sly.Api, target_fps, result_project_name):
api.project.update_meta(res_project.id, meta_json)
dummy_map = KeyIdMap()

datasets = api.dataset.get_list(g.PROJECT_ID)
progress = sly.Progress('Video recoding', sum(ds.items_count for ds in datasets))

for dataset in datasets:
Expand Down

0 comments on commit 580b8eb

Please sign in to comment.