Skip to content

Commit

Permalink
Added support of mxf videos (#2514)
Browse files Browse the repository at this point in the history
* added support of mxf videos
  • Loading branch information
Andrey Zhavoronkov authored Dec 1, 2020
1 parent f2fb053 commit 45e2ea0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
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 @@ -1697,12 +1697,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 @@ -2339,6 +2340,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

0 comments on commit 45e2ea0

Please sign in to comment.