Kodi Community Forum

Full Version: Move the video cache on Android to prevent stuttering whlile playing the 4k HDR
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is there any way how to move the video cache location on Android? It's default location is in Kodi's temp directory when 
Code:
<memorysize>0</memorysize>
is set in advancedsettings.xml. I need to use the file based video cache, because there is not enough free RAM available for the cache on my Andtoid TV to handle the 4K HDR content. In the demanding scenes the bitrate exeeds 100 Mbit/s what is outside of the capabilities of my internet connection. In such situation, the small video cache in RAM is quiclky getting empty and the video becomes stuttering.

I do not want to let Kodi to make the video cache files in the Android TV internal storage to prevent it from destroing during the time by the huge amount of data being written into the cache.

I hoped to solve that by the path substituion of the temp directory as described here: https://kodi.wiki/view/Path_substitution. But it turned out to be not supported in case of the temp directory in particular, see here: https://github.com/xbmc/xbmc/issues/19393.

One possible solution working on Android is to move the Kodi's data directory elsewhere using the xbmc_env.properties file. But this is not my desired solution as I do not want to move the whole data directory, but only the temp. Or even better just the filecache files made by the video cache there.

I appreciate any help here.
this should do it: https://github.com/wsnipex/xbmc/commit/f...43416993c9

usage: $ cat xbmc_env.properties                                                                                                                         
xbmc.temp=/storage/emulated/0/tmp


test builds:
arm 32bit: https://mirrors.kodi.tv/test-builds/andr...bi-v7a.apk
arm 64bit: https://mirrors.kodi.tv/test-builds/andr...64-v8a.apk

Note that those are v20 builds, so take a backup of your userdata if you want to go back. If this works for you, I'll try to get it into v19.1
(2021-03-13, 19:05)wsnipex Wrote: [ -> ]this should do it: https://github.com/wsnipex/xbmc/commit/f...43416993c9

usage: $ cat xbmc_env.properties                                                                                                                         
xbmc.temp=/storage/emulated/0/tmp


test builds:
arm 32bit: https://mirrors.kodi.tv/test-builds/andr...bi-v7a.apk
arm 64bit: https://mirrors.kodi.tv/test-builds/andr...64-v8a.apk

Note that those are v20 builds, so take a backup of your userdata if you want to go back. If this works for you, I'll try to get it into v19.1
Wow, that sounds great. Thank you! I'll do the test and will keep you informed.

BTW: At least in my case it is not necessary to move the whole temp, moving just the filecache storage would be enough. I do not need to move the log and the other stuff in temp. But if this is not possible or desired, moving the whole temp will help too for sure.
The option for the whole temp dir brings android in line with the other platforms, where this is already possible for a long time. Just the file cache is too much of a niche use case and would require larger code changes, so would be unlikely to be accepted into v19.1
(2021-03-14, 22:48)wsnipex Wrote: [ -> ]The option for the whole temp dir brings android in line with the other platforms, where this is already possible for a long time. Just the file cache is too much of a niche use case and would require larger code changes, so would be unlikely to be accepted into v19.1

OK, I uderstand. That's also my idea that moving just the filecache would be not so easy as moving the whole temp.

So, here is my test result I did on tablet running Android 10:
I tested the 64bit apk you provided (if there is any need to test the 32bit as well, just let me know, I will do that). I did find out the following:
1. Redirecting temp to internal storage works.
2. Redirecting temp to NFS storage doesn't work. Kodi falls down to use of the default temp location and starts well. But I guess that's the Android, not Kodi who should be blamed here.
3. Redirecting temp to SMB share doesn't work. The result is the same as in the NFS case. I was hoping that SMB would work (unlike the NFS).
4. Redirecting temp to USB attached and FAT32 formatted flash storage doesn't work. Kodi crashes immediately after launching and doesn't create any log anywhere. Flash storage is writable from Android. If I change the xbmc_env.properties from redirecting the temp to redirecting the whole data, it does the same. When I tried redirecting the data to the USB attached flash earlier in Kodi 19 running on other device with Android TV 8.0, it worked.

Would be nice if redirecting to USB storage and if possible to SMB/NFS too would work. Otherwise it is a bit pointless, because the point here is to redirect the massive video cache writes from the internal storage.

I'm ready to do other testing when needed.
It's not possible to move the temp folder to network storage(and it would defeat the purpose of a network cache). Please provide a Debug Log for the USB case
There was no log, Kodi has crashed before the log has been made. But my bad. I forgot the Android rule that an app cannot write to the external memory other than into its own data directory. After making the Android/data/org.xbmc.kodi directory on the USB storage and redirecting the temp to there, it has started to work.

So redirecting the temp in xbmc_env.properties works as expected in the provided Kodi 20.0 alpha. Thank you!

Regarding the idea on redirecting the temp to the network storage, I'm not a fan of that for sure. But there is one problem in the current video cache implemtation that makes me to think this way too. Current video caching to storage (including in the 20.0 alpha version) does not take into account the 4GB file limit of the FAT32 filesystem. Unfortunately there is still a lot of Android devices (including my TV running on Android TV 8.0) which doesn't support any other fileformat of the external USB storage than FAT32. I did the test and let the filecache redirected to the external USB to grow up. After reaching the 4GB limit it has stopped and did not start to make other filecache file. Therefore I'm thinking of the network filecache storage, because this looks like the only one possible solution for me now. Although I have no idea if the 5GHz home WiFi would be capable enough to handle such traffic. If my assumtion is correct the video would need to be transferred as much as three times over the WiFi.
Just an info for anybody interested in this topic. To overcome the 4GB filesize limit of the FAT32 formated external USB storage I had to change it to Adoptable/Internal storage on the Android storage settings. After moving Kodi there, its whole data directory (includiong the temp) is now stored on the adopted storage and the filecache can grow over the 4GB filesize limit.
(2021-03-13, 19:05)wsnipex Wrote: [ -> ]this should do it: https://github.com/wsnipex/xbmc/commit/f...43416993c9

usage: $ cat xbmc_env.properties                                                                                                                         
xbmc.temp=/storage/emulated/0/tmp


test builds:
arm 32bit: https://mirrors.kodi.tv/test-builds/andr...bi-v7a.apk
arm 64bit: https://mirrors.kodi.tv/test-builds/andr...64-v8a.apk

Note that those are v20 builds, so take a backup of your userdata if you want to go back. If this works for you, I'll try to get it into v19.1

Hi, I'm going to download this test build tomorrow and give it a go. If I wanted the temp dir on a USB stick on my nvidia shield how would I change its location using the test build? Thanks
(2021-03-15, 22:10)sunarowicz Wrote: [ -> ]There was no log, Kodi has crashed before the log has been made. But my bad. I forgot the Android rule that an app cannot write to the external memory other than into its own data directory. After making the Android/data/org.xbmc.kodi directory on the USB storage and redirecting the temp to there, it has started to work.

So redirecting the temp in xbmc_env.properties works as expected in the provided Kodi 20.0 alpha. Thank you!

Regarding the idea on redirecting the temp to the network storage, I'm not a fan of that for sure. But there is one problem in the current video cache implemtation that makes me to think this way too. Current video caching to storage (including in the 20.0 alpha version) does not take into account the 4GB file limit of the FAT32 filesystem. Unfortunately there is still a lot of Android devices (including my TV running on Android TV 8.0) which doesn't support any other fileformat of the external USB storage than FAT32. I did the test and let the filecache redirected to the external USB to grow up. After reaching the 4GB limit it has stopped and did not start to make other filecache file. Therefore I'm thinking of the network filecache storage, because this looks like the only one possible solution for me now. Although I have no idea if the 5GHz home WiFi would be capable enough to handle such traffic. If my assumtion is correct the video would need to be transferred as much as three times over the WiFi.

Hi, is it possible I can see your advanced settings xml file so I can figure out where I'm going wrong please? Thank you
(2021-04-03, 03:08)Markreed89 Wrote: [ -> ]
(2021-03-13, 19:05)wsnipex Wrote: [ -> ]this should do it: https://github.com/wsnipex/xbmc/commit/f...43416993c9

usage: $ cat xbmc_env.properties                                                                                                                         
xbmc.temp=/storage/emulated/0/tmp


test builds:
arm 32bit: https://mirrors.kodi.tv/test-builds/andr...bi-v7a.apk
arm 64bit: https://mirrors.kodi.tv/test-builds/andr...64-v8a.apk

Note that those are v20 builds, so take a backup of your userdata if you want to go back. If this works for you, I'll try to get it into v19.1

Hi, I'm going to download this test build tomorrow and give it a go. If I wanted the temp dir on a USB stick on my nvidia shield how would I change its location using the test build? Thanks
Exactly as wsnipex wrote. You has to put the file xbmc_env.properties that includes the line (change the path according to your need)
Code:
xbmc.temp=/storage/emulated/0/tmp
into the root direcrory of your internal SD card, see here: https://kodi.wiki/view/HOW-TO:Change_dat...or_Android.
(2021-04-03, 18:02)Markreed89 Wrote: [ -> ]
(2021-03-15, 22:10)sunarowicz Wrote: [ -> ]There was no log, Kodi has crashed before the log has been made. But my bad. I forgot the Android rule that an app cannot write to the external memory other than into its own data directory. After making the Android/data/org.xbmc.kodi directory on the USB storage and redirecting the temp to there, it has started to work.

So redirecting the temp in xbmc_env.properties works as expected in the provided Kodi 20.0 alpha. Thank you!

Regarding the idea on redirecting the temp to the network storage, I'm not a fan of that for sure. But there is one problem in the current video cache implemtation that makes me to think this way too. Current video caching to storage (including in the 20.0 alpha version) does not take into account the 4GB file limit of the FAT32 filesystem. Unfortunately there is still a lot of Android devices (including my TV running on Android TV 8.0) which doesn't support any other fileformat of the external USB storage than FAT32. I did the test and let the filecache redirected to the external USB to grow up. After reaching the 4GB limit it has stopped and did not start to make other filecache file. Therefore I'm thinking of the network filecache storage, because this looks like the only one possible solution for me now. Although I have no idea if the 5GHz home WiFi would be capable enough to handle such traffic. If my assumtion is correct the video would need to be transferred as much as three times over the WiFi.

Hi, is it possible I can see your advanced settings xml file so I can figure out where I'm going wrong please? Thank you
Sure:
Code:
<advancedsettings>
    <cache>
        <memorysize>0</memorysize>
        <buffermode>1</buffermode>
        <readfactor>4</readfactor>
    </cache>
</advancedsettings>
(2021-04-04, 23:50)sunarowicz Wrote: [ -> ]
(2021-04-03, 18:02)Markreed89 Wrote: [ -> ]
(2021-03-15, 22:10)sunarowicz Wrote: [ -> ]There was no log, Kodi has crashed before the log has been made. But my bad. I forgot the Android rule that an app cannot write to the external memory other than into its own data directory. After making the Android/data/org.xbmc.kodi directory on the USB storage and redirecting the temp to there, it has started to work.

So redirecting the temp in xbmc_env.properties works as expected in the provided Kodi 20.0 alpha. Thank you!

Regarding the idea on redirecting the temp to the network storage, I'm not a fan of that for sure. But there is one problem in the current video cache implemtation that makes me to think this way too. Current video caching to storage (including in the 20.0 alpha version) does not take into account the 4GB file limit of the FAT32 filesystem. Unfortunately there is still a lot of Android devices (including my TV running on Android TV 8.0) which doesn't support any other fileformat of the external USB storage than FAT32. I did the test and let the filecache redirected to the external USB to grow up. After reaching the 4GB limit it has stopped and did not start to make other filecache file. Therefore I'm thinking of the network filecache storage, because this looks like the only one possible solution for me now. Although I have no idea if the 5GHz home WiFi would be capable enough to handle such traffic. If my assumtion is correct the video would need to be transferred as much as three times over the WiFi.

Hi, is it possible I can see your advanced settings xml file so I can figure out where I'm going wrong please? Thank you
Sure:
Code:
<advancedsettings>
    <cache>
        <memorysize>0</memorysize>
        <buffermode>1</buffermode>
        <readfactor>4</readfactor>
    </cache>
</advancedsettings>
Thanks. So are you not using advanced settings to redirect the temp directory?
(2021-04-05, 00:11)Markreed89 Wrote: [ -> ]
(2021-04-04, 23:50)sunarowicz Wrote: [ -> ]
(2021-04-03, 18:02)Markreed89 Wrote: [ -> ]Hi, is it possible I can see your advanced settings xml file so I can figure out where I'm going wrong please? Thank you
Sure:
Code:
<advancedsettings>
    <cache>
        <memorysize>0</memorysize>
        <buffermode>1</buffermode>
        <readfactor>4</readfactor>
    </cache>
</advancedsettings>
Thanks. So are you not using advanced settings to redirect the temp directory?
Ah, just read the other post
(2021-04-04, 23:46)sunarowicz Wrote: [ -> ]
(2021-04-03, 03:08)Markreed89 Wrote: [ -> ]
(2021-03-13, 19:05)wsnipex Wrote: [ -> ]this should do it: https://github.com/wsnipex/xbmc/commit/f...43416993c9

usage: $ cat xbmc_env.properties                                                                                                                         
xbmc.temp=/storage/emulated/0/tmp


test builds:
arm 32bit: https://mirrors.kodi.tv/test-builds/andr...bi-v7a.apk
arm 64bit: https://mirrors.kodi.tv/test-builds/andr...64-v8a.apk

Note that those are v20 builds, so take a backup of your userdata if you want to go back. If this works for you, I'll try to get it into v19.1

Hi, I'm going to download this test build tomorrow and give it a go. If I wanted the temp dir on a USB stick on my nvidia shield how would I change its location using the test build? Thanks
Exactly as wsnipex wrote. You has to put the file xbmc_env.properties that includes the line (change the path according to your need)
Code:
xbmc.temp=/storage/emulated/0/tmp
into the root direcrory of your internal SD card, see here: https://kodi.wiki/view/HOW-TO:Change_dat...or_Android.

I'm assuming my device needs to be rooted to put the file there? Unfortunately I don't think it's possible to root a shield pro 2019 yet
Pages: 1 2