mirror of
https://github.com/mediacms-io/mediacms.git
synced 2024-11-22 00:03:28 +01:00
check resolution for HLS (#832)
This commit is contained in:
parent
4bf41fe80e
commit
fe7427a1f2
@ -818,6 +818,7 @@ class Media(models.Model):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
res = {}
|
res = {}
|
||||||
|
valid_resolutions = [240, 360, 480, 720, 1080, 1440, 2160]
|
||||||
if self.hls_file:
|
if self.hls_file:
|
||||||
if os.path.exists(self.hls_file):
|
if os.path.exists(self.hls_file):
|
||||||
hls_file = self.hls_file
|
hls_file = self.hls_file
|
||||||
@ -829,11 +830,20 @@ class Media(models.Model):
|
|||||||
uri = os.path.join(p, iframe_playlist.uri)
|
uri = os.path.join(p, iframe_playlist.uri)
|
||||||
if os.path.exists(uri):
|
if os.path.exists(uri):
|
||||||
resolution = iframe_playlist.iframe_stream_info.resolution[1]
|
resolution = iframe_playlist.iframe_stream_info.resolution[1]
|
||||||
|
# most probably video is vertical, getting the first value to
|
||||||
|
# be the resolution
|
||||||
|
if resolution not in valid_resolutions:
|
||||||
|
resolution = iframe_playlist.iframe_stream_info.resolution[0]
|
||||||
|
|
||||||
res["{}_iframe".format(resolution)] = helpers.url_from_path(uri)
|
res["{}_iframe".format(resolution)] = helpers.url_from_path(uri)
|
||||||
for playlist in m3u8_obj.playlists:
|
for playlist in m3u8_obj.playlists:
|
||||||
uri = os.path.join(p, playlist.uri)
|
uri = os.path.join(p, playlist.uri)
|
||||||
if os.path.exists(uri):
|
if os.path.exists(uri):
|
||||||
resolution = playlist.stream_info.resolution[1]
|
resolution = playlist.stream_info.resolution[1]
|
||||||
|
# same as above
|
||||||
|
if resolution not in valid_resolutions:
|
||||||
|
resolution = playlist.stream_info.resolution[0]
|
||||||
|
|
||||||
res["{}_playlist".format(resolution)] = helpers.url_from_path(uri)
|
res["{}_playlist".format(resolution)] = helpers.url_from_path(uri)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user