Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ojo1
Reel Rookie

Start live channel with timeshift at live position

Jump to solution

Hello,

I've not found any documentation nor trick to proper start streaming a Dash video with timeshift at its live position.
Currently I observe stream duration then seek to that duration for this but it causes an unwanted audio video glitch.

Any help please?

Sample code:

sub init()
  videocontent = createObject("RoSGNode", "ContentNode")

  videocontent.live = true
  videocontent.title = "Live video with timeshift"
  videocontent.streamformat = "dash"
  videocontent.url = "https://host/live/channel_with_2h_timeshift.mpd"

  video = m.top.findNode("exampleVideo")
  video.ObserveField("duration", "onDuration")
  video.content = videocontent

  video.setFocus(true)
  video.control = "play"
end sub

sub onDuration(message as object)
  video = message.getRoSGNode()
  duration = video.duration
  if duration > 10 then
    video.UnobserveField("duration")
    video.seek = duration
  end if
end sub

 

0 Kudos
1 Solution

Accepted Solutions
RokuJonathanD
Community Moderator
Community Moderator

Re: Start live channel with timeshift at live position

Jump to solution

Hi @ojo1,

To start at the live edge, you can use the Video node's PlayStart field. In this case, you can do something like this: 

PlayStart(some large number) (for example, PlayStart(9999)

The media player will figure out that the live edge is wanted and will automatically set itself to 30 seconds behind it (this is the default setting for smooth buffering and no re-buffering events).

View solution in original post

0 Kudos
5 REPLIES 5
RokuJonathanD
Community Moderator
Community Moderator

Re: Start live channel with timeshift at live position

Jump to solution

Hi @ojo1,

To start at the live edge, you can use the Video node's PlayStart field. In this case, you can do something like this: 

PlayStart(some large number) (for example, PlayStart(9999)

The media player will figure out that the live edge is wanted and will automatically set itself to 30 seconds behind it (this is the default setting for smooth buffering and no re-buffering events).

0 Kudos
ojo1
Reel Rookie

Re: Start live channel with timeshift at live position

Jump to solution

Thanks you!

The documentation talks about negative value to allows "the media players to start playbacks distanced from the edge of the live stream". This is confusing...

Actually I found that solution after having accidentally put a bookmark position to a live stream!

Regards

0 Kudos
Moriarty
Reel Rookie

Re: Start live channel with timeshift at live position

Jump to solution

@ojo1  I did put the playerStart to a big number like said in the previous comment. But, still, the live playback is starting only from 20 seconds behind !!. Any idea what could cause that issue ??

0 Kudos
devnullpointer
Streaming Star

Re: Start live channel with timeshift at live position

Jump to solution

I use the  playStart field with the current time as seconds,

ex: 

currentTime = CreateObject("roDateTime")
videoPlayer.playStart = currentTime.AsSeconds()
 
This makes sure I'm playing the most current TS segment from the live stream. Now if you are still 20 seconds behind then it's not the stream, but the whole encoding, transcribing and network latency of the live broadcast. Try playing the stream with FFPlay (FFMpeg) and see if theres a difference between the Roku and the FFPlay. There should be a minimal 1-2 second delay which is normal.
0 Kudos
nthingvall
Reel Rookie

Re: Start live channel with timeshift at live position

Jump to solution

@RokuJonathanD You said 30 seconds is the default setting for live distance. Is there a way to change this setting? I'm looking through the docs but can't find anything for adjusting that. Even getting within 20 seconds of live edge would make a big difference for me. I'd like to get even closer, but I have a 30 second DVR window and Roku is barely staying within the window the manifest provides. PlayStart and seek have not worked at all because of this distance from live. Thanks!

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.