# HTTPLiveStreamURL

**URL:** <https://forums.plex.tv/t/httplivestreamurl/48355>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [November 30, 2013, 8:11pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355 "2013-11-30T20:11:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![shopgirl284](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@shopgirl284](https://forums.plex.tv/u/shopgirl284)\
**Post date:** [November 30, 2013, 8:11pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/1 "2013-11-30T20:11:59Z")

</div>

Here is a question for you guys.

&nbsp;

Since it is not currently in the documentation, what exactly is HTTPLiveStreamURL() and how can it be used?

&nbsp;

I know it can be used in the MediaObject to automatically set the attributes with:

```
MediaObject(
       parts = [PartObject(key = HTTPLiveStreamURL(url))]
     )
```

Is it only for use within the MediaObject()? &nbsp;And does it automatically set all the attributes for MediaObject()? Are there any other attributes you may or may not want to add?

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [December 1, 2013, 12:08am UTC](https://forums.plex.tv/t/httplivestreamurl/48355/2 "2013-12-01T00:08:40Z")

</div>

_HTTPLiveStreamURL_ will set the following attributes and values for you:

```
protocol = 'hls'
container = 'mpegts'
video_codec = VideoCodec.H264
audio_codec = AudioCodec.AAC
```

Other attributes you can set:&nbsp;

```
video_resolution = '480'
audio_channels = 2
optimized_for_streaming = True
```

---

<div class="post-metadata">

**Author:** ![papalozarou](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@papalozarou](https://forums.plex.tv/u/papalozarou)\
**Post date:** [August 7, 2014, 9:43pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/3 "2014-08-07T21:43:50Z")

</div>

Trying to make a channel work with HTTPLiveStreamURL and get errors if I include anything else apart from the URL argument. Is the above still valid?

Also is there anything else that you can put in container?

---

<div class="post-metadata">

**Author:** ![mikedm139](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mikedm139/32/96909_2.png) [@mikedm139](https://forums.plex.tv/u/mikedm139)\
**Post date:** [August 7, 2014, 11:14pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/4 "2014-08-07T23:14:26Z")

</div>

> Trying to make a channel work with HTTPLiveStreamURL and get errors if I include anything else apart from the URL argument. Is the above still valid?
> 
> Also is there anything else that you can put in container?

Yes, it is still valid. HTTPLiveStreamURL takes the url for an m3u8 playlist as the key argument. Alternatively, you can call a function to execute some code and return the m3u8 playlist url using a Callback() as the key parameter.

```
MediaObject(
       parts = [PartObject(key = HTTPLiveStreamURL(Callback(PlayVideo, url)))]
     )
```

where PlayVideo() is defined something like this:

```
@indirect
def PlayVideo(url):
''' take the given url and execute necessary requests/manipulation to return a valid video url'''
  ...
  return IndirectResponse(VideoClipObject, key=m3u8_url)
```

What else are you trying to add to the container?

---

<div class="post-metadata">

**Author:** ![papalozarou](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@papalozarou](https://forums.plex.tv/u/papalozarou)\
**Post date:** [August 8, 2014, 12:06am UTC](https://forums.plex.tv/t/httplivestreamurl/48355/5 "2014-08-08T00:06:22Z")

</div>

I've basically picked up my RTMP streaming plugin again, and then realised in a proper 'doh' moment that the site works on iOS as well so therefore must have HLS streams, which it does.

I've successfully converted my code to use the HLS streams, but I'm still getting an error when trying to play on iOS/Apple TV etc. Weirdly, I get the same error in Chrome as well, but the stream plays (although it pauses and then plays back like it's on fast forward, pauses, plays back like ff, whilst the audio is fine). PHT works as expected, and I can play streams directly in VLC and Quicktime via my constructed URL (for reference the site uses a randomised pool of IP addresses, I assume to spread load).

I've currently got this:

```
CHANNEL_OBJECT = VideoClipObject(
        key = Callback(CreateChannelEpisodeObject,QUALITY=QUALITY,TITLE=TITLE,SUMMARY=SUMMARY,NUMBER=NUMBER,THUMB=THUMB,INCLUDE_CONTAINER=True),
        rating_key = NUMBER,
        title = TITLE,
        summary = SUMMARY,
        thumb = R(THUMB),
        items = [
            MediaObject(
                video_codec = VideoCodec.H264,
                video_resolution = HEIGHT,
                audio_codec = AudioCodec.AAC,
                audio_channels = 2,
                protocol = 'HTTPLiveStreaming',
                optimized_for_streaming = True,
                height = HEIGHT,
                width = WIDTH,
                parts = [
                    PartObject(
                        key = HTTPLiveStreamURL(
                            url = URL   
                        )
                    )
                ]
            )
        ]
    )

```
if INCLUDE_CONTAINER:
  return ObjectContainer(objects=[CHANNEL_OBJECT])
else:
  return CHANNEL_OBJECT

```
```

And was just about to hack that down a bit to see if less detail made it work on iOS

The error I get (via iOS devices, and Chrome, despite it playing the url) is:

```
ERROR - [Transcoder] Failed to open bitstream filter h264_mp4toannexb for stream 0 with codec cop
ERROR - [Transcoder] : Invalid argument
```

And it basically constantly spits that out for the duration of the time you try to access the stream on an iOS device.

---

<div class="post-metadata">

**Author:** ![papalozarou](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@papalozarou](https://forums.plex.tv/u/papalozarou)\
**Post date:** [August 8, 2014, 7:45am UTC](https://forums.plex.tv/t/httplivestreamurl/48355/6 "2014-08-08T07:45:19Z")

</div>

Just to update – i removed the audio\_codec, video\_codec and protocol attributes from the MediaObject and it now works across all the devices I have to test it on (iPad, iPhone, Apple TV, PHT, both Chrome and Safari.

It seems like the extra details, or duplication of detail in this case as defaults were okay, seems to force other clients to into thinking they need to transcode the streams.

This, I assume, is probably \_not\_ news to some of you.&nbsp; ;)

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [August 8, 2014, 2:48pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/7 "2014-08-08T14:48:01Z")

</div>

If you're using&nbsp;_HTTPLiveStreamURL_ some attributes are set automatically. In this case, this should be enough:

```
        items                   = [
            MediaObject(
                video_resolution        = HEIGHT,
                audio_channels          = 2,
                optimized_for_streaming = True,
                height                  = HEIGHT,
                width                   = WIDTH,
                parts                   = [
                    PartObject(
                        key             = HTTPLiveStreamURL(url=URL)
                    )
                ]
            )
        ]
```

If you want to set values manually, you can leave out the&nbsp;_HTTPLiveStreamURL_ and do this:

```
        items                   = [
            MediaObject(
                protocol                = 'hls', # protocol = 'HTTPLiveStreaming' is incorrect, 'hls' is the correct value.
                container               = 'mpegts',
                video_codec             = VideoCodec.H264,
                video_resolution        = HEIGHT,
                audio_codec             = AudioCodec.AAC,
                audio_channels          = 2,
                optimized_for_streaming = True,
                height                  = HEIGHT,
                width                   = WIDTH,
                parts                   = [
                    PartObject(
                        key             = URL
                    )
                ]
            )
        ]
```

&nbsp;

---

<div class="post-metadata">

**Author:** ![papalozarou](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@papalozarou](https://forums.plex.tv/u/papalozarou)\
**Post date:** [August 8, 2014, 3:16pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/8 "2014-08-08T15:16:06Z")

</div>

I've gone with the first solution you've posted sander1, but might try the second one as it's not working on my Nexus 7 (original one) on Android 4.4.3 (though it works on Galaxy Nexus with Android 4.3).

---

<div class="post-metadata">

**Author:** ![papalozarou](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@papalozarou](https://forums.plex.tv/u/papalozarou)\
**Post date:** [August 8, 2014, 3:16pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/9 "2014-08-08T15:16:32Z")

</div>

Also wondering if the @indirect method has any effect on it playing on more devices?

---

<div class="post-metadata">

**Author:** ![papalozarou](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@papalozarou](https://forums.plex.tv/u/papalozarou)\
**Post date:** [November 29, 2015, 1:00pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/10 "2015-11-29T13:00:48Z")

</div>

Once again revisiting this as I’m updating a plugin.

I’ve got this working on everything but iOS/Apple TV 4. So it works on PHT, Plex Web, Android AND Apple TV 3 via PlexConnect, but refuses to work via the iOS or Apple TV 4 apps.

The code I’m using is:

`CHANNEL_OBJECT = VideoClipObject( key = Callback( CreateChannelEpisodeObject, TITLE = TITLE, URL = URL, SUMMARY = SUMMARY, THUMB = THUMB, INCLUDE_CONTAINER = True ), rating_key = URL, title = TITLE, summary = SUMMARY, thumb = R(THUMB), items = [MediaObject( video_resolution = RESOLUTION, width = WIDTH, height = HEIGHT, audio_channels = 2, optimized_for_streaming = True, video_frame_rate = 25, parts = [ PartObject( key = HTTPLiveStreamURL( url = URL ) )] ) ] )`

(WIDTH, HEIGHT and RESOLUTION are calculated based on whether the stream is HD or not)

The logs look exactly the same whether it’s attempting to play back on say Plex Web (or PHT) or in the iOS/Apple TV apps.

I can also play the streams, using the generated URLs, directly in VLC on Mac, or via Infuse on iOS.

---

<div class="post-metadata">

**Author:** ![coryo123](https://avatars.discourse-cdn.com/v4/letter/c/a587f6/32.png) [@coryo123](https://forums.plex.tv/u/coryo123)\
**Post date:** [November 29, 2015, 6:43pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/11 "2015-11-29T18:43:07Z")

</div>

It seems like HLS is always trying to be transcoded for iOS.

HLS isn’t in the ‘DirectPlayProfiles’ of the iOS Profile in `Program Files (x86)\Plex Media Server\Resources\Profiles\iOS.xml` or `usr/local/plexmediaserver/Resources/Profiles/iOS.xml`.

I removed the HLS entry from TranscodeTargets in that file, and put in DirectPlayProfiles:

```auto
<VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac,mp3" context="streaming" />

```

so `Plex Media Server\Resources\Profiles\iOS.xml` now looks like:

```auto
<?xml version="1.0" encoding="utf-8"?>
<Client name="iOS">
  <!-- Author: Plex Inc. -->
  <!-- This profile is used by A5 and higher devices (starting with iPhone 4S and iPad 3) -->
  <TranscodeTargets>
    <VideoProfile container="mp4" codec="h264" audioCodec="aac" context="static">
      <Setting name="VideoEncodeFlags" value="-x264opts bframes=3:cabac=1" />
    </VideoProfile>
    <MusicProfile container="mp3" codec="mp3" />
    <PhotoProfile container="jpeg" />
    <SubtitleProfile protocol="hls" container="webvtt" subtitleCodec="webvtt"/>
  </TranscodeTargets>
  <DirectPlayProfiles>
    <VideoProfile container="mp4" codec="h264,mpeg4" audioCodec="aac,mp3" subtitleCodec="ttxt,tx3g" />
    <VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac,mp3" context="streaming" />
    <!-- Since iOS may have issues direct playing mov/*/mp3 it has its own profile -->
    <VideoProfile container="mov" codec="h264,mpeg4" audioCodec="aac" subtitleCodec="ttxt,tx3g,mov_text" />
    <MusicProfile container="mp3" codec="mp3" />
    <MusicProfile container="mp4" codec="aac" />
    <PhotoProfile container="jpeg" />
  </DirectPlayProfiles>
  <CodecProfiles>
    <VideoCodec name="h264">
      <Limitations>
        <UpperBound name="video.width" value="1920" />
        <UpperBound name="video.height" value="1080" />
        <UpperBound name="video.bitDepth" value="8" isRequired="false" />
      </Limitations>
    </VideoCodec>
    <VideoAudioCodec name="aac">
      <Limitations>
        <UpperBound name="audio.channels" value="2" />
      </Limitations>
    </VideoAudioCodec>
  </CodecProfiles>
</Client>

```

After restarting my server, HLS content from my Twitch TV channel was able to play on iPad.

---

<div class="post-metadata">

**Author:** ![krisvenden](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/krisvenden/32/308256_2.png) [@krisvenden](https://forums.plex.tv/u/krisvenden)\
**Post date:** [November 29, 2015, 8:00pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/12 "2015-11-29T20:00:47Z")

</div>

Hmm, I followed your instructions to a T and now rather than the endless spinning circle and no stream ever loading, I instantly get a popup box that says “Uh-oh! Couldn’t create the playback session for this time” with an Ok box or x to get rid of. I feel like I’m so close… any other ideas?

---

<div class="post-metadata">

**Author:** ![MaestroJAL](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/maestrojal/32/7562_2.png) [@MaestroJAL](https://forums.plex.tv/u/MaestroJAL)\
**Post date:** [November 29, 2015, 8:19pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/13 "2015-11-29T20:19:13Z")

</div>

Can confirm this works for me! Great work coryo123! Such an easy fix too. I updated all of the iOS profiles because I have many different iOS devices. You might want to try the same thing volcom45.

For Mac users: Right click on the Plex Media Server application and choose “Show Package Contents”. Then choose “Contents”. From there you can follow coryo123’s instructions.

---

<div class="post-metadata">

**Author:** ![coryo123](https://avatars.discourse-cdn.com/v4/letter/c/a587f6/32.png) [@coryo123](https://forums.plex.tv/u/coryo123)\
**Post date:** [November 29, 2015, 8:35pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/14 "2015-11-29T20:35:40Z")

</div>

@volcom45  
I think there’s more to the issue.

my [Twitch.tv](http://Twitch.tv) channel gives HTTPLiveStreamURL for both live streams and vod content, and after my fix, the live streams work but the vods don’t.

Also YouTubeTV gives HTTPLiveStreamURL from youtube, and that also doesn’t work.

At least we got some content to load though.

---

<div class="post-metadata">

**Author:** ![Phatland](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/phatland/32/4435_2.png) [@Phatland](https://forums.plex.tv/u/Phatland)\
**Post date:** [November 29, 2015, 8:55pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/15 "2015-11-29T20:55:36Z")

</div>

Cant get my own media to play with this fix, channels great tho…

---

<div class="post-metadata">

**Author:** ![krisvenden](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/krisvenden/32/308256_2.png) [@krisvenden](https://forums.plex.tv/u/krisvenden)\
**Post date:** [November 29, 2015, 9:03pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/16 "2015-11-29T21:03:15Z")

</div>

Haha, even weirder, I decided to change it back to the way it was before and saved, but haven’t restarted server yet, and just tried again and now it’s working fine for first time ever… 😛

---

<div class="post-metadata">

**Author:** ![Phatland](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/phatland/32/4435_2.png) [@Phatland](https://forums.plex.tv/u/Phatland)\
**Post date:** [November 29, 2015, 9:19pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/17 "2015-11-29T21:19:26Z")

</div>

> @volcom45 said:  
> Haha, even weirder, I decided to change it back to the way it was before and saved, but haven’t restarted server yet, and just tried again and now it’s working fine for first time ever… 😛

Can you play your own media and channels, everything works?

---

<div class="post-metadata">

**Author:** ![papalozarou](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@papalozarou](https://forums.plex.tv/u/papalozarou)\
**Post date:** [November 30, 2015, 4:17pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/18 "2015-11-30T16:17:58Z")

</div>

Is this a recent change to PMS?

My plugin/Channel used to work, with the same HLS URLs, on iOS devices.

---

<div class="post-metadata">

**Author:** ![krisvenden](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/krisvenden/32/308256_2.png) [@krisvenden](https://forums.plex.tv/u/krisvenden)\
**Post date:** [November 30, 2015, 7:09pm UTC](https://forums.plex.tv/t/httplivestreamurl/48355/19 "2015-11-30T19:09:23Z")

</div>

> @Phatland said:
> 
> > @krisvenden said:  
> > Haha, even weirder, I decided to change it back to the way it was before and saved, but haven’t restarted server yet, and just tried again and now it’s working fine for first time ever… 😛
> 
> Can you play your own media and channels, everything works?

Hmm, nope my own media seems broken now… which is real weird because file should be back to the way it was originally now yet channels continue to work and my media doesn’t.

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [December 1, 2015, 8:25am UTC](https://forums.plex.tv/t/httplivestreamurl/48355/20 "2015-12-01T08:25:24Z")

</div>

There is a known issue with playing HTTP Live Stream videos on iOS and tvOS in Plex clients. Devs are aware of it.

[Next page](https://forums.plex.tv/t/httplivestreamurl/48355.md?page=2)
