Channel Quality - Multiple Bitrates per Episode

It's probably bad form to start off with an apology, but... please forgive my ignorance here.  I'm rewriting the TGWTG channel because I want that content available to me, and the current TGWTG recently broke due to lack of backwards compatibility.

 

The question I have is this:

 

What is the proper way to return multiple qualities for any given item when the actual bitrate is unknown (but levels of quality are known at least as 1 < 2 < 3)?

 

For each of the TGWTG episodes, I've been able to drill down to the list of m4v files, which are assigned a value of either hdsd, or ld.  Is there a way to return all three?  Should they be given relative bitrate values somehow?

 

What is the best way to handle this?  Just pass the HD back and allow the Plex server to transcode for other devices?

If the source doesn’t advertise the actual bitrates, I usually will test a couple videos pull up the codec/bitrate information while playing them in VLC. Often the bitrates will vary from one video to the next, but an educated guess is usually sufficient when it comes to available bitrates and resolutions. If the hd/sd/ld all have different resolutions, that will also factor heavily into which video gets selected by the Plex client. Make sure to verify that they are using the same codecs for audio and video for the different videos. If so, make sure to include that info as it is important in determining whether clients direct play or request a transcode from the server.

If the source doesn't advertise the actual bitrates, I usually will test a couple videos pull up the codec/bitrate information while playing them in VLC. Often the bitrates will vary from one video to the next, but an educated guess is usually sufficient when it comes to available bitrates and resolutions. If the hd/sd/ld all have different resolutions, that will also factor heavily into which video gets selected by the Plex client. Make sure to verify that they are using the same codecs for audio and video for the different videos. If so, make sure to include that info as it is important in determining whether clients direct play or request a transcode from the server.

Thanks.  From a conceptual overview, that makes sense.

Not sure how this is done from a procedural standpoint, though.  Any code snippets (actual code, not pseudo) that would illustrate the return of multiple bitrates / filenames for the same "video"?

There are lots of URL Services in the Services.bundle that return multiple media objects for each VideoObject. A fairly straightforward example to look at is the one for GiantBomb, https://github.com/plexinc-plugins/Services.bundle/blob/master/Contents/Service%20Sets/com.plexapp.plugins.giantbomb/URL/GiantBomb/ServiceCode.pys#L38

Thanks.  That's exactly what I was looking for.

Sorry to bring back an old thread, but this seems an appropriate place to follow up.

Mikedm, your code example worked perfectly for me, but I'm finding that some clients are not presented with the bit rate selection screen.  On my PC and on the Web UI, I'm given the option of streams, but on my iPhone, it picks (I think) the highest quality.  For testing purposes, I rate limited my bandwidth at my router to see if it would select a different one, but no luck, it still tries for the highest quality, and then plays back horribly.

Is there any way to make the iOS app play nice with multi-bitrate files?

Sorry to bring back an old thread, but this seems an appropriate place to follow up.

Mikedm, your code example worked perfectly for me, but I'm finding that some clients are not presented with the bit rate selection screen. On my PC and on the Web UI, I'm given the option of streams, but on my iPhone, it picks (I think) the highest quality. For testing purposes, I rate limited my bandwidth at my router to see if it would select a different one, but no luck, it still tries for the highest quality, and then plays back horribly.

Is there any way to make the iOS app play nice with multi-bitrate files?

The iOS client selects which bitrate to play based on your settings in the iOS client preferences. Like so:
Posted Image

I'll do some testing with that then, thank you.

Unfortunately, this doesn't appear to work (perhaps it only affects the transcoder quality?)

This is a picture of the stream when I have my bitrates set to 8Mbps local, 8Mbps remote and 3Mbps cellular:

http://imgur.com/gNpsLzM

This is a picture when I force the stream (in code) to the lowest bitrate (by removing the other options):

http://imgur.com/WmeCR9p

And finally, this is a picture when I enable all bitrates in code again, and set my streaming quality options to 320kbps local, 320kbps remote and 64kbps cellular:

http://imgur.com/gfMiqo2

For what it's worth, prior to my first message, I also tried changing the direct play option in the advanced settings to "Prioritize Playability" instead of Quality (when I had my router rate limited to 300kbps)

It definitely should respect those settings. Can you paste (or link to) your MediaObjectsForURL() code? It’s possible that a bug found its way in to the iOS code but, I’d like to see your implementation before we start fretting about that posibility.

Sure thing, here's my code:

def MediaObjectsForURL(url):
return [
	GetMediaObject(url, 4500, 1080, 120), # this is a lie, this stream is really 720 and 120 fps.  but plex only shows the resolution, so lets lie a bit and make it clearer for the user
	GetMediaObject(url, 3000, 720, 60),
	GetMediaObject(url, 1600, 540, 60),
	GetMediaObject(url, 1200, 432, 60),
	GetMediaObject(url, 800, 360, 60),
	GetMediaObject(url, 400, 224, 60)
]

def GetMediaObject(url, quality, resolution, framerate):
return MediaObject(
optimized_for_streaming=True,
parts = [PartObject(key=HTTPLiveStreamURL(Callback(PlayVideo, url=url, quality=str(quality))))],
audio_codec = AudioCodec.AAC,
audio_channels = 2,
container = Container.MP4,
bitrate = quality,
video_resolution = resolution,
video_frame_rate = framerate
)

If it matters, the streams in question are M3U8 playlists.

Here's a link to the full service code if you need: https://github.com/pudds/Hockey.bundle/blob/prefs-change-multi-bitrate/Contents/Services/URL/Hockey/ServiceCode.pys

Thanks for the assistance man.

The only thing that looks like it possibly might cause issues, is that you’re setting the container-type to “mp4” when you’re working with HLS. The HTTPLiveStreamURL() function automatically sets the correct container type, so you can remove the “container = Container.MP4” line from GetMediaObject().
It’s unlikely that’s actually what’s causing your specific problem though. Are the HLS streams adaptive?
I might have to play with it a little myself to see if I can figure out what’s going on. Does the plugin require a subscription?

They don't seem to be adaptive, you have to select the bitrate ahead of time and then you're stuck with that one.

No, the code doesn't require a subscription, if you check out the "prefs-change-multi-bitrate" branch from the linked github repository, you'll be on the same code I'm working with.

Downside is that the streams are live, so you can't do any real testing until there is a game on.

Actually I having trouble with the Giantbomb 1080p streams, they don't work for me and then I came across this thread which listed some of the specs for the stream the plex app of giant bomb offers.      

"   parts = [PartObject(key=Callback(PlayVideo, url=url, fmt='hd'))],

            bitrate = 2400,
            video_resolution = 1080"
 
But I've also found a thread on the giant bomb forum from someone with the same problem and it mentioned that ;"The highest resolution videos on Giant Bomb are 720p, and they recently (this year?) went up to 4mbps for video bit rate (from the 3.5mbps they used for years before that). I did see that P-Dawg encoded his latest spooooky vidz at 5mbps, which was nice." 
   
Is there something wrong with the services.bundle or the API or the channel bundle that it won't play the highest quality version under the label 1080p in the plex channel?

They don't seem to be adaptive, you have to select the bitrate ahead of time and then you're stuck with that one.

No, the code doesn't require a subscription, if you check out the "prefs-change-multi-bitrate" branch from the linked github repository, you'll be on the same code I'm working with.

Downside is that the streams are live, so you can't do any real testing until there is a game on.

Try removing the container and audio_codec args, since both of those are set automatically by the HTTPLiveStreamURL() function. Mis-information there could very well break playback on some clients.

Actually I having trouble with the Giantbomb 1080p streams, they don't work for me and then I came across this thread which listed some of the specs for the stream the plex app of giant bomb offers.
" parts = [PartObject(key=Callback(PlayVideo, url=url, fmt='hd'))],
bitrate = 2400,
video_resolution = 1080"

But I've also found a thread on the giant bomb forum from someone with the same problem and it mentioned that ;"The highest resolution videos on Giant Bomb are 720p, and they recently (this year?) went up to 4mbps for video bit rate (from the 3.5mbps they used for years before that). I did see that P-Dawg encoded his latest spooooky vidz at 5mbps, which was nice."

Is there something wrong with the services.bundle or the API or the channel bundle that it won't play the highest quality version under the label 1080p in the plex channel?

If you're interested in trying to fix the GiantBomb issue, please start a new thread. Or if you're just looking for support, reply to the (or start a new) GiantBomb thread in Plex Channels forum.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.