Merge branch add-transcoding-types
Add several AVC1 profile/levels that are necessary now. Also fix the video source type attribute.
This commit is contained in:
@@ -8,5 +8,6 @@ class GetShortNameOfTranscodingTypeTestCase(SimpleTestCase):
|
||||
self.assertEqual(result, 'vp8')
|
||||
|
||||
def test_gets_transcoding_by_transcoding_object(self):
|
||||
result = get_short_name_of_transcoding_type(TranscodingType(name='Looooong naaaaame', short_name='shrt nm'))
|
||||
self.assertEqual(result, 'shrt nm')
|
||||
result = get_short_name_of_transcoding_type(TranscodingType(name='Looooong naaaaame', short_name='shrt nm',
|
||||
description='Some Description'))
|
||||
self.assertEqual(result, 'shrt nm')
|
||||
|
||||
@@ -24,7 +24,7 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
models.Transcoding,
|
||||
video=video,
|
||||
quality='480p',
|
||||
type='video/webm',
|
||||
type='video/webm; codecs="vp9, opus"',
|
||||
url='http://480p.webm',
|
||||
)
|
||||
transcoding2 = factories.create(
|
||||
@@ -38,7 +38,7 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
models.Transcoding,
|
||||
video=video,
|
||||
quality='720p',
|
||||
type='video/webm',
|
||||
type='video/webm; codecs="vp9, opus"',
|
||||
url='http://720p.webm',
|
||||
)
|
||||
transcoding4 = factories.create(
|
||||
@@ -60,8 +60,8 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
self.assertInHTML(
|
||||
"""<video width="853" height="480" controls="controls">
|
||||
<source src="http://480p.mp4" type='video/mp4' />
|
||||
<source src="http://480p.webm" type='video/webm' />
|
||||
You need a browser that understands HTML5 video and supports h.264 or vp8 codecs.
|
||||
<source src="http://480p.webm" type='video/webm; codecs="vp9, opus"' />
|
||||
You need a browser that understands HTML5 video and supports h.264 or vp9 codecs.
|
||||
</video>""",
|
||||
content,
|
||||
)
|
||||
@@ -96,7 +96,7 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
models.Transcoding,
|
||||
video=video,
|
||||
quality='480p',
|
||||
type='video/webm',
|
||||
type='video/webm; codecs="vp8, vorbis"',
|
||||
url='http://480p.webm',
|
||||
)
|
||||
transcoding2 = factories.create(
|
||||
@@ -110,7 +110,7 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
models.Transcoding,
|
||||
video=video,
|
||||
quality='720p',
|
||||
type='video/webm',
|
||||
type='video/webm; codecs="vp8, vorbis"',
|
||||
url='http://720p.webm',
|
||||
)
|
||||
transcoding4 = factories.create(
|
||||
@@ -130,7 +130,7 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
self.assertInHTML(
|
||||
"""<video width="1280" height="720" controls="controls">
|
||||
<source src="http://720p.mp4" type='video/mp4' />
|
||||
<source src="http://720p.webm" type='video/webm' />
|
||||
<source src="http://720p.webm" type='video/webm; codecs="vp8, vorbis"' />
|
||||
You need a browser that understands HTML5 video and supports h.264 or vp8 codecs.
|
||||
</video>""",
|
||||
content,
|
||||
@@ -156,7 +156,7 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
models.Transcoding,
|
||||
video=video,
|
||||
quality='480p',
|
||||
type='video/webm',
|
||||
type='video/webm; codecs="vp8, vorbis"',
|
||||
url='http://480p.webm',
|
||||
)
|
||||
transcoding2 = factories.create(
|
||||
@@ -170,7 +170,7 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
models.Transcoding,
|
||||
video=video,
|
||||
quality='720p',
|
||||
type='video/webm',
|
||||
type='video/webm; codecs="vp8, vorbis"',
|
||||
url='http://720p.webm',
|
||||
)
|
||||
transcoding4 = factories.create(
|
||||
@@ -191,7 +191,7 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
self.assertInHTML(
|
||||
"""<video width="1280" height="720" controls="controls">
|
||||
<source src="http://720p.mp4" type='video/mp4' />
|
||||
<source src="http://720p.webm" type='video/webm' />
|
||||
<source src="http://720p.webm" type='video/webm; codecs="vp8, vorbis"' />
|
||||
You need a browser that understands HTML5 video and supports h.264 or vp8 codecs.
|
||||
</video>""",
|
||||
content,
|
||||
@@ -221,7 +221,7 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
models.Transcoding,
|
||||
video=video,
|
||||
quality='480p',
|
||||
type='video/webm',
|
||||
type='video/webm; codecs="vp8, vorbis"',
|
||||
upload=movie,
|
||||
)
|
||||
|
||||
@@ -234,7 +234,7 @@ class VideoTestCase(UploadMixin, TestCase):
|
||||
|
||||
self.assertInHTML(
|
||||
"""<video width="853" height="480" poster="{image}" controls="controls">
|
||||
<source src="{url}" type='video/webm' />
|
||||
<source src="{url}" type='video/webm; codecs="vp8, vorbis"' />
|
||||
You need a browser that understands HTML5 video and supports vp8 codecs.
|
||||
</video>""".format(url=movie.file.url, image=image.file.url),
|
||||
content,
|
||||
|
||||
@@ -15,6 +15,7 @@ class Quality(NamedTuple):
|
||||
class TranscodingType(NamedTuple):
|
||||
name: str
|
||||
short_name: str
|
||||
description: str
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -27,11 +28,18 @@ qualities = (
|
||||
)
|
||||
|
||||
transcoding_types = (
|
||||
TranscodingType(name='video/webm', short_name='vp8'),
|
||||
TranscodingType(name='video/webm; codecs="vp8, vorbis"', short_name='vp8'),
|
||||
TranscodingType(name='video/webm; codecs="vp9, opus"', short_name='vp9'),
|
||||
TranscodingType(name='video/mp4', short_name='h.264'),
|
||||
TranscodingType(name='video/mp4; codecs="avc1.64001f,mp4a.40.2"', short_name='h.264'),
|
||||
TranscodingType(name='video/webm', short_name='webm', description='Generic WebM'),
|
||||
TranscodingType(name='video/webm; codecs="vp8, vorbis"', short_name='vp8', description='WebM with VP8 and Vorbis'),
|
||||
TranscodingType(name='video/webm; codecs="vp9, opus"', short_name='vp9', description='WebM with VP9 and Opus'),
|
||||
TranscodingType(name='video/mp4', short_name='h.264', description='Generic MP4 with H.264'),
|
||||
TranscodingType(name='video/mp4; codecs="avc1.64001e,mp4a.40.2"', short_name='h.264',
|
||||
description='MP4 with H.264 (AVC1 profile High, Level 3.0) and AAC-LC'),
|
||||
TranscodingType(name='video/mp4; codecs="avc1.64001f,mp4a.40.2"', short_name='h.264',
|
||||
description='MP4 with H.264 (AVC1 profile High, Level 3.1) and AAC-LC'),
|
||||
TranscodingType(name='video/mp4; codecs="avc1.640028,mp4a.40.2"', short_name='h.264',
|
||||
description='MP4 with H.264 (AVC1 profile High, Level 4.0) and AAC-LC'),
|
||||
TranscodingType(name='video/mp4; codecs="avc1.640032,mp4a.40.2"', short_name='h.264',
|
||||
description='MP4 with H.264 (AVC1 profile High, Level 5.0) and AAC-LC'),
|
||||
)
|
||||
|
||||
class Upload(models.Model):
|
||||
@@ -112,4 +120,4 @@ def get_short_name_of_transcoding_type(transcoding_type: Union[str, TranscodingT
|
||||
transcoding_type = type_
|
||||
|
||||
if isinstance(transcoding_type, TranscodingType):
|
||||
return transcoding_type.short_name
|
||||
return transcoding_type.short_name
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<h1>{{ title }}</h1>
|
||||
<video width="{{ width }}" height="{{ height }}" {% if poster %}poster="{{ poster }}" {% endif %}controls="controls">
|
||||
{% for source in sources %}
|
||||
<source src="{{ source.src }}" type='{{ source.type }}' />
|
||||
<source src="{{ source.src }}" type='{{ source.type|safe }}' />
|
||||
{% endfor %}
|
||||
You need a browser that understands HTML5 video and supports {% for i in used_codecs %}{{ i }}{% if not loop.last %} or {% endif %}{% endfor %} codecs.
|
||||
</video><br />
|
||||
@@ -33,4 +33,4 @@
|
||||
<script data-container="commenter-container" src="//www.welmers.net/commenter/js/commenter.js" type="text/javascript"></script>
|
||||
<script src="static/js/video.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user