Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script for Hikvision cameras with SD card #11

Closed
mrmaximas opened this issue Sep 17, 2021 · 55 comments
Closed

Script for Hikvision cameras with SD card #11

mrmaximas opened this issue Sep 17, 2021 · 55 comments

Comments

@mrmaximas
Copy link

mrmaximas commented Sep 17, 2021

It is possible to modify this script for use with cameras, not DVRs?
trying to load from DS-2CD2143G0-I
Traceback (most recent call last):
File "/Users/max/Downloads/HikLoad-master/downloadTodayRecordings.py", line 22, in
for channel in channelList['StreamingChannelList']['StreamingChannel']:
KeyError: 'StreamingChannelList'

@Tedyst
Copy link
Owner

Tedyst commented Sep 18, 2021

Since I do not have a hikvision camera, can you please add the line print(channelList) above line 22 and send me the output (after you remove any private information like username and passwords) to see where exactly is the channel stored? Thanks.

@mrmaximas
Copy link
Author

python3 downloadTodayRecordings.py
{'html': OrderedDict([('head', OrderedDict([('title', 'Document Error: Not Found'), ('@attrs', {})])), ('body', OrderedDict([('h2', 'Access Error: 404 -- Not Found'), ('p', "Can't locate document: /ISAPIStreaming/channels"), ('@attrs', {})])), ('@attrs', {})])}
Traceback (most recent call last):
File "/Users/max/Downloads/HikLoad-master/downloadTodayRecordings.py", line 22, in
for channel in channelList['StreamingChannelList']['StreamingChannel']:
KeyError: 'StreamingChannelList'

@Tedyst
Copy link
Owner

Tedyst commented Sep 19, 2021

I may have found the cause of this error, can you verify if 51ebdd8 fixed this issue? Also, in master I specified how to enable DEBUG mode by uncommenting this line

# logging.getLogger().setLevel(logging.DEBUG)

If there are any more issues, this one should help a lot for debugging.

@mrmaximas
Copy link
Author

max@MacBook-Pro HikLoad-master % python3 downloadTodayRecordings.py
INFO:root:Started downloading 20210919012739.mkv
INFO:root:Starting download from: rtsp://log:[email protected]/ISAPI/Streaming/tracks/101/?starttime=20210919T012739Z&endtime=20210919T012757Z&name=ch01_00000000018000701&size=14035240
Traceback (most recent call last):
File "/Users/max/Downloads/HikLoad-master/downloadTodayRecordings.py", line 53, in
hikvisionapi.downloadRTSP(url,
File "/Users/max/Downloads/HikLoad-master/hikvisionapi/RTSPutils.py", line 19, in downloadRTSP
stream = ffmpeg.output(ffmpeg.input(url),
AttributeError: module 'ffmpeg' has no attribute 'output'

@Tedyst
Copy link
Owner

Tedyst commented Sep 19, 2021

This is definitely related to kkroening/ffmpeg-python#174 (comment), I will add in README how to install dependencies using virtualenv so this shouldn't happen again.

@mrmaximas
Copy link
Author

uninstall both with:
pip uninstall ffmpeg
pip uninstall ffmpeg-python
and install ffmpeg-python again with :
pip install ffmpeg-python

it's works!!!

@mrmaximas
Copy link
Author

some issues

  1. the files are named with gmt time instead of my local time (gmt+3) 20210919001307.mkv really captured in 03:13:07
  2. python3 downloadTodayRecordings.py
    INFO:root:Started downloading 20210919001307.mkv
    INFO:root:Starting download from: tsp://log:[email protected]/ISAPI/Streaming/tracks/101/?starttime=20210919T001307Z&endtime=20210919T001322Z&name=ch01_00000000149000601&size=11352420
    at this stage the file 20210919001307.mkv appears with zero size, ffmpeg process and that's where it ends.
    my camera records in H.265 (not H.256+)

@mrmaximas
Copy link
Author

mrmaximas commented Sep 19, 2021

my cameras are installed at a remote site with 30-40ms latenсy lte channel with 5 mbps upstream speed, but camera records with 8 mbps vbr. may be this is a problem?

@Tedyst
Copy link
Owner

Tedyst commented Sep 19, 2021

  1. The name can be changed here:
    name = re.sub(r'[-T\:Z]', '', recording['timeSpan']['startTime'])

    2&3: In c22cacc I forced the downloading to be done via TCP, this should fix both of the problems. I guess sometimes HikVision cameras and DVRs do not like UDP and thus, if a packet is lost, it can take down ffmpeg and make it unresponsive. Can you verify if it works as intended now?

@mrmaximas
Copy link
Author

mrmaximas commented Sep 19, 2021

it's works! thanks!
video stream is ok, but time zone error repeats again. file 20210919014959.mkv captured in 04:49:59 GMT+3

@mrmaximas
Copy link
Author

it's possible to generate .mp4 or .mov video container instead of .mkv?

@Tedyst
Copy link
Owner

Tedyst commented Sep 19, 2021

For the timezone problem, I usually get what the camera says, so maybe check if the camera is set in UTC time or not. If it is set in your local time and returns UTC time, then you should be able to change the string to reflect your real timezone. And for the .mp4 you can change it on the line next to the one where you set the filename:

name = re.sub(r'[-T\:Z]', '', recording['timeSpan']['startTime'])
name = name + ".mkv"

@mrmaximas
Copy link
Author

i try to change file to .mov or .mp4 QT player says 'The file isn’t compatible with QuickTime Player.
it's problem with a movie container

@mrmaximas
Copy link
Author

the first downloaded file is always not earlier than 03:00 am
Screen Shot 2021-09-19 at 14 17 51

@Tedyst
Copy link
Owner

Tedyst commented Sep 19, 2021

I think I fixed both of the problems, the first one was because I was just copying the video from the camera without transcoding, the second one was because I kinda forgot how timezones work.

@mrmaximas
Copy link
Author

python3 downloadTodayRecordings.py
INFO:root:Could not find any videos for camera 101

@Tedyst
Copy link
Owner

Tedyst commented Sep 19, 2021

To be honest, if fc19ee7 dosen't fix this issue I might revert the whole timezone part and keep all of the times in UTC.

@mrmaximas
Copy link
Author

ok. what about .mp4 container instead of .mkv? it's ffmpeg call option as i know it.

@mrmaximas
Copy link
Author

mrmaximas commented Sep 19, 2021

To be honest, if fc19ee7 dosen't fix this issue I might revert the whole timezone part and keep all of the times in UTC.

maybe you can modify the script to accept timespan interval parameters and generate folder with camera name for example?

@Tedyst
Copy link
Owner

Tedyst commented Sep 20, 2021

I think I made almost everything that you asked, you can now run the script using arguments. To replicate the behaviour that you wanted run python download.py 192.168.10.239 username password --starttime 2021-09-19T07:58:52+03:00 --endtime 2021-09-20T04:58:52+00:00 --folders --videoformat=mp4. The only think that I don't know how to implement is how to specify custom filenames.

@mrmaximas
Copy link
Author

mrmaximas commented Sep 20, 2021

max@MacBook-Pro HikLoad-master % python3 download.py 111.111.111.2 admin password  --debug
DEBUG:root:Downloads already exists
DEBUG:root:{'StreamingChannelList': OrderedDict([('StreamingChannel', [OrderedDict([('id', '101'), ('channelName', 'CAM 2'), ('enabled', 'true'), ('Transport', OrderedDict([('maxPacketSize', '1000'), ('ControlProtocolList', OrderedDict([('ControlProtocol', [OrderedDict([('streamingTransport', 'RTSP'), ('@attrs', {})]), OrderedDict([('streamingTransport', 'HTTP'), ('@attrs', {})]), OrderedDict([('streamingTransport', 'SHTTP'), ('@attrs', {})])]), ('@attrs', {})])), ('Unicast', OrderedDict([('enabled', 'true'), ('rtpTransportType', 'RTP/TCP'), ('@attrs', {})])), ('Multicast', OrderedDict([('enabled', 'true'), ('destIPAddress', '0.0.0.0'), ('videoDestPortNo', '8860'), ('audioDestPortNo', '8862'), ('FecInfo', OrderedDict([('fecRatio', '0'), ('fecDestPortNo', '8960'), ('@attrs', {})])), ('@attrs', {})])), ('Security', OrderedDict([('enabled', 'true'), ('certificateType', 'digest'), ('@attrs', {})])), ('@attrs', {})])), ('Video', OrderedDict([('enabled', 'true'), ('videoInputChannelID', '1'), ('videoCodecType', 'H.265'), ('videoScanType', 'progressive'), ('videoResolutionWidth', '2688'), ('videoResolutionHeight', '1520'), ('videoQualityControlType', 'VBR'), ('constantBitRate', '6144'), ('fixedQuality', '100'), ('vbrUpperCap', '6144'), ('vbrLowerCap', '32'), ('maxFrameRate', '1500'), ('keyFrameInterval', '4000'), ('snapShotImageType', 'JPEG'), ('GovLength', '60'), ('SVC', OrderedDict([('enabled', 'false'), ('@attrs', {})])), ('PacketType', ['PS', 'RTP']), ('smoothing', '1'), ('H265Profile', 'Main'), ('SmartCodec', OrderedDict([('enabled', 'false'), ('@attrs', {})])), ('@attrs', {})])), ('@attrs', {'version': '2.0'})]), OrderedDict([('id', '102'), ('channelName', 'CAM 2'), ('enabled', 'true'), ('Transport', OrderedDict([('maxPacketSize', '1000'), ('ControlProtocolList', OrderedDict([('ControlProtocol', [OrderedDict([('streamingTransport', 'RTSP'), ('@attrs', {})]), OrderedDict([('streamingTransport', 'HTTP'), ('@attrs', {})]), OrderedDict([('streamingTransport', 'SHTTP'), ('@attrs', {})])]), ('@attrs', {})])), ('Unicast', OrderedDict([('enabled', 'true'), ('rtpTransportType', 'RTP/TCP'), ('@attrs', {})])), ('Multicast', OrderedDict([('enabled', 'true'), ('destIPAddress', '0.0.0.0'), ('videoDestPortNo', '8866'), ('audioDestPortNo', '8868'), ('FecInfo', OrderedDict([('fecRatio', '0'), ('fecDestPortNo', '8966'), ('@attrs', {})])), ('@attrs', {})])), ('Security', OrderedDict([('enabled', 'true'), ('certificateType', 'digest'), ('@attrs', {})])), ('@attrs', {})])), ('Video', OrderedDict([('enabled', 'true'), ('videoInputChannelID', '1'), ('videoCodecType', 'H.264'), ('videoScanType', 'progressive'), ('videoResolutionWidth', '640'), ('videoResolutionHeight', '360'), ('videoQualityControlType', 'VBR'), ('constantBitRate', '256'), ('fixedQuality', '100'), ('vbrUpperCap', '256'), ('vbrLowerCap', '32'), ('maxFrameRate', '1000'), ('keyFrameInterval', '4000'), ('snapShotImageType', 'JPEG'), ('H264Profile', 'High'), ('GovLength', '40'), ('SVC', OrderedDict([('enabled', 'false'), ('@attrs', {})])), ('PacketType', ['PS', 'RTP']), ('smoothing', '1'), ('H265Profile', 'Main'), ('@attrs', {})])), ('@attrs', {'version': '2.0'})])]), ('@attrs', {'version': '2.0'})])}
DEBUG:root:101 already exists
DEBUG:root:Using 2021-09-20 00:00:00 and 2021-09-20 23:59:59 as start and end times
DEBUG:root:Data sent: <?xml version = "1.0" encoding = "UTF-8" ?><CMSearchDescription version="1.0" xmlns="http://www.hikvision.com/ver20/XMLSchema"><searchID>{xxx-4089-11A3-9A0C-0305E82C2906}</searchID><trackIDList><trackID>101</trackID></trackIDList><timeSpanList><timeSpan><startTime>2021-09-20T00:00:00</startTime><endTime>2021-09-20T23:59:59</endTime></timeSpan></timeSpanList><contentTypeList><contentType>video</contentType></contentTypeList><maxResults>100</maxResults></CMSearchDescription>
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 111.111.111.2:80
DEBUG:urllib3.connectionpool:http://111.111.111.2:80 "GET /ISAPI/ContentMgmt/search HTTP/1.1" 401 178
DEBUG:urllib3.connectionpool:http://111.111.111.2:80 "GET /ISAPI/ContentMgmt/search HTTP/1.1" 200 354
INFO:root:Could not find any videos for camera 101
max@MacBook-Pro HikLoad-master %

=====
something went wrong.
p.s. i thing 'channelName' argument is the best for directory naming (channelName', 'CAM 2' in my case)

@Tedyst
Copy link
Owner

Tedyst commented Sep 20, 2021

I guess you can specify the --starttime and --endtime arguments to see if making the interval bigger would work? The problem is that the camera cannot find anything, since the dates are kinda correct from what I see. Also I now changed to use the channelName instead of the channelID for folder names.

@mrmaximas
Copy link
Author

i have some records today, but nothing to loads with or withiout timespan args
Screen Shot 2021-09-20 at 11 07 46

@Tedyst
Copy link
Owner

Tedyst commented Sep 20, 2021

If you add the option --skipdownload does it show that you have some recordings or just says Found 0 recordings for channel 101? I reverted the timezone things that I did these days and went back to the wrong (in the sense of timezones) way that should work.

@mrmaximas
Copy link
Author

answer is: Found 0 recordings for channel CAM 2
instead of Found 0 recordings for channel 101

@mrmaximas
Copy link
Author

mrmaximas commented Sep 20, 2021

INFO:root:Found channels ['101']
DEBUG:root:Folder CAM 2 already exists
DEBUG:root:Using 2021-09-20T00:00:00Z and 2021-09-20T23:59:59Z as start and end times
DEBUG:root:Data sent: zzz-4460-bcb4-1b31807527101012021-09-20T00:00:00Z2021-09-20T23:59:59Zvideo
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 111.111.111.111:80
DEBUG:urllib3.connectionpool:http://111.111.111.111:80 "GET /ISAPI/ContentMgmt/search HTTP/1.1" 401 178
DEBUG:urllib3.connectionpool:http://111.111.111.111:80 "GET /ISAPI/ContentMgmt/search HTTP/1.1" 200 346
DEBUG:root:{'CMSearchResult': OrderedDict([('searchID', '{zzz-4460-bcb4-1b3180752710}'), ('responseStatus', 'true'), ('responseStatusStrg', 'MORE'), ('numOfMatches', '0'), ('matchList', '\n'), ('@attrs', {'version': '2.0'})])}
INFO:root:Found 0 recordings for channel CAM 2
max@MacBook-Pro HikLoad-master %

@Tedyst
Copy link
Owner

Tedyst commented Sep 20, 2021

This error is just weird, the camera says it found something but dosen't want to return anything. For now I implemented the ISAPI spec a bit weirdly, since somehow with optional fields it works for you. I also added a way to return more than 64(for my DVR) results, by following what the DVR says.

@mrmaximas
Copy link
Author

now it's works, great!
But my filenames based on UTC time instead of local time (;
For example Finished downloading 20210920115109.mp4
Screen Shot 2021-09-20 at 15 33 04

@Tedyst
Copy link
Owner

Tedyst commented Sep 20, 2021

Since now it works, I finally added --localtimefilenames to save filenames using date in local time instead of UTC :))

@mrmaximas
Copy link
Author

strange bugs.. I know for a fact that I have one record in my camera between 6 and 7 a.m. (06:52:01 exact time)

if i run script without time span args:
HikLoad-master % python3 download.py 111.111.111.111 admin pass --folders
INFO:root:Found channels ['101']
INFO:root:Found 16 recordings for channel 101
INFO:root:Started downloading 20210920035201.mkv <<< this is first record of the day

if i run with time span args:
max@MacBook-Pro HikLoad-master % python3 download.py 111.111.111.111 admin pass --folders --starttime 2021-09-20T06:00:00+03:00 --endtime 2021-09-20T07:00:00+03:00

INFO:root:Found channels ['101']
INFO:root:Found 6 recordings for channel 101
Traceback (most recent call last):
File "/Users/max/Downloads/HikLoad-master/download.py", line 150, in
main(args)
File "/Users/max/Downloads/HikLoad-master/download.py", line 122, in main
url = recording['mediaSegmentDescriptor']['playbackURI']
TypeError: string indices must be integers

@mrmaximas
Copy link
Author

oops, now i will try latest version ))

@mrmaximas
Copy link
Author

same issue with latest ver
max@MacBook-Pro HikLoad-master % python3 download.py 111.111.111.111 admin pass --folders --starttime 2021-09-20T06:00:00+03:00 --endtime 2021-09-20T07:00:00+03:00

INFO:root:Found channels ['101']
INFO:root:Found 6 recordings for channel 101
Traceback (most recent call last):
File "/Users/max/Downloads/HikLoad-master/download.py", line 159, in
main(args)
File "/Users/max/Downloads/HikLoad-master/download.py", line 124, in main
url = recording['mediaSegmentDescriptor']['playbackURI']
TypeError: string indices must be integers
max@MacBook-Pro HikLoad-master %

@mrmaximas
Copy link
Author

Since now it works, I finally added --localtimefilenames to save filenames using date in local time instead of UTC :))

--localtimefilenames >> INFO:root:Found 16 recordings for channel 101
INFO:root:Started downloading 20210920005201.mkv

file name 20210920005201.mkv for file from 06:52:01 instead of 20210920065201.mkv

@mrmaximas
Copy link
Author

python3 download.py 111.111.111.111 admin pass --folders --localtimefilenames --videoformat mp4 --days 2

INFO:root:Found channels ['101']
INFO:root:Found 35 recordings for channel 101
INFO:root:Started downloading 20210918222739.mp4 <<< file captured 2020:09:19 04:27:39
INFO:root:Finished downloading 20210918222739.mp4
INFO:root:Started downloading 20210918223157.mp4 <<< file captured 2020:09:19 04:31:57
INFO:root:Finished downloading 20210918223157.mp4
etc

@Tedyst
Copy link
Owner

Tedyst commented Sep 20, 2021

Yeah, this one was because I substracted the time difference instead of adding. Also added a little check in case hikvision returns a string instead of an object...

@mrmaximas
Copy link
Author

same issue with latest ver
max@MacBook-Pro HikLoad-master % python3 download.py 111.111.111.111 admin pass --folders --starttime 2021-09-20T06:00:00+03:00 --endtime 2021-09-20T07:00:00+03:00

INFO:root:Found channels ['101']
INFO:root:Found 6 recordings for channel 101
Traceback (most recent call last):
File "/Users/max/Downloads/HikLoad-master/download.py", line 159, in
main(args)
File "/Users/max/Downloads/HikLoad-master/download.py", line 124, in main
url = recording['mediaSegmentDescriptor']['playbackURI']
TypeError: string indices must be integers
max@MacBook-Pro HikLoad-master %

what about this?

@mrmaximas
Copy link
Author

python3 download.py 111.111.111.111 admin pass --folders --localtimefilenames --videoformat mp4 --days 2

INFO:root:Found channels ['101']
INFO:root:Found 35 recordings for channel 101
INFO:root:Started downloading 20210918222739.mp4 <<< file captured 2020:09:19 04:27:39
INFO:root:Finished downloading 20210918222739.mp4
INFO:root:Started downloading 20210918223157.mp4 <<< file captured 2020:09:19 04:31:57
INFO:root:Finished downloading 20210918223157.mp4
etc

fixed

@mrmaximas
Copy link
Author

mrmaximas commented Sep 20, 2021

--folders --localtimefilenames --videoformat mp4 --starttime 2021-09-20T06:00:00+03:00 --endtime 2021-09-20T07:00:00+03:00
INFO:root:Found channels ['101']
INFO:root:Found 6 recordings for channel 101
Traceback (most recent call last):
  File "/Users/max/Downloads/HikLoad-master/download.py", line 165, in <module>
    main(args)
  File "/Users/max/Downloads/HikLoad-master/download.py", line 125, in main
    mediasegment = recording['mediaSegmentDescriptor']
TypeError: string indices must be integers

today i have only one record from 06 to 07 am. 06:52:01 exact time

--folders --localtimefilenames --videoformat mp4 --days 1
INFO:root:Found channels ['101']
INFO:root:Found 20 recordings for channel 101
INFO:root:Started downloading 20210920065201.mp4 << this is right. but if we have time span args we have an error

@mrmaximas
Copy link
Author

next step of usability - stack files in a folders by date )

@mrmaximas
Copy link
Author

and --yesterday arg )

@Tedyst
Copy link
Owner

Tedyst commented Sep 21, 2021

and --yesterday arg )

Ok, added this

next step of usability - stack files in a folders by date )

Reimplemented --folders to specify how exactly you want the folders to be created(onepercamera, oneperday, onepermonth, oneperyear)

TypeError: string indices must be integers

For this one I made so that the code dosen't stop when it sees that error, I don't really know what could cause this except the server returning wrong XML data.

@Tedyst
Copy link
Owner

Tedyst commented Sep 21, 2021

Also if the new code dosen't download videos correctly, you can try the --fmpeg flag, since I made the default behaviour to download directly from the DVR/Camera, without any RTSP.

@mrmaximas
Copy link
Author

Also if the new code dosen't download videos correctly, you can try the --fmpeg flag, since I made the default behaviour to download directly from the DVR/Camera, without any RTSP.

good idea, may be the best way is download via http then convert with ffmpeg? so slow but more reliably

@Tedyst
Copy link
Owner

Tedyst commented Sep 21, 2021

good idea, may be the best way is download via http then convert with ffmpeg? so slow but more reliably

If there is specified another file extension than "mkv"(since the dvr saves the videos in this format), it will be transcoded using ffmpeg.

@mrmaximas
Copy link
Author

good idea, may be the best way is download via http then convert with ffmpeg? so slow but more reliably

If there is specified another file extension than "mkv"(since the dvr saves the videos in this format), it will be transcoded using ffmpeg.

yes, but how to automate this transcoding locally )

@Tedyst
Copy link
Owner

Tedyst commented Sep 21, 2021

Isn't the script automatically transcoding already? It is supposed to do that, but maybe I introduced a bug that won't let it work.

@mrmaximas
Copy link
Author

mrmaximas commented Sep 21, 2021

Isn't the script automatically transcoding already? It is supposed to do that, but maybe I introduced a bug that won't let it work.

automate transcoding works only via rtsp download, with --ffmpeg option.
with --no-ffmpeg option files downloads via http but no transcoded,
DEBUG:root:Folder CAM 2 already exists
DEBUG:root:Folder 2021 already exists
DEBUG:root:Folder 9 already exists
DEBUG:root:Folder 20 already exists
INFO:root:Started downloading 20210920214512.mp4
DEBUG:root:url: 'rtsp://111/Streaming/tracks/101/?starttime=20210920T184512Z&endtime=20210920T184528Z&name=ch01_00000000021000101&size=11939600', name: '20210920214512.mp4'
DEBUG:root:Data sent: rtsp://111/Streaming/tracks/101/?starttime=20210920T184512Z&endtime=20210920T184528Z&name=ch01_00000000021000101&size=11939600
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 111:80
DEBUG:urllib3.connectionpool:http://111:80 "GET /ISAPI/ContentMgmt/download HTTP/1.1" 401 178
DEBUG:urllib3.connectionpool:http://111:80 "GET /ISAPI/ContentMgmt/download HTTP/1.1" 200 11939640
INFO:root:Finished downloading 20210920214512.mp4

@Tedyst
Copy link
Owner

Tedyst commented Sep 22, 2021

Can you try running the latest version? If the bug still exists, can you specify what arguments are you using? For me, it works using the arguments --folders=oneperday --videoformat mkv --debug. (I also changed the default format to mp4, since it is more compatible in general). If this still dosen't work, you can try --forcetranscoding.

[root -                 main() ] Started downloading 20210920062001.mp4
[root -                 main() ] Files to download: (url: 'rtsp:///Streaming/tracks/201/?starttime=&endtime=&name=&size=18150844', name: '20210920062001.mp4')
[hikvisionapi.utils -               getXML() ] Data sent: <?xml version = "1.0" encoding = "UTF-8" ?><downloadRequest xmlns="http://www.hikvision.com/ver20/XMLSchema"><playbackURI>rtsp:///Streaming/tracks/201/?starttime=&amp;endtime=&amp;name=&amp;size=18150844</playbackURI></downloadRequest>
[urllib3.connectionpool -            _new_conn() ] Starting new HTTP connection (1): :80
[urllib3.connectionpool -        _make_request() ] http://:80 "GET /ISAPI/ContentMgmt/download HTTP/1.1" 401 138
[urllib3.connectionpool -        _make_request() ] http://:80 "GET /ISAPI/ContentMgmt/download HTTP/1.1" 200 18150884
[hikvisionapi.RTSPutils -    processSavedVideo() ] Starting processing 20210920062001.mp4
ffmpeg version n4.4 Copyright (c) 2000-2021 the FFmpeg developers

@mrmaximas
Copy link
Author

max@MacBook-Pro HikLoad-master % python3 download.py 111.111.111.111 admin pass --folders oneperday --localtimefilenames --debug

[hikvisionapi.utils - getXMLRaw() ] http://admin:[email protected]/ISAPI/Streaming/channels
[urllib3.connectionpool - _new_conn() ] Starting new HTTP connection (1): 111.111.111.111:80
[urllib3.connectionpool - _make_request() ] http://111.111.111.111:80 "GET /ISAPI/Streaming/channels HTTP/1.1" 401 178
[urllib3.connectionpool - _make_request() ] http://111.111.111.111:80 "GET /ISAPI/Streaming/channels HTTP/1.1" 200 3800
[hikvisionapi.utils - getXMLRaw() ] http://admin:[email protected]/ISAPI/ContentMgmt/search/profile
[urllib3.connectionpool - _new_conn() ] Starting new HTTP connection (1): 111.111.111.111:80
[urllib3.connectionpool - _make_request() ] http://111.111.111.111:80 "GET /ISAPI/ContentMgmt/search/profile HTTP/1.1" 401 178
[urllib3.connectionpool - _make_request() ] http://111.111.111.111:80 "GET /ISAPI/ContentMgmt/search/profile HTTP/1.1" 403 318
Traceback (most recent call last):
File "/Users/max/Downloads/HikLoad-master/download.py", line 196, in
main(args)
File "/Users/max/Downloads/HikLoad-master/download.py", line 76, in main
server.ContentMgmt.search.profile())
File "/Users/max/Downloads/HikLoad-master/hikvisionapi/_ContentMgmt.py", line 19, in profile
return hikvisionapi.getXML(self.parent, "ContentMgmt/search/profile")
File "/Users/max/Downloads/HikLoad-master/hikvisionapi/utils.py", line 40, in getXML
raise hikvisionapi.HikvisionException(
hikvisionapi.classes.HikvisionException: Invalid Operation
max@MacBook-Pro HikLoad-master %

@mrmaximas
Copy link
Author

mrmaximas commented Sep 22, 2021

here is answer for request url /ISAPI/Streaming/channels ( <> changed with [])

[StreamingChannelList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"]
[StreamingChannel xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"]
[id]101[/id]
[channelName]CAM 1[/channelName]
[enabled]true[/enabled]
[Transport]
[maxPacketSize]1000[/maxPacketSize]
[ControlProtocolList]
[ControlProtocol]
[streamingTransport]RTSP[/streamingTransport]
[/ControlProtocol]
[ControlProtocol]
[streamingTransport]HTTP[/streamingTransport]
[/ControlProtocol]
[ControlProtocol]
[streamingTransport]SHTTP[/streamingTransport]
[/ControlProtocol]
[/ControlProtocolList]
[Unicast]
[enabled]true[/enabled]
[rtpTransportType]RTP/TCP[/rtpTransportType]
[/Unicast]
[Multicast]
[enabled]true[/enabled]
[destIPAddress]0.0.0.0[/destIPAddress]
[videoDestPortNo]8860[/videoDestPortNo]
[audioDestPortNo]8862[/audioDestPortNo]
[FecInfo]
[fecRatio]0[/fecRatio]
[fecDestPortNo]8960[/fecDestPortNo]
[/FecInfo]
[/Multicast]
[Security]
[enabled]true[/enabled]
[certificateType]digest[/certificateType]
[/Security]
[/Transport]
[Video]
[enabled]true[/enabled]
[videoInputChannelID]1[/videoInputChannelID]
[videoCodecType]H.265[/videoCodecType]
[videoScanType]progressive[/videoScanType]
[videoResolutionWidth]2688[/videoResolutionWidth]
[videoResolutionHeight]1520[/videoResolutionHeight]
[videoQualityControlType]VBR[/videoQualityControlType]
[constantBitRate]6144[/constantBitRate]
[fixedQuality]100[/fixedQuality]
[vbrUpperCap]6144[/vbrUpperCap]
[vbrLowerCap]32[/vbrLowerCap]
[maxFrameRate]1500[/maxFrameRate]
[keyFrameInterval]4000[/keyFrameInterval]
[snapShotImageType]JPEG[/snapShotImageType]
[GovLength]60[/GovLength]
[SVC]
[enabled]false[/enabled]
[/SVC]
[PacketType]PS[/PacketType]
[PacketType]RTP[/PacketType]
[smoothing]1[/smoothing]
[H265Profile]Main[/H265Profile]
[SmartCodec]
[enabled]false[/enabled]
[/SmartCodec]
[/Video]
[/StreamingChannel]
[StreamingChannel xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"]
[id]102[/id]
[channelName]CAM 1[/channelName]
[enabled]true[/enabled]
[Transport]
[maxPacketSize]1000[/maxPacketSize]
[ControlProtocolList]
[ControlProtocol]
[streamingTransport]RTSP[/streamingTransport]
[/ControlProtocol]
[ControlProtocol]
[streamingTransport]HTTP[/streamingTransport]
[/ControlProtocol]
[ControlProtocol]
[streamingTransport]SHTTP[/streamingTransport]
[/ControlProtocol]
[/ControlProtocolList]
[Unicast]
[enabled]true[/enabled]
[rtpTransportType]RTP/TCP[/rtpTransportType]
[/Unicast]
[Multicast]
[enabled]true[/enabled]
[destIPAddress]0.0.0.0[/destIPAddress]
[videoDestPortNo]8866[/videoDestPortNo]
[audioDestPortNo]8868[/audioDestPortNo]
[FecInfo]
[fecRatio]0[/fecRatio]
[fecDestPortNo]8966[/fecDestPortNo]
[/FecInfo]
[/Multicast]
[Security]
[enabled]true[/enabled]
[certificateType]digest[/certificateType]
[/Security]
[/Transport]
[Video]
[enabled]true[/enabled]
[videoInputChannelID]1[/videoInputChannelID]
[videoCodecType]H.264[/videoCodecType]
[videoScanType]progressive[/videoScanType]
[videoResolutionWidth]640[/videoResolutionWidth]
[videoResolutionHeight]360[/videoResolutionHeight]
[videoQualityControlType]VBR[/videoQualityControlType]
[constantBitRate]256[/constantBitRate]
[fixedQuality]100[/fixedQuality]
[vbrUpperCap]256[/vbrUpperCap]
[vbrLowerCap]32[/vbrLowerCap]
[maxFrameRate]1000[/maxFrameRate]
[keyFrameInterval]4000[/keyFrameInterval]
[snapShotImageType]JPEG[/snapShotImageType]
[H264Profile]High[/H264Profile]
[GovLength]40[/GovLength]
[SVC]
[enabled]false[/enabled]
[/SVC]
[PacketType]PS[/PacketType]
[PacketType]RTP[/PacketType]
[smoothing]1[/smoothing]
[H265Profile]Main[/H265Profile]
[/Video]
[/StreamingChannel]
[/StreamingChannelList]

@mrmaximas
Copy link
Author

here is for ISAPI/ContentMgmt/search/profile
[ResponseStatus xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"]
[requestURL]/ISAPI/ContentMgmt/search/profile[/requestURL]
[statusCode]4[/statusCode]
[statusString]Invalid Operation[/statusString]
[subStatusCode]invalidOperation[/subStatusCode]
[/ResponseStatus]

@Tedyst
Copy link
Owner

Tedyst commented Sep 22, 2021

Due to the complexity of the functions entailed in a recording and content management (RaCM)
device, all RaCM devices MUST provide a ‘profile’ resource (schema instance) such that entities
accessing them may determine their functional level and basic attributes. Details are outlined below.

I am starting to question the validity of the ISAPI specification... Also removed the line that caused this error.

@mrmaximas
Copy link
Author

what about http download then transcode? not on-the-fly. imho rtsp download with on-the-fly transcoding is not best way.

@Tedyst
Copy link
Owner

Tedyst commented Sep 23, 2021

what about http download then transcode? not on-the-fly. imho rtsp download with on-the-fly transcoding is not best way.

That can already be accomplished by running ffmpeg -i 20210923051106.mp4 video.mkv -y. I don't think it is needed for download.py to manage anything other than downloading. Maybe if I create another script for that, but imo i don't think it is that needed.

@Tedyst
Copy link
Owner

Tedyst commented Sep 24, 2021

I am closing this issue since everything should be solved. If there are any more problems, be sure to create another issue or reply to this one.

@Tedyst Tedyst closed this as completed Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants