API to set audio/video delay to discrete values?
#1
Hey,

I am searching for a way to configure the audio/video "delay" as you can configure it statically in advancedsettings.xml:
https://kodi.wiki/view/Advancedsettings.xml

Is there a chance to configure this delay at runtime using the RPC API (or any other remote API)? I could not find anything. I would like to change the delay when activating bluetooth headphones which introduce an audio delay.

The only thing I could find are the actions "audiodelayminus" and "audiodelayplus" but as they only add or substract to currently active delay and do not allow to set a discrete value this way does not really cut it.

Thank you.
Reply
#2
(2022-01-30, 01:32)devkid Wrote: Hey,

I am searching for a way to configure the audio/video "delay" as you can configure it statically in advancedsettings.xml:
https://kodi.wiki/view/Advancedsettings.xml

Is there a chance to configure this delay at runtime using the RPC API (or any other remote API)? I could not find anything. I would like to change the delay when activating bluetooth headphones which introduce an audio delay.

The only thing I could find are the actions "audiodelayminus" and "audiodelayplus" but as they only add or substract to currently active delay and do not allow to set a discrete value this way does not really cut it.

Thank you.


I think you can use the approach I outlined in a thread earlier today, using a JSON RPC call.  Then look at the settings.xml file, specifically beginning at line 36.

        <setting id="videoplayer.seekdelay" type="integer" label="13557" help="37043">
          <level>1</level>
          <default>750</default>
          <constraints>
            <minimum label="231">0</minimum> <!-- None -->
            <step>250</step>
            <maximum>3000</maximum>


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#3
Ok, thank you. I will take a look. But I am not sure if this method will be working as the delay value is not in regular settings but in advanced settings.
Reply
#4
As adressed multiple times now, 

The setting is not "placed" in advanced settings. You are able to modify the core setting from this section. That doesn't mean the value is set at this section. Modifying the advancedsettings.xml from the JSON RPC is not supported and won't make any sense as that won't have a "runtime-effect".

As said earlier (in other threads) as well, Kodi also reads that value from the "guisettings.xml" file during startup. Modifying that file is also not supported and won't change anything during Kodi runtime as that file is only read at the time Kodi starts. 

As you have pointed out yourself, the only thing which can be done via JSON is "audiodelayplus" and/or "audiodelayminus". If that won't match your need, we can't do anything for you unless someone creates a PR which gives the option to set a specific value for the audiodelay.
Reply
#5
Ok, thank you for clarification.

For other readers:
There is an addon which can modify the audio delay at runtime by automating the UI controls:
https://forum.kodi.tv/showthread.php?tid=366574

I am about to modify that addon so it will accept a custom delay value via JSON RPC so it can be remote controlled.
Reply
#6
(2022-02-04, 08:08)DaVu Wrote:  If that won't match your need, we can't do anything for you unless someone creates a PR which gives the option to set a specific value for the audiodelay.

Seemingly it is very simple.
For example the value of port that is also in the guisettings.xml file.
With this script it is possible to change the port at runtime:
import json
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.SetSettingValue", "params":{"setting":"network.httpproxyport","value":8080},"id":1}')


According to this all you need (for the next version of Kodi) is just add the setting of the delay in settings with "setting id" just like the setting of port (network.httpproxyport)
Reply
#7
I am not an expert but I think there are two problems:
* The delay value is an advanced setting and not a regular setting so the "Settings.SetSettingValue" call won't work
* Even if you manage to change it: the delay value from the advanced settings is only read when the player is started/created so you would also make sure to update the value in the current player if you manage to change the advanced setting value at runtime
Reply
#8
I meant that in the next version of kodi, the developers will add the option to change the delay in the main settings with id, so that it can also be changed via an API just like the UI controls.
Reply
#9
All those explanations have already be made at the German Kodinerds Forum where he also asked.

And yes, I know if that value would have a setting ID, it could easily be changed. But as that's not the case currently, we can't do much at this point.

Creating scripts which would change that value wouldn't be allowed at our repos. Changing this value at its current state and implementation wouldn't help him as well as the guisettings are only read at Kodi startup and only saved if Kodi exits properly. Take a look at yourself. Change the volume and have a look at the guisettings while Kodi is still running. Nothing is changed until you close Kodi.

So...only giving this setting an ID won't change its behaviour during runtime. There's a bit more which needs to be done.

JSON provides the option audiodelayplus or audiodelayminus

Currently you can't set a specific value and all suggested workarounds won't change the delay during run-time.
Reply
#10
(2022-02-07, 23:29)DaVu Wrote: Changing this value at its current state and implementation wouldn't help him as well as the guisettings are only read at Kodi startup and only saved if Kodi exits properly. Take a look at yourself. Change the volume and have a look at the guisettings while Kodi is still running. Nothing is changed until you close Kodi.
Choosing "Set as default for all media" in the osdaudiosettings also makes Kodi flush the settings to disk updating the guisettins.xml. The addon is doing that.
Reply
#11
correct. And the same thing about the example I gave with port, if you change the value in the settings - it changes in guisettings while kodi is running.
So I did not understand what the problem is, just add id in the next version of kodi? How is it different from port?
Reply
#12
Delay is not a simple scalar value as it is configurable by frame rate. Not sure how stuff like that could be translated into a regular settings:
Code:
<refresh>
  <min>, <max> refresh rate range, OR
  <rate> exact refresh rate
  <delay> display latency for the given refresh rate
</refresh>

Changing it would also mean breaking backward compatibility to all existing installations currently using the delay configuration.

And as said, you would still need to adapt Kodi to obey the new delay values updated at runtime.
Reply
#13
(2022-02-08, 10:15)devkid Wrote: Delay is not a simple scalar value as it is configurable by frame rate. Not sure how stuff like that could be translated into a regular settings
I meant that value <audiodelay>0.000000</audiodelay> in guisettings.
But anyway I was wrong because with JSON the guisettings file does not change during run-time but only through the UI controls.
Reply
#14
(2022-02-08, 00:22)vip. Wrote: So I did not understand what the problem is, just add id in the next version of kodi? How is it different from port?

PR welcome
Reply
#15
With PR https://github.com/xbmc/xbmc/pull/22109
has been added the JSON RPC setting support for audio offset
that will be available on next Kodi v21 (nightlies)
Dev-Maintainer of InputStream Adaptive add-on, Netflix add-on ▫ Skills Python, C#, VB.NET and a bit of C++
Reply

Logout Mark Read Team Forum Stats Members Help
API to set audio/video delay to discrete values?0