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

[GSoC2024] added better error message when video resolution too large #7549

Merged
merged 9 commits into from
Mar 11, 2024
8 changes: 8 additions & 0 deletions cvat/apps/engine/media_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from random import shuffle
from cvat.apps.engine.utils import rotate_image
from cvat.apps.engine.models import DimensionType, SortingMethod
from rest_framework.exceptions import ValidationError

# fixes: "OSError:broken data stream" when executing line 72 while loading images downloaded from the web
# see: https://stackoverflow.com/questions/42462431/oserror-broken-data-stream-when-reading-image-file
Expand Down Expand Up @@ -722,6 +723,7 @@ def save_as_chunk(

class Mpeg4ChunkWriter(IChunkWriter):
FORMAT = 'mp4'
MAX_MBS_PER_FRAME = 36864

def __init__(self, quality=67):
# translate inversed range [1:100] to [0:51]
Expand Down Expand Up @@ -752,6 +754,12 @@ def _add_video_stream(self, container, w, h, rate, options):
if w % 2:
w += 1

# libopenh264 has 4K limitations, https://github.com/opencv/cvat/issues/7425
if h * w > (self.MAX_MBS_PER_FRAME << 8):
raise ValidationError(
'The video codec being used does not support such high video resolution, refer https://github.com/opencv/cvat/issues/7425'
)

video_stream = container.add_stream(self._codec_name, rate=rate)
video_stream.pix_fmt = "yuv420p"
video_stream.width = w
Expand Down
Loading