I'm trying to figure out how can I make a HLS Stream videoclip work.
I have the m3u8 link so I did something like this because I read that Plex framework will handle the playback for me:
# url contains the m3u8 link # title a string to use as title # thumb an image link to use as thumbnail def play(url, title, thumb): oc = ObjectContainer( title2 = title )oc.add(VideoClipObject(
key = Callback(
play,
url = url,
title = title,
thumb = thumb
),
rating_key = title,
items = [
MediaObject(
protocol = Protocol.HLS,
container = Container.MP4,
video_codec = VideoCodec.H264,
audio_codec = AudioCodec.AAC,
audio_channels = 2,
parts = [
PartObject(
key = url
)
]
)
],
title = title,
thumb = Resource.ContentsOfURLWithFallback(url = thumb)
))return oc
And indeed it works but the quality of the video is horrible.
I have downloaded the m3u8 to have a look inside and it looks like this:
#EXTM3U #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=500000 http://foo.bar/baz/MB_500/chunklist.m3u8?secureHash=OTUuMjAuNS4yMDU=&nva=20150405194831&token=02ba9cef8c1589bb3323b #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1200000 http://foo.bar/baz/MB_1200/chunklist.m3u8?secureHash=OTUuMjAuNS4yMDU=&nva=20150405194831&token=00f41f436a008a009e489 #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2000000 http://foo.bar/baz/MB_2000/chunklist.m3u8?secureHash=OTUuMjAuNS4yMDU=&nva=20150405194831&token=031d311bc14d6aa28dcd5
So looks it contains 3 different qualities for the stream.
Is there a way to specify which of the qualities to use in the MediaObject? Or must I create a Callback to extract all that data myself and create a MediaObject for each quality? Anyone knows a channel doing something similar?
Thanks.