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

Added support of mxf videos #2514

Merged
merged 2 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- MOTS png mask format support (<https://github.com/openvinotoolkit/cvat/pull/2198>)
- Ability to correct upload video with a rotation record in the metadata (<https://github.com/openvinotoolkit/cvat/pull/2218>)
- User search field for assignee fields (<https://github.com/openvinotoolkit/cvat/pull/2370>)
- Support of mxf videos (<https://github.com/openvinotoolkit/cvat/pull/2514>)

### Changed

Expand Down
1 change: 1 addition & 0 deletions cvat/apps/engine/media.mimetypes
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ video/mp2t m2t
video/mp2t bdmv
video/vnd.mpegurl m4u
video/mp4 m4v
video/mxf mxf

# possible image formats
image/x-minolta-mrw mrw
Expand Down
24 changes: 21 additions & 3 deletions cvat/apps/engine/tests/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,12 +1476,13 @@ def generate_image_files(*args):

return image_sizes, images

def generate_video_file(filename, width=1920, height=1080, duration=1, fps=25):
def generate_video_file(filename, width=1920, height=1080, duration=1, fps=25, codec_name='mpeg4'):
f = BytesIO()
total_frames = duration * fps
container = av.open(f, mode='w', format='mp4')
file_ext = os.path.splitext(filename)[1][1:]
container = av.open(f, mode='w', format=file_ext)

stream = container.add_stream('mpeg4', rate=fps)
stream = container.add_stream(codec_name=codec_name, rate=fps)
stream.width = width
stream.height = height
stream.pix_fmt = 'yuv420p'
Expand Down Expand Up @@ -2118,6 +2119,23 @@ def _test_api_v1_tasks_id_data(self, user):
self._test_api_v1_tasks_id_data_spec(user, task_spec, task_data, self.ChunkType.IMAGESET,
self.ChunkType.VIDEO, image_sizes, StorageMethodChoice.CACHE)

task_spec = {
"name": "test mxf format",
"use_zip_chunks": False,
"labels": [
{"name": "car"},
{"name": "person"},
],
}

image_sizes, video = generate_video_file(filename="test_video_1.mxf", width=1280, height=720, codec_name='mpeg2video')
task_data = {
"client_files[0]": video,
"image_quality": 51,
}

self._test_api_v1_tasks_id_data_spec(user, task_spec, task_data, self.ChunkType.VIDEO, self.ChunkType.VIDEO, image_sizes)

def test_api_v1_tasks_id_data_admin(self):
self._test_api_v1_tasks_id_data(self.admin)

Expand Down