Author Topic: transfer video to computer via code  (Read 3517 times)

DDR

  • Krontech
  • Full Member
  • *****
  • Posts: 110
    • View Profile
    • Krontech
Re: transfer video to computer via code
« Reply #15 on: September 06, 2018, 10:31:11 PM »
On linux, ssh1 may be able to connect where ssh cannot. We hope this issue - and the security warnings - will be solved by the upcoming 0.4.x update.

Oracle

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: transfer video to computer via code
« Reply #16 on: August 13, 2019, 02:14:47 AM »
The error basically means the connection to the camera failed on port 22.

Can you try to use ssh to connect to the camera? PuTTY is a great windows tool for that. Or use BASH directly if you're on windows 10.
From there on troubleshooting is much easier.
Good day. I had the same problem as a user above. Now I connected to camera via SSH as a root. What can/should I do now in order to enable the script provided above to work? (The main task for me is to get the images/videos from the camera when I need via python script, if this information is necessary)

skronstein

  • Krontech
  • Jr. Member
  • *****
  • Posts: 63
    • View Profile
Re: transfer video to computer via code
« Reply #17 on: August 13, 2019, 12:10:05 PM »
The error basically means the connection to the camera failed on port 22.

Can you try to use ssh to connect to the camera? PuTTY is a great windows tool for that. Or use BASH directly if you're on windows 10.
From there on troubleshooting is much easier.
Good day. I had the same problem as a user above. Now I connected to camera via SSH as a root. What can/should I do now in order to enable the script provided above to work? (The main task for me is to get the images/videos from the camera when I need via python script, if this information is necessary)

Run the script on the computer, not the camera. You don't have to log in via SSH separately.  The script will do that for you.
Logging in via ssh might be useful as a debugging step if the script isn't working.

Oracle

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: transfer video to computer via code
« Reply #18 on: August 13, 2019, 01:59:01 PM »
The problem is that the script is not working :) Therefore I tried to connect by SSH, but now I don't know how to use it to solve initial problem.

skronstein

  • Krontech
  • Jr. Member
  • *****
  • Posts: 63
    • View Profile
Re: transfer video to computer via code
« Reply #19 on: August 14, 2019, 11:53:38 AM »
What happens when you try to run the script?

Oracle

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: transfer video to computer via code
« Reply #20 on: August 15, 2019, 02:11:15 AM »
Traceback (most recent call last):
  File "get_latest_video.py", line 7, in <module>
    cam = ParamikoMachine(host=host, user='root', password='')
  File "/home/martin/anaconda3/envs/camera/lib/python3.7/site-packages/plumbum/machines/paramiko_machine.py", line 245, in __init__
    self._client.connect(host, **kwargs)
  File "/home/martin/anaconda3/envs/camera/lib/python3.7/site-packages/paramiko/client.py", line 416, in connect
    self, server_hostkey_name, server_key
  File "/home/martin/anaconda3/envs/camera/lib/python3.7/site-packages/paramiko/client.py", line 824, in missing_host_key
    "Server {!r} not found in known_hosts".format(hostname)
paramiko.ssh_exception.SSHException: Server '192.168.12.21' not found in known_hosts

Oracle

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: transfer video to computer via code
« Reply #21 on: August 15, 2019, 10:16:25 PM »
What happens when you try to run the script?
Also, this is the only way I was able to connect to camera via SSH:
ssh root@192.168.12.1 -o Kexalgorithms=+diffie-hellman-group1-sha1 -o Ciphers=+aes128-cbc

skronstein

  • Krontech
  • Jr. Member
  • *****
  • Posts: 63
    • View Profile
Re: transfer video to computer via code
« Reply #22 on: August 16, 2019, 06:00:22 PM »
The script is trying to connect to connect to '192.168.12.21' instead of '192.168.12.1'.
Was your script edited to use 21 instead of 1 for the last number?

Oracle

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: transfer video to computer via code
« Reply #23 on: August 17, 2019, 05:54:42 AM »
I just noticed it) After changing IP to 192.168.12.1 there occured another error:
copying latest video to host
Traceback (most recent call last):
  File "get_latest_video.py", line 37, in <module>
    copy_video(cam, serial, localdir)
NameError: name 'serial' is not defined

How should I define that serial?

skronstein

  • Krontech
  • Jr. Member
  • *****
  • Posts: 63
    • View Profile
Re: transfer video to computer via code
« Reply #24 on: August 19, 2019, 04:03:10 PM »
serial should just be removed from the script.  Open the script in a text editor and change the line containing the world 'serial' to:
copy_video(cam, localdir)

rvcFS

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: transfer video to computer via code
« Reply #25 on: September 09, 2019, 06:05:12 AM »
Hey guys,

I downloaded the get_latest_video.py script and installed all the dependencies (paramiko and plumbum), however I am not able to connect to the camera.
I did the following steps but I keep getting timed out.
Connect the Camera to the PC using (eSATA / USB) port
Connected a ethernet LAN cable from my pc network adapter to the cameras network adapter (blinking with lights)
Changed my pc network adapter ip to a static ip of 192.168.12.10
Tried to ping the camera on 192.168.12.1, destination host unreachable / request timed out
I tried running the script, gave me a no response error.

Would appreciate any advise on what I did wrong. :-[

rvcFS

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: transfer video to computer via code
« Reply #26 on: September 09, 2019, 09:07:15 AM »
Sorry guys, it was my mistake, I missed the point where the USB acts as a Ethernet bridge.

I managed to connect using winSCP, however when I try to run the python script, I get the following errors:

Code: [Select]
File "C:\Program Files (x86)\Python36-32\lib\site-packages\plumbum\machines\paramiko_machine.py", line 245, in __init__
    self._client.connect(host, **kwargs)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\paramiko\client.py", line 416, in connect
    self, server_hostkey_name, server_key
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\paramiko\client.py", line 824, in missing_host_key
    "Server {!r} not found in known_hosts".format(hostname)
paramiko.ssh_exception.SSHException: Server '192.168.12.1' not found in known_hosts

Im running this on Python 3.6.5 on a Windows 10 OS;

NiNeff

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: transfer video to computer via code
« Reply #27 on: September 09, 2019, 10:47:11 AM »
have you tried ssh1 instead of winscp?
can you edid you known_hosts file and add the required key?
if you're on win10 you can install bash and use native linux tools which might be easier.

rvcFS

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: transfer video to computer via code
« Reply #28 on: September 09, 2019, 12:16:30 PM »
have you tried ssh1 instead of winscp?
can you edid you known_hosts file and add the required key?
if you're on win10 you can install bash and use native linux tools which might be easier.

@NiNeff thanks for the reply, I managed to solve the issue.
 
Apparently windows does not automatically add unknown hosts when SSHing (no .ssh host file exists) for security reasons. I added the following parameter to the ParmaikoMachine() initalizer:
Code: [Select]
cam = ParamikoMachine(host=host, user='root', password='', missing_host_policy=paramiko.AutoAddPolicy()) since the default value is set to "None" which rejects any unknown hosts.

Furthermore, copying the video introduced another issue, the following line:
Code: [Select]
latest = cam['/bin/ls -t -1 /media/mmcblk1p1']().split()[0] returns the first index of the standard out which in my case was "System" and caused a (File does not exist) error when attempting to copy the file.

Changing it to the following solves the issue:
Code: [Select]
latest = cam['/bin/ls -t -1 /media/mmcblk1p1']().split()[3] which is the 3rd index of the sorted list. This returned the latest video in my case.

Sharing in case anyone encounters similar issues.

Cheers!