pi@gc16:~ $ python
Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from onvif import ONVIFCamera
>>> mycam = ONVIFCamera('172.24.1.65', 8080, 'admin', 'admin')
>>> media = mycam.create_media_service()
>>> ec = media.GetCompatibleVideoEncoderConfigurations()
>>> ec
[(VideoEncoderConfiguration){
_token = "main_video_encoder_cfg_token"
Name = "main_video_encoder_cfg"
UseCount = 1
Encoding = "H264"
Resolution =
(VideoResolution){
Width = 1280
Height = 720
}
Quality = 6.0
RateControl =
(VideoRateControl){
FrameRateLimit = 30
EncodingInterval = 60
BitrateLimit = 6144
}
H264 =
(H264Configuration){
GovLength = 50
H264Profile = "Baseline"
}
Multicast =
(MulticastConfiguration){
Address =
(IPAddress){
Type = "IPv4"
IPv4Address = "0.0.0.0"
IPv6Address = ""
}
Port = 0
TTL = 3
AutoStart = False
}
SessionTimeout = "PT0H0M0.010S"
}, (VideoEncoderConfiguration){
_token = "sub_video_encoder_cfg_token"
Name = "sub_video_encoder_cfg"
UseCount = 1
Encoding = "H264"
Resolution =
(VideoResolution){
Width = 320
Height = 176
}
Quality = 6.0
RateControl =
(VideoRateControl){
FrameRateLimit = 30
EncodingInterval = 150
BitrateLimit = 32
}
H264 =
(H264Configuration){
GovLength = 50
H264Profile = "Baseline"
}
Multicast =
(MulticastConfiguration){
Address =
(IPAddress){
Type = "IPv4"
IPv4Address = "0.0.0.0"
IPv6Address = ""
}
Port = 0
TTL = 3
AutoStart = False
}
SessionTimeout = "PT0H0M0.010S"
}]
>>> params = media.create_type('SetVideoEncoderConfiguration')
>>> params
(SetVideoEncoderConfiguration){
Configuration =
(VideoEncoderConfiguration){
Name = None
UseCount = None
_token = ""
Encoding =
(VideoEncoding){
value = None
}
Resolution =
(VideoResolution){
Width = None
Height = None
}
Quality = None
RateControl =
(VideoRateControl){
FrameRateLimit = None
EncodingInterval = None
BitrateLimit = None
}
MPEG4 =
(Mpeg4Configuration){
GovLength = None
Mpeg4Profile =
(Mpeg4Profile){
value = None
}
}
H264 =
(H264Configuration){
GovLength = None
H264Profile =
(H264Profile){
value = None
}
}
Multicast =
(MulticastConfiguration){
Address =
(IPAddress){
Type =
(IPType){
value = None
}
IPv4Address = None
IPv6Address = None
}
Port = None
TTL = None
AutoStart = None
}
SessionTimeout = None
}
ForcePersistence = None
}
>>> params.Configuration = ec[0]
>>> params.Configuration.RateControl.EncodingInterval=150
>>> media.SetVideoEncoderConfiguration(params)
>>> media.GetCompatibleVideoEncoderConfigurations()
[(VideoEncoderConfiguration){
_token = "main_video_encoder_cfg_token"
Name = "main_video_encoder_cfg"
UseCount = 1
Encoding = "H264"
Resolution =
(VideoResolution){
Width = 1280
Height = 720
}
Quality = 6.0
RateControl =
(VideoRateControl){
FrameRateLimit = 30
EncodingInterval = 150
BitrateLimit = 6144
}
H264 =
(H264Configuration){
GovLength = 50
H264Profile = "Baseline"
}
Multicast =
(MulticastConfiguration){
Address =
(IPAddress){
Type = "IPv4"
IPv4Address = "0.0.0.0"
IPv6Address = ""
}
Port = 0
TTL = 3
AutoStart = False
}
SessionTimeout = "PT0H0M0.010S"
}, (VideoEncoderConfiguration){
_token = "sub_video_encoder_cfg_token"
Name = "sub_video_encoder_cfg"
UseCount = 1
Encoding = "H264"
Resolution =
(VideoResolution){
Width = 320
Height = 176
}
Quality = 6.0
RateControl =
(VideoRateControl){
FrameRateLimit = 30
EncodingInterval = 150
BitrateLimit = 32
}
H264 =
(H264Configuration){
GovLength = 50
H264Profile = "Baseline"
}
Multicast =
(MulticastConfiguration){
Address =
(IPAddress){
Type = "IPv4"
IPv4Address = "0.0.0.0"
IPv6Address = ""
}
Port = 0
TTL = 3
AutoStart = False
}
SessionTimeout = "PT0H0M0.010S"
}]
>>>
pi@gc16:~ $ python
Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytz
>>> from datetime import datetime
>>> from onvif import ONVIFCamera
>>> mycam = ONVIFCamera('172.24.1.65', 8080, 'admin', 'admin')
>>> media = mycam.create_media_service()
>>> time_params = mycam.devicemgmt.create_type('SetSystemDateAndTime')
>>> now = datetime.now(pytz.timezone('Asia/Tokyo'))
>>> time_params.DateTimeType = 'Manual'
>>> time_params.DaylightSavings = True
>>> time_params.TimeZone.TZ = pytz.timezone('Asia/Tokyo')
>>> now = datetime.now(pytz.timezone('Asia/Tokyo'))
>>> time_params.UTCDateTime.Date.Year = now.year
>>> time_params.UTCDateTime.Date.Month = now.month
>>> time_params.UTCDateTime.Date.Day = now.day
>>> time_params.UTCDateTime.Time.Hour = now.hour
>>> time_params.UTCDateTime.Time.Minute = now.minute
>>> time_params.UTCDateTime.Time.Second = now.second
>>> mycam.devicemgmt.SetSystemDateAndTime(time_params)
>>> mycam.devicemgmt.GetSystemDateAndTime()
(SystemDateTime){
DateTimeType = "Manual"
DaylightSavings = True
TimeZone =
(TimeZone){
TZ = "Asia/Tokyo"
}
UTCDateTime =
(DateTime){
Time =
(Time){
Hour = 9
Minute = 37
Second = 19
}
Date =
(Date){
Year = 2017
Month = 9
Day = 26
}
}
}
>>>