Commit ec552cf1 by Nimisha Asthagiri

Merge pull request #5981 from edx/mobile/MA-141

MA-141 Support webm encoding for VAL-enabled videos
parents 08cd3272 caf5d539
...@@ -184,20 +184,26 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers, ...@@ -184,20 +184,26 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers,
# stream. # stream.
if self.edx_video_id and edxval_api: if self.edx_video_id and edxval_api:
try: try:
val_video_urls = edxval_api.get_urls_for_profiles( val_profiles = ["youtube", "desktop_webm", "desktop_mp4"]
self.edx_video_id, ["desktop_mp4", "youtube"] val_video_urls = edxval_api.get_urls_for_profiles(self.edx_video_id, val_profiles)
)
# VAL will always give us the keys for the profiles we asked for, but # VAL will always give us the keys for the profiles we asked for, but
# if it doesn't have an encoded video entry for that Video + Profile, the # if it doesn't have an encoded video entry for that Video + Profile, the
# value will map to `None` # value will map to `None`
if val_video_urls["desktop_mp4"]:
if self.download_video: # add the non-youtube urls to the list of alternative sources
download_video_link = val_video_urls["desktop_mp4"] # use the last non-None non-youtube url as the link to download the video
# add the desktop_mp4 profile to the list of alternative sources for url in [val_video_urls[p] for p in val_profiles if p != "youtube"]:
if val_video_urls["desktop_mp4"] not in sources: if url:
sources.append(val_video_urls["desktop_mp4"]) if url not in sources:
sources.append(url)
if self.download_video:
download_video_link = url
# set the youtube url
if val_video_urls["youtube"]: if val_video_urls["youtube"]:
youtube_streams = "1.00:{}".format(val_video_urls["youtube"]) youtube_streams = "1.00:{}".format(val_video_urls["youtube"])
except edxval_api.ValInternalError: except edxval_api.ValInternalError:
# VAL raises this exception if it can't find data for the edx video ID. This can happen if the # VAL raises this exception if it can't find data for the edx video ID. This can happen if the
# course data is ported to a machine that does not have the VAL data. So for now, pass on this # course data is ported to a machine that does not have the VAL data. So for now, pass on this
......
...@@ -512,28 +512,33 @@ class TestGetHtmlMethod(BaseTestXmodule): ...@@ -512,28 +512,33 @@ class TestGetHtmlMethod(BaseTestXmodule):
) )
def test_get_html_with_existing_edx_video_id(self): def test_get_html_with_existing_edx_video_id(self):
result = create_profile( # create test profiles and their encodings
dict( encoded_videos = []
profile_name="desktop_mp4", for profile, extension in [("desktop_webm", "webm"), ("desktop_mp4", "mp4")]:
extension="mp4", result = create_profile(
width=200, dict(
height=2001 profile_name=profile,
extension=extension,
width=200,
height=2001
)
) )
) self.assertEqual(result, profile)
self.assertEqual(result, "desktop_mp4") encoded_videos.append(
dict(
url=u"http://fake-video.edx.org/thundercats.{}".format(extension),
file_size=9000,
bitrate=42,
profile=profile,
)
)
result = create_video( result = create_video(
dict( dict(
client_video_id="Thunder Cats", client_video_id="Thunder Cats",
duration=111, duration=111,
edx_video_id="thundercats", edx_video_id="thundercats",
encoded_videos=[ encoded_videos=encoded_videos
dict(
url=u"http://fake-video.edx.org/thundercats.mp4",
file_size=9000,
bitrate=42,
profile="desktop_mp4",
)
]
) )
) )
self.assertEqual(result, "thundercats") self.assertEqual(result, "thundercats")
...@@ -549,6 +554,7 @@ class TestGetHtmlMethod(BaseTestXmodule): ...@@ -549,6 +554,7 @@ class TestGetHtmlMethod(BaseTestXmodule):
{sources} {sources}
</video> </video>
""" """
data = { data = {
'download_video': 'true', 'download_video': 'true',
'source': 'example_source.mp4', 'source': 'example_source.mp4',
...@@ -559,8 +565,11 @@ class TestGetHtmlMethod(BaseTestXmodule): ...@@ -559,8 +565,11 @@ class TestGetHtmlMethod(BaseTestXmodule):
'edx_video_id': "thundercats", 'edx_video_id': "thundercats",
'result': { 'result': {
'download_video_link': u'http://fake-video.edx.org/thundercats.mp4', 'download_video_link': u'http://fake-video.edx.org/thundercats.mp4',
# make sure the desktop_mp4 url is included as part of the alternative sources. # make sure the urls for the various encodings are included as part of the alternative sources.
'sources': json.dumps([u'example.mp4', u'example.webm', u"http://fake-video.edx.org/thundercats.mp4"]), 'sources': json.dumps(
[u'example.mp4', u'example.webm'] +
[video['url'] for video in encoded_videos]
),
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment