diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b12654da4da..c198eaf9d732 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- TDB +- Incorrectly determined video frame count when the video contains an MP4 edit list + () ### Security diff --git a/cvat/apps/engine/task.py b/cvat/apps/engine/task.py index 98c35de7568f..104436a23852 100644 --- a/cvat/apps/engine/task.py +++ b/cvat/apps/engine/task.py @@ -932,7 +932,6 @@ def _update_status(msg): manifest_path=db_data.get_manifest_path()) manifest.init_index() manifest.validate_seek_key_frames() - manifest.validate_frame_numbers() assert len(manifest) > 0, 'No key frames.' all_frames = manifest.video_length diff --git a/utils/dataset_manifest/core.py b/utils/dataset_manifest/core.py index 1be0976849c6..e049e0217c71 100644 --- a/utils/dataset_manifest/core.py +++ b/utils/dataset_manifest/core.py @@ -46,10 +46,6 @@ def __init__(self, source_path, chunk_size, force): ) self.height, self.width = (frame.height, frame.width) - # not all videos contain information about numbers of frames - if video_stream.frames: - self._frames_number = video_stream.frames - return @property @@ -63,6 +59,9 @@ def _get_video_stream(container): return video_stream def __len__(self): + assert self._frames_number is not None, \ + "The length will not be available until the reader is iterated all the way through at least once" + return self._frames_number @property @@ -498,7 +497,7 @@ def _write_base_information(self, file): def _write_core_part(self, file, _tqdm): iterable_obj = self._reader if _tqdm is None else \ - _tqdm(self._reader, desc="Manifest creating", total=len(self._reader)) + _tqdm(self._reader, desc="Manifest creating", total=float("inf")) for item in iterable_obj: if isinstance(item, tuple): json_item = json.dumps({ @@ -510,17 +509,12 @@ def _write_core_part(self, file, _tqdm): def create(self, *, _tqdm=None): # pylint: disable=arguments-differ """ Creating and saving a manifest file """ - if not len(self._reader): - tmp_file = StringIO() - self._write_core_part(tmp_file, _tqdm) + tmp_file = StringIO() + self._write_core_part(tmp_file, _tqdm) - with open(self._manifest.path, 'w') as manifest_file: - self._write_base_information(manifest_file) - manifest_file.write(tmp_file.getvalue()) - else: - with open(self._manifest.path, 'w') as manifest_file: - self._write_base_information(manifest_file) - self._write_core_part(manifest_file, _tqdm) + with open(self._manifest.path, 'w') as manifest_file: + self._write_base_information(manifest_file) + manifest_file.write(tmp_file.getvalue()) self.set_index() @@ -576,15 +570,6 @@ def validate_seek_key_frames(self): self.validate_key_frame(container, video_stream, key_frame) last_key_frame = key_frame - def validate_frame_numbers(self): - with closing(av.open(self._source_path, mode='r')) as container: - video_stream = self._get_video_stream(container) - # not all videos contain information about numbers of frames - frames = video_stream.frames - if frames: - assert frames == self.video_length, "The uploaded manifest does not match the video" - return - class ImageProperties(dict): @property def full_name(self):