from onvif import ONVIFCamera camera = ONVIFCamera(<host>, <port>, <user>, <passwd>, adjust_time=True) camera.create_media_service() osd = camera.media.create_type('CreateOSD') osd.OSD = { 'token': 'token0', 'Position': { 'Type': 'UpperLeft', }, 'TextString': { 'PlainText': 'TEST', 'Type': 'Plain', }, 'Type': 'Text', 'VideoSourceConfigurationToken': 'token1', } response = camera.media.CreateOSD(osd) print(response)
This is my whole code.
When I call GetServiceCapabilities(), OSD returns True so I think my camera does support OSD.
How can I fix this error?
Advertisement
Answer
Solved this by adding VideoSourceConfigurationToken
.
Final code:
from onvif import ONVIFCamera camera = ONVIFCamera(<host>, <port>, <user>, <passwd>, adjust_time=True) camera.create_media_service() profiles = camera.media.GetProfiles() osd = camera.media.create_type('CreateOSD') osd.OSD = { 'token': 'token0', 'Position': { 'Type': 'UpperLeft', }, 'TextString': { 'PlainText': 'TEST', 'Type': 'Plain', }, 'Type': 'Text', 'VideoSourceConfigurationToken': profiles[0].VideoSourceConfiguration.token, } response = camera.media.CreateOSD(osd) print(response)