Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small preview and progress #1331

Merged
merged 11 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle duration == None
  • Loading branch information
Andrey Zhavoronkov committed Mar 30, 2020
commit 05c379efb79ac950957263bc89a7e4da1ededfd4
4 changes: 2 additions & 2 deletions cvat/apps/engine/media_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def get_preview(self):
return self._get_preview(io_image)

def get_image_size(self):
img = Image.open(BytesIO(self._zip_source.read(self._source_path[0])))
img = Image.open(io.BytesIO(self._zip_source.read(self._source_path[0])))
return img.width, img.height

def get_image(self, i):
Expand Down Expand Up @@ -225,7 +225,7 @@ def get_progress(self, pos):
container = self._get_av_container()
# Not for all containers return real value
stream = container.streams.video[0]
return pos / stream.duration
return pos / stream.duration if stream.duration else None

def _get_av_container(self):
return av.open(av.datasets.curated(self._source_path[0]))
Expand Down
13 changes: 11 additions & 2 deletions cvat/apps/engine/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,18 @@ def _create_thread(tid, data):
db_data.original_chunk_type = models.DataChoice.VIDEO if task_mode == 'interpolation' else models.DataChoice.IMAGESET

def update_progress(progress):
job.meta['status'] = 'Images are being compressed... {}%'.format(round(progress * 100))
progress_animation = '|/-\\'
if not hasattr(update_progress, 'call_counter'):
update_progress.call_counter = 0

status_template = 'Images are being compressed {}'
if progress:
current_progress = '{}%'.format(round(progress * 100))
else:
current_progress = '{}'.format(progress_animation[update_progress.call_counter])
job.meta['status'] = status_template.format(current_progress)
job.save_meta()
update_progress.call_counter = (update_progress.call_counter + 1) % len(progress_animation)

compressed_chunk_writer_class = Mpeg4CompressedChunkWriter if db_data.compressed_chunk_type == DataChoice.VIDEO else ZipCompressedChunkWriter
original_chunk_writer_class = Mpeg4ChunkWriter if db_data.original_chunk_type == DataChoice.VIDEO else ZipChunkWriter
Expand All @@ -263,7 +273,6 @@ def update_progress(progress):
else:
db_data.chunk_size = 36


video_path = ""
video_size = (0, 0)

Expand Down