Jump to content

How to use OpenToken to play Live TV?


VicMoore

Recommended Posts

VicMoore

I have learned how to play movies and tv shows from the EMBY library.  I am now trying to play live content.  To do so I have watched what the Web Client does. Before playing the movie It POSTS a request for PlayBackInfo to the server:

http://192.168.1.201:8096/emby/Items/2564423/PlaybackInfo?UserId=e62c08bb99774ba794d6bcec82f76237&StartTimeTicks=0&IsPlayback=true&AutoOpenLiveStream=true&MaxStreamingBitrate=140000000&X-Emby-Client=Emby Web&X-Emby-Device-Name=Chrome Windows&X-Emby-Device-Id=20630783-23d6-40c3-9e69-414ea652ba5d&X-Emby-Client-Version=4.7.8.0&X-Emby-Token=1069c4b9b861424daf92bb47a7c0a050&reqformat=json

It receives back the LiveStreamId, which it uses later to play the IPTV stream

LiveStreamId: "06044cf0e6f93cdae5f285c9ecfaaeb4_01413a525b3a9622ce6fdf19f7dde354_45ff95b613fc94aee5320bdf127133dd"

When I issue the same request for PlayBackInfo i don't get the LiveStreamId.  Instead I get an  OpenToken.

OpenToken: "06044cf0e6f93cdae5f285c9ecfaaeb4_2564423_45ff95b613fc94aee5320bdf127133dd"

How do I use this OpenToken to get the LiveStreamId so I can play the stream with hls.js?

Vic

 

 

 

Link to comment
Share on other sites

HI, admittedly this whole sequence of communications is not well documented, so until I'm able to do that I would suggest mimicking the requests that the web app uses by monitoring them in the browser debugger.

Link to comment
Share on other sites

It used to be required with another request to open the live stream after /playbackinfo, but nowadays you can just add the param AutoOpenLiveStream=true to /playbackinfo and then I don't think you have to worry about it. You still have to close the live stream later though, but that gets handled for you when you report playback stopped.

Link to comment
Share on other sites

VicMoore

 

Thanks Luke, that worked, now I have the same "master.m3u8" url as the web app.  I give this url to hls.js program. But the live tv still does not play. I get an "error starting ffmpeg" error.

I have attached the server log below. 

Vic

embyserver (2).txt

Link to comment
Share on other sites

VicMoore

Luke, both logs are attached below.

The live channel, from which the logs below apply, did not play in my code or the Emby web app.  I tried to play other channels and they worked OK. 

Vic

embyserver (3).txt ffmpeg-transcode-38dee6ee-5931-4ad0-ad76-813fb397a9f5_1.txt

Edited by VicMoore
Link to comment
Share on other sites

  • 2 weeks later...
VicMoore

Good morning Luke...

I apologize for the long delay. I took time to run several test to aid my description of the problem.

Problem description:

I have initialized Live TV on my Emby server.  The  M3U url is https://i.mjh.nz/PlutoTV/us.m3u8.  the xml TV program guide is https://i.mjh.nz/PlutoTV/us.xml.gz

The problem is experienced by both the Emby web client and my own client (my code is attached below if you need it).

1) The test begins by restarting the Emby Server

2) click on Live TV and select from the EPG any of the live TV channels and play it.

3) the channel will play as expected. Now select several other channel and play them.  After doing this for a while go back and try playing some of the originally played channels. You will notice that some will not play. As you experiment, more channels wont play. Soon nothing will play.

4) the error is "error starting ffmpeg."  The Emby server and ffmpeg logs are attached below.

image.png.a0c325d3d8dc08b5564d3930f0bffb5b.png

Payload

image.png.46897a4fcb555e22877e2a606dc6e880.png

Preview

image.png.061b11580a907960de9e82b3328e579a.png

I have observed that the selected movie from the EPG always plays when the "PlaybackInfo" request to the server (made just before the master.msu8) takes 1 or 2 seconds (implying that the data is not from a cache). It seldom plays when the return is immediate (which could imply that it comes from a cache).  This is just an observation.  I turned off caching in my fetch requests and it didn't help things.

image.png.9b12dccb06f9b37b50b722a94406c942.png

5) if you restart the Emby server and return to the EPG to play programs, you will discover that everything plays again.  As before, playing programs degrades what will play.  Restarting the server temporarily fixes the problem. 

I hope this helps.

Vic

 

 

 

image.png

ffmpeg-directstream-f617ad20-414b-4130-87a1-3144f793d4f5_1.txt embyserver.txt ffmpeg-directstream-247df480-9af6-48dd-8102-0156af75faf6_1.txt ffmpeg-directstream-3181c32e-ed74-4f3f-92f4-4c923b7e9fc6_1.txt tool_2.0c.zip

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...