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
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).
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!
@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 ??
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.
@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!
@RokuJonathanD Any thoughts on this? I’m coming back to this after a long hiatus and the latency is still an issue. I notice LL-HLS streams now can go below 10s latency. Any way to shorten the latency for standard HLS live streams?