Thread Rating:
  • 0 Vote(s) - 0 Average
Timeshift buffer has no limit. Implement a ring buffer.
Hi Manül,
do you have any timeframe for implementing the ring buffer?
Any workaround for using the ramdisk as the timeshift device would be very appreciated :-)

Thanks in advance.
No. And it's very low on my priority list.
Keep in mind that a ring/circular buffer is not easy to implement for streams where bitrates can heavily vary.


In a ring buffer scenario, the write pointer must *never* catch up with the read pointer (from behind, of course), otherwise we are in big trouble. Unfortunately it is pretty difficult to estimate how much space is required for X minutes, since TV broadcasters might use pretty variable bitrates for video.

Let's play through a small scenario... We assume that writing to the ring buffer has been performed for 2 minutes with a pretty low bitrate and now wraps back to the beginning because the size of the ring buffer has been reached. Now the user decides to jump back 1 minute (for whatever reason, maybe he missed something..). Everything is perfectly fine. He keeps on watching from that position (somewhere around in the middle of the ring buffer). But then, a broadcast with a significantly higher bitrate (like a sports event for example) starts, so that writing suddenly becomes much faster than reading. At some point in time, the write pointer might catch up with the read pointer. Bad news...
Sony BRAVIA 2015 (FW V3.885 / Android TV 6.0.1) | DVBViewer Media Server 2.0
Thanks for your answers.
i agree that implementing a ring buffer is very complicated.
For me it would be absolute sufficient if the tv stream would not stop when the ramdisk is out of space.
Perhaps it would be a easy solution to delete the timeshift file when the disk is full and start with a new file.
I also just realized that the KODI timeshifting is a permanent one. I am using a 60GB partition on an SSD for timeshifting. But I use it with DVBViewer only now, because it only starts writing to disc after pressing "Pause". Hammering the SSD all the time without needing it mostly is not such a good idea...

I don't really like this permanent approach with rather small ring-buffer in RAM. An a small permanent one without a ring makes even less sense. I actually like it the way I am using it with DVBViewer.

When I want to timeshift within KODI I just add a timer via the Guide and play the recording when I get back. The recording can be read even though the file is still being written to. I will have to check whether there are any problems with seeking inside a file that is still being written to.
Sony BRAVIA 2015 (FW V3.885 / Android TV 6.0.1) | DVBViewer Media Server 2.0
Not hammering the SSD is the reason while i use a ram disk of 4 GB. i mostly use timeshift to pause the actual channel while i am e.g. have a phone call etc. And the good thing then is that i can skip forward if the commercials are on the screen.
At the moment i use the MediaPortal TV server. In my opinion the timeshift there is perfectly implemented. The ring buffer is implemented while having more than 1 file of a certain size. E.g. 6 files a 256 MB. And if the disk is full it deletes or overwrites the first written file. So you do not loose the complete history. There is always a guarantee that you have the last x minutes (depends on your configurable disk space) on the files.
I know the thread is 1,5 years old and I've asked it before (not knowing what a ring buffer was back then), but has any progress been made since?
This still bugs me and I really don't want to spend more on extra ram for my ramdisk and getting my htpc out of the tv cabinet for just a ram upgrade is really bothersome.
By now even more people only have SSD's (nucs etc) and probably the numbers of people experiencing this are increasing rapidly by now.
Not to mention we even have 4k streams on the cable now which in my case only gives a bit over 15min of buffer space.

Probably more PVR addons suffer from it, why not have it done by Kodi instead of the addon? would that be the better plan? what would it take for someone to pick this up and solve it?
Since I can't code I don't understand why it's hard to do but I'd learn to code just to do this plus a few other things maybe if I could just find me some spare time.
About two weeks ago I've implemented timeshift on pause, so there's no timeshift buffering until the first time you pause. This feature will be part of the PVR version shipped with Kodi L*.

There's still no ringbuffer support.
Well, at least it's something. It will still be useful for for the public channels over here where we have no commercials within the programmes.
However the commercial channels will still be a big pain... my use case consist of waiting 10-20 min of the start of some programmes so I can quickly skip the commercials.
And I do this a lot.
So I keep hoping to get this some time in the future
You don't need a ring buffer for that. You go to the channel when your event starts, press pause and come back 20 minutes later to start playback. You can then skip over commercials.
Sony BRAVIA 2015 (FW V3.885 / Android TV 6.0.1) | DVBViewer Media Server 2.0
Maybe I don't understand how it works then, either way we'll see when the L* builds get released soon enough.
How I understand it: my ramdisk is 6 out of 8GB of my ram and when it reaches that 6GB the file gets destroyed and the video stops playing.
This is what I want to have solved, and the only way right now is going with a hard disk while my htpc is 100% passive now.
I have no use for a buffer of more than 30min.
The perfect solution would be it deletes the oldest data while approaching that 6GB mark, and from how I understand this is what a ring buffer does.
What you propose doesn't work, at least not right now as I do that all the time.

Have already looked at several other backends but only dvbviewer does everything I want and runs on windows.
Ah OK. Understood. You really need a ring buffer which the DVBViewer Client add-on in L*** won't give you either. I already suggested to port over the RingBuffer class from the NextPVR add-on...
Sony BRAVIA 2015 (FW V3.885 / Android TV 6.0.1) | DVBViewer Media Server 2.0
The RingBuffer in NextPVR is used as a simple cache while reading from the backend and has nothing to do with timeshifting at all.

Handling overflows is another problem. There's no API call to resume playback.
Hey manül, timeshift is a function that many people like me use
It is time to spare my SSD, I would like to finally save my stream to the Ram drive

Could you please fix this for us.

Mediaportal uses a function to create several small TS files
When it reaches the maximum specified size, it deletes the last ts file

Is difficult to program?
The live stream has 1.6 mb a second

1.6 MB x 60 seconds = 96 MB x 60 minute = 5.76 GB
4 hours Live tv on the day = 23 GB per day

Definitely not healthy for the SSD

Timeshift buffer has no limit. Implement a ring buffer.00