File size and times for live TV

Want to write your own code to work with a HDHomeRun or work with the HDHomeRun DVR? We are happy to help with concepts, APIs, best practices.
Post Reply
MatthewLundberg
Posts: 43
Joined: Mon May 08, 2017 3:57 pm

File size and times for live TV

Post by MatthewLundberg » Sat Dec 08, 2018 11:05 am

When I pull a live channel from the DVR, there is a buffer. How can a client determine the size of the buffer (in bytes) as well as the timestamps for the beginning and end of the buffer? This is dynamic information, so it would need to be a query against the Record engine (I would think). Is there a way?

Similarly, for a file that is currently being recorded, this can be pulled before the recording is finished, but again I need to determine the current file size and time bounds (although here, the time bounds can be inferred from the recording information itself).

When I pull a file that is a complete recording, the HTTP headers return the file size and the recording information gives the times, but for live TV that obviously can't work, and no size information seems to be returned for an incomplete recording (or am I wrong about that?).

MatthewLundberg
Posts: 43
Joined: Mon May 08, 2017 3:57 pm

Re: File size and times for live TV

Post by MatthewLundberg » Mon Dec 10, 2018 6:19 pm

I'm looking for this information so I can pass it back to Kodi. It wants the stream times and the file size, so it can compute a seek position to satisfy user requests. There must be a way.

airdrummer
Posts: 71
Joined: Tue Jan 08, 2013 8:39 am

Re: File size and times for live TV

Post by airdrummer » Tue Jan 08, 2019 9:48 pm

https://github.com/Silicondust/document ... ki/Live-TV sez
Seeking:
Close the existing HTTP connection that is streaming video.
Issue a new HTTP request specifying the desired starting byte offset in the RANGE header. The ClientID and SessionID parameters of the URL must be the same as the original HTTP request.
so what's the RANGE header, and how do i get vlc to set it?


airdrummer
Posts: 71
Joined: Tue Jan 08, 2013 8:39 am

Re: File size and times for live TV

Post by airdrummer » Wed Jan 09, 2019 10:40 am

thx 4 the link...any insight into VLC's RANGE?

MatthewLundberg
Posts: 43
Joined: Mon May 08, 2017 3:57 pm

Re: File size and times for live TV

Post by MatthewLundberg » Thu Jan 10, 2019 8:39 pm

Ok, well, setting the Range header is beyond the scope of my question. Kodi does that for me, but it wants to compute the new position, and to do that, it needs to know the size of the file.

When I fetch a completed recording, the file size is sent back in the headers and I can pass that into Kodi, and it works just fine. Seeking is as expected. The problem is that for live TV and incomplete recordings, I'm not getting this data.

djp952
Posts: 862
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD

Re: File size and times for live TV

Post by djp952 » Sat Jan 12, 2019 9:09 pm

Hi Matt, I assume you're working on implementing Kodi's GetStreamTimes() function? Try this:

Live TV:
- Set the buffer start time to the time at which the user opened the stream
- Set the buffer end time to the system clock

Recorded TV:
- Set the buffer start time to the time reported via the Recording metadata
- Set the buffer end time to the lesser of the system clock or the end time reported via the Recording metadata

The theory for Live TV is that you have no way to know when/if the DVR engine has a back buffer for the channel, so the point at which the user opened the stream is as far back in time as you can reasonably go. Since the stream is "live", the current system clock indicates the point to which the user can seek forward.

The theory for Recorded TV is that you know the start time of the recording from the metadata. The end time becomes the lesser of the system time and the end time of the recording from the metadata. If it's still in progress the system time is the right answer. If the recording completed, the metadata end time is the right answer since it occurred in the past.

My commit of GetStreamTimes() adjusted for these particular theories may be of assistance: https://github.com/djp952/pvr.hdhomerun ... 8ffcdfb42f

Good luck! Hit me up on e-mail or PM if this doesn't solve your problem :)

airdrummer
Posts: 71
Joined: Tue Jan 08, 2013 8:39 am

Re: File size and times for live TV

Post by airdrummer » Tue Jan 15, 2019 2:49 pm

ur logic sounds good, djp...any way this can b applied in VLC?

djp952
Posts: 862
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD

Re: File size and times for live TV

Post by djp952 » Tue Jan 15, 2019 7:04 pm

airdrummer wrote:
Tue Jan 15, 2019 2:49 pm
ur logic sounds good, djp...any way this can b applied in VLC?
This would be a Kodi addon specific thing, I'm not that familiar with any support for things like addons in VLC. To be honest, I've only used VLC a handful of times with the HDHomeRun devices, and that was to mainly to play around with testing URL formatting and stuff like that. Sorry!

edit: the RANGE header you're looking to set is done at the time of the HTTP request, and is included in the request headers. How you would do that in VLC - no idea.

https://developer.mozilla.org/en-US/doc ... ders/Range

Post Reply