Gadgets and Things

Blogs about gadgets and stuffs I've been playing with

Saturday, February 10, 2024

Raspi Mirror Kiosk setup

This is a how-to setup for my Raspi Mirror, which is basically just a Rasperry Pi running a webpage on Kiosk mode.



Install Raspbian on your Pi.

After Installing Raspbian

1. Install unclutter
sudo apt install unclutter

2. Setup Chromium to autostart in kiosk mode (and remove cursor)
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

#Put this lines in the autostart file
@chromium-browser --start-fullscreen --kiosk https://your.webpage.here
@unclutter -idle 0.01

3. Setup Crontab to turn off screen at night and turn on in the morning

crontab -e

#Put this lines in the crontab file
0 22 * * * vcgencmd display_power 0
0 7 * * * vcgencmd display_power 1

4. Edit /boot/config.txt
display_rotate=1
  • note this probably don't work anymore, need to go to desktop and change orientation
  • With the Raspberry Pi Configuration menu opened, you will need to first change to the “ Display ” tab. Within this tab, you should see the option named “ Screen Blanking “, click the “ Disabled ” button next to the option. Once the option is disabled, click the “ Ok ” button to apply the change

Added Note:
vcgencmd no longer works in new builds, you will need to do this:
- edit file /boot/config.txt
- comment out this line dtoverlay=vc4-kms-v3d
- save file
- reboot
This will also make display_rotate=1 work..


Posted by Roland at 11:45 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

Tuesday, January 24, 2023

Octoprint on Pogoplug V4

If you have a Pogoplug V4 (other Pogoplugs variants will probably work), another use for it could be as an Octoprint server!


Here's how I set up mine.  FYI, I've updated my Pogoplug to Debian Buster, so YMMV.

There's two sections, one is for installing mjpg-streamer, and the other is for Octoprint itself.

 

1. MJPG-STREAMER

 

apt-get install build-essential libjpeg62-turbo-dev imagemagick libv4l-dev cmake git -y

mkdir ~/mjpg-streamer
cd ~/mjpg-streamer
 
git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
 
make
make install


Then, test:

/usr/local/bin/mjpg_streamer -i "input_uvc.so -f 15 -r 640x480" \
 -o "output_http.so -w /usr/local/share/mjpg-streamer/www"

I've place the command :

/usr/local/bin/mjpg_streamer -b -i "input_uvc.so -f 15 -r 1920x1080" -o "output_http.so -w /usr/local/share/mjpg-streamer/www"

in the last line of /etc/rc.local so it will load mjpg_streamer on startup and it is accessible on port 8080 (i.e. your Pogoplug's IP address is 192.168.1.78, then the url to view the webcam is http://192.168.1.78:8080/?action=stream)


2. OCTOPRINT

 

Prior to installing Octoprint, make sure you have enough TMP folder space, as some downloads will take up more than the available space for TMP folder.

I've resized my tmp folder by editing /etc/fstab and replacing the default values for tmpfs:

tmpfs          /tmp            tmpfs   rw,nodev,nosuid,size=5G  0       0

Then reboot and do a "df" command to see how much space is available for the tmp folder. 5GB is big enough for me, but it's up to you how much you want (I think 1GB is optimal).

In order to install Octoprint, you will need a non-root user, and these steps were copied from the manual install procedure of the Raspberry Pi so we will be using the user "pi" (but be free to use your own username).

Installing Octoprint in Pogoplug

Setup pogoplug:

apt install sudo

adduser pi (or any name)
usermod -aG sudo pi

Logon as non-root user:

cd ~
sudo apt update
sudo apt install python3 python3-pip python3-dev python3-setuptools python3-venv git libyaml-dev build-essential libffi-dev libssl-dev ffmpeg
mkdir OctoPrint && cd OctoPrint
python3 -m venv venv
source venv/bin/activate


You should now be in venv (virtual machine)

pip install pip --upgrade
pip install wheel
pip install octoprint

sudo usermod -a -G tty pi
sudo usermod -a -G dialout pi


Starting the server for the first time

You should then be able to start the OctoPrint server using the octoprint serve command:

~/OctoPrint/venv/bin/octoprint serve

2020-11-03 17:39:17,979 - octoprint.startup - INFO - ***************************
2020-11-03 17:39:17,980 - octoprint.startup - INFO - Starting OctoPrint 1.8.6
2020-11-03 17:39:17,980 - octoprint.startup - INFO - ***************************


Octoprint should  then be accessible thru port 5000 of the IP address of your Pogoplug (i.e. http://192.168.1.78:5000)

You will then set Octoprint to run on startup, or manually...

Posted by Roland at 5:11 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

Tuesday, April 06, 2021

Installing Debian Buster to Pogoplug/Dockstar/Seagate GoFlexNet

Installing Debian Buster to Pogoplug/Dockstar/Seagate GoFlexNet

I found that my old dockstars/Pogoplugs (and other similar devices) were running outdated Linux versions (Wheezy) and wanted to update them... A visit to the usual sites like doozan.com had lots of varying instructions, and I made this blog post to consolidate all the instructions and the steps I made to upgrade mine to Debian Buster. Your dockstar/pogoplug compatible device should be accessible as root, and this post doesn't include the instructions to hack your device to allow booting with root. 

Some of my devices have missing USB drives but were able to boot with the drives from different devices (I was able to use the drive from my dockstar with GoFlexNet) and some had rescue boot installed so I was able to work it when I wasn't able to use the boot drive... The instructions here does not include how to install rescue boot but I will figure it out later.

Some the links I posted here are direct links that may change in time, so if the links do expire, visit https://forum.doozan.com/read.php?2,12096 for the current links.

Part 1 would be instructions to install UBoot (which is basically the "firmware"), while Part 2 would be instructions on preparing your usb drive (or SD Card or SATA drive for Pogoplug V4) with Debian Buster(OS)....

Part 1 - Preparing Uboot

Flashing uBoot

Dockstar
wget https://www.dropbox.com/s/8n5c2fzgpoxgk39/uboot.2017.07-tld-1.dockstar.bodhi.tar --no-check-certificate

GoflexNet
wget https://www.dropbox.com/s/b7ac42royuow72q/uboot.2017.07-tld-1.goflexnet.bodhi.tar --no-check-certificate

GoFlexHome
wget https://www.dropbox.com/s/klksl0vawkhie9r/uboot.2017.07-tld-1.goflexhome.bodhi.tar --no-check-certificate

Pogoplug E02
wget https://www.dropbox.com/s/vgbshmiq3o14btp/uboot.2017.07-tld-1.pogo_e02.bodhi.tar --no-check-certificate

Pogoplug V4
wget https://www.dropbox.com/s/6k3a80jqdplpkeg/uboot.2017.07-tld-1.pogo_v4.bodhi.tar --no-check-certificate


Flashing Instructions

1. get your ethernet addr:
fw_printenv ethaddr

2. Save it in a text file for later use (00:10:75:1A:3C:B5)

3. Save the contents of your environment:
fw_printenv > current_envs.txt

4. Dump Nand mtd0:
nanddump --noecc --omitoob -l 0x80000 -f mtd0 /dev/mtd0

If you don't have nanddump, install it using apt-get install mtd-utils
else

cd /tmp
wget http://download.doozan.com/uboot/nanddump
wget http://download.doozan.com/uboot/nandwrite
wget http://download.doozan.com/uboot/flash_erase
chmod +x nanddump nandwrite flash_erase

5. Make sure you don't have bad block from 0 to 7

Be sure there is no bad block in the first 1M of your NAND (check dmesg). This is very important, if there is bad block in the first 1M (8 blocks), don't flash u-boot, because you will almost certainly brick your box. Please post your question here (there is a work around for it).

Example of bad block in mtd0:

dmesg | grep -i 'bad'

[    2.413231] Scanning device for bad blocks
[    2.417731] Bad eraseblock 3 at 0x000000060000

This bad block is the 4th block which resides within mtd0 (block 0 to block 7). So u-boot should not be flashed.

6. Extract archive to /tmp (use the tar file you downloaded for your version of device)
cd /tmp
tar -xf uboot.2017.07-tld-1.dockstar.bodhi.tar
tar -xf uboot.2017.07-tld-1.goflexhome.bodhi.tar
tar -xf uboot.2017.07-tld-1.goflexnet.bodhi.tar
tar -xf uboot.2017.07-tld-1.iconnect.bodhi.tar
tar -xf uboot.2017.07-tld-1.netgear_ms2110.bodhi.tar
tar -xf uboot.2017.07-tld-1.pogo_e02.bodhi.tar
tar -xf uboot.2017.07-tld-1.pogo_v4.bodhi.tar
tar -xf uboot.2017.07-tld-2.sheevaplug.bodhi.tar
tar -xf uboot.2017.07-tld-1.nsa320.bodhi.tar
tar -xf uboot.2017.07-tld-1.nsa325.bodhi.tar
tar -xf uboot.2017.07-tld-1.nsa310s.bodhi.tar
tar -xf uboot.2017.07-tld-1.nsa310.bodhi.tar

7. Erase mtd0

./flash_erase /dev/mtd0 0 4

8. Write image to NAND

./nandwrite /dev/mtd0 uboot.2017.07-tld-1.dockstar.mtd0.kwb
./nandwrite /dev/mtd0 uboot.2017.07-tld-1.goflexhome.mtd0.kwb
./nandwrite /dev/mtd0 uboot.2017.07-tld-1.goflexnet.mtd0.kwb
./nandwrite /dev/mtd0 uboot.2017.07-tld-1.pogo_e02.mtd0.kwb
./nandwrite /dev/mtd0 uboot.2017.07-tld-1.pogo_v4.mtd0.kwb

9. Flash default u-boot envs image

wget https://www.dropbox.com/s/4smmw2wr4ugayz9/uboot.2016.05-tld-1.environment.bodhi.tar --no-check-certificate

10. Extract Archive

cd /tmp
tar -xf uboot.2016.05-tld-1.environment.bodhi.tar

11. Save current envs (no need if you have done 3.)

fw_printenv > current_envs.txt (make a copy in notepad as you will refer it later)

12.Flash u-boot envs to NAND location 0xC0000.

Be extra careful with the next 2 commands, you should see output that look like below. If there is error, then do not reboot, post your problem here so we can help.

./flash_erase /dev/mtd0 0xc0000 1

Expected output:

Erase Total 1 Units
Performing Flash Erase of length 131072 at offset 0xc0000 done

./nandwrite -s 786432 /dev/mtd0 uboot.2016.05-tld-1.environment.img

Expected output:

Writing data to block 6 at offset 0xc0000

Modify the following u-boot variables using fw_setenv:

ArcNumber:

for Pogo V4/Mobile:

fw_setenv arcNumber 3960
fw_setenv machid f78

for Dockstar:

fw_setenv arcNumber 2998
fw_setenv machid

for Pogo E02:

fw_setenv arcNumber 3542
fw_setenv machid dd6

for GoFlex Home:

fw_setenv arcNumber 3338
fw_setenv machid

for GoFlex Net:

fw_setenv arcNumber 3089
fw_setenv machid

Then for all boxes, restore these 2 envs using the saved envs text

fw_setenv mtdparts 'xxxxxxxxx'
fw_setenv ethaddr 'xx:xx:xx:xx:xx:xx'

Example :
fw_setenv mtdparts 'mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)'
fw_setenv ethaddr '00:10:75:1A:3B:C5'

Note: If fw_setenv ethaddr fails and complains that it is readonly, you will need to change it in netconsole.
      Interrupt the boot process in netconsole, type in "setenv ethaddr '00:10:75:1A:3B:C5'" and then "saveenv" to save the changes

13. Set IDE env

fw_setenv bootcmd_uenv 'run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi; sleep 3'

14. Adjust DTB Name to boot correct rootfs
Find your box DTB file in the rootfs /boot/dts directory and adjust the env to it. For example, if the box is the Dockstar

fw_setenv dtb_file '/boot/dts/kirkwood-dockstar.dtb'
fw_setenv dtb_file '/boot/dts/kirkwood-pogoplug_v4.dtb'
fw_setenv dtb_file '/boot/dts/kirkwood-pogo_e02.dtb'
fw_setenv dtb_file '/boot/dts/kirkwood-goflexhome.dtb'
fw_setenv dtb_file '/boot/dts/kirkwood-goflexnet.dtb'

15. Check your environment

fw_printenv

16. Setup netconsole (the server should be running netconsole)

Set up your server (the PC where netconsole will be sending the screen to... Run "ncat -l -u -p 6666" in a dos prompt

fw_setenv preboot_nc 'setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi'
fw_setenv preboot 'run preboot_nc'
fw_setenv ipaddr    '192.168.1.xxx'
fw_setenv serverip '192.168.1.67'

in this case, 192.168.1.67 is the PC where you ran ncat.

18. Install debian to the drive



Part 2 - Preparing External Media

Preparing the USB/SD Card that Pogoplug uses to load Debian:

1. Partition and format your boot partition/drive from a linux PC (or Rescue mode in Pogoplug)

Assuming your drive is showing as /dev/sdb (do an lsusb command to see usb drives)

fdisk /dev/sdb

Create a partition with linux file system and set it as a boot partition (under fdisk, use "a" to flag partition as bootable)

Format the partition to an ext3 filesystem 

mkfs.ext3 -L rootfs /dev/sdb1

Quit fdisk

Mount the new partition (make sure you create the /media/usb directory first)

mount /dev/sdb1 /media/usb

2. Download Debian-5.2.9-kirkwood-tld-1-rootfs-bodhi.tar.bz2 (anywhere, I suggest root dir)

cd /media/usb
wget https://www.dropbox.com/s/pa2cbg93qgcnp8w/Debian-5.2.9-kirkwood-tld-1-rootfs-bodhi.tar.bz2 --no-check-certificate

3. Unzip the package to root directory of the new partition

cd /media/usb

tar -xjf Debian-5.2.9-kirkwood-tld-1-rootfs-bodhi.tar.bz2 
Once it finishes, you should have the directories and files for a debian buster on the partition

 

4. Install Boot loader over Debian (/boot directory)

cd /media/usb/boot

wget https://www.dropbox.com/s/79ply8m4r6jj734/linux-5.11.4-kirkwood-tld-1-bodhi.tar.bz2 --no-check-certificate

Once it is downloaded, unzip it to boot directory... it should have all the dtb files you need for all kirkwood types of devices (Pogoplug, GoflexNet, Dockstar)

tar -xjf linux-5.11.4-kirkwood-tld-1-bodhi.tar.bz2
tar -xf  linux-dtb-5.11.4-kirkwood-tld-1.tar


 5. Remove the disk and install in Pogoplug device (use umount to flush the data to the drive)

umount /media/usb


Installing WIFI: Depending on what dmesg says, which in my case says : "Direct firmware load for htc_9271.fw failed with error" - apt install firmware-ath9k-htc


Posted by Roland at 3:05 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

Wednesday, December 23, 2015

AMAZON Dash
 
Well, I just received a couple of these nifty devices from Amazon.

Being in Canada, it's basically useless right now but I have a lot of ideas on what we can do with these medicine tablet size devices.

The Dash has a basic ARM processor and WIFI connectivity, and once you set it up on your mobile device thru the Amazon app, depending on what product you set it up to buy from Amazon, every time you push the button it will connect to your WIFI router, submit the command thru Amazon (log a purchase) and then turns itself off to save power.
 
Now, if you didn't set up a product for purchase in your Amazon App, it will basically just connect to your WIFI router, and then disconnect.
 
With this behavior, we can create a monitoring app (ARP Probe), which just detects if Amazon Dash  connects to the WIFI router, and then based on this, trigger an action.
 
Here are some of possible applications the Dash can be used for with IFTTT:
 
1. Doorbell  - Push the button, trigger a notification on all the iPads, android machines
2. Door Opener - Push a button, opens a zwave door lock
3. Picture taker - Push a button, grabs a snapshot from my webcam running on the dockstar and email it
4. Light switch - Push button, turn on a zwave light (no need to grab phone, open app, turn on)
5. Garage door opener - Open the garage from living room (might be a security risk)
6. Data logger - Push a button everytime you drink medicine, post it to a spreadsheet so you'll track it.
7. Self Destruct - For the paranoid people out there, a self destruct switch, which turns on wemo/zwave switch that turns on an electromagnet besides your hard drive.
8. etc.
 
The common denominator would be is that you'd need an always on machine, like a Raspberry Pi, Dockstar, Openwrt router, Smartthings, file server PC, etc.  that is running Linux or Windows and when the button is pressed, a monitoring program will detect the MAC address of the Dash, depending on what triggers you have setup in IFTTT (example: file created in Dropbox, send an email to IFTTT, etc.) and when IFTTT detects that, it will then generate a subsequent action like turn on the light (via Wemo, Smarthings, Hue), Post a facebook/instagram/twitter message, and lots of other actions.
 
Stay tune for number 3, I'm planning on having the Amazon Dash post a screen cap from my dockstar's mjpg-streamer automatically to either my FB acct or instagram whenever I push the button.
Posted by Roland at 2:41 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

Thursday, February 26, 2015

My 22TB RAID file server




Sans Digital 8 Bay eSATA Enclosure

My GoFlex Net 22TB NAS




I've been meaning to write up my experiences in creating my cheap 24TB GoFlex Net setup, but I haven't found the time until now.

Now, I've been buying 3TB drives when they were on sale for years now, whenever it goes below $100, I bought one each time, and was planning on just plugging it in my Pogoplug or a desktop HTPC so I can have my file collections accessible online.

Eventually, I was able to buy an 8-bay eSATA enclosure from Amazon.ca for around $160 which was quite cheap compared to the regular price of over $300... It had two eSATA connectors, and the card that came with it supports RAID setups, which I opted not to use.

I have 4 3TB drives and 4 2TB drives installed  in it, totaling 18TB and was using my HTPC as the network server for my iPads, Androids, XBMC, WDTV, XIOS, etc. and it was ok for a while...

However, having a 300W PC server, is a bit excessive as all I really needed was a fileserver, and I looked for a more energy efficient option.I shopped around for any 4 or 8-bay NAS and was surprised it costs more than what a PC is worth and appalled that an 8-bay NAS with no Disk costs more than a thousand dollars, and probably powered by a so-so processor that even the slowest Celeron PC can run around circles with.


I looked at Cubieboards (1 SATA port), Raspberry Pis (USB only), Beaglebone Blacks (USB) and even Cubox-i4Pro (1 eSATA port) and only the Cubox-i4Pro would probably be able to handle the 8 drives, but it would involve splitting the single eSATA port to two SATA connectors, which would in-turn split into 4 drives each, and I'm wary that a single SATA bus would be able to handle it.


Then I found out about the Seagate GoFlex Net, 
Seagate GoFlex Net







which was an fork of the Pogoplug, it supports two SATA drives, and more importantly those SATA bus supports Port Multiplier, allowing me to use my 8-bay enclosure.



The GoFlex Net is now discontinued, as the Pogoplug Cloud didn't really take off, but it is hackable to install Linux on it. My first try was to use Arch Linux, but Debian has a number of fairly good packages I switched to Debian instead and installed Open Media Vault.


I will be discussing later on how I was able to install Debian on the GoFlex Net and the uBoot settings I had to configure for it to be able to boot from the first drive (freeing up the lone USB port) and how I soldered an external power connector (which I took from an old internal fan connector) so I can power the GoFlexnet from the enclosure power supply.


But just to show you it is doable, here's a couple of pictures of the GoFlex Net mounted inside the 8-bay enclosure, thereby giving me a cheap 8-bay NAS. I've accumulated more than 8 3TB drives, so I was planning on installing all of them to have 24TB, but I had problems booting on the 3TB drive due to the Linux's limitation. I was able to boot off a 3TB on my Seagate GoFlex Home (which is a 1 SATA Pogoplug clone), but I was having a hard time to do in on the GoFlexNet, so I opted to just use a 2TB drive for my first two drives in the enclosure... I was planning on setting up RAID on the first two drives and then another RAID for the rest of the 3TB drives, but in the end I just set them all up as independent drives (Disk 1 to 8) and just use RSYNC to back up the important files (which are just pictures, home movies, etc)... Hence I have 22TB  of storage accessible...







GoFlex Net inside the eSATA enclosure


Plugged the SATA cables directly to the GoFlex Net

Posted by Roland at 1:13 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

Tuesday, February 26, 2013

Installing Debian "Wheezy" for Pogoplug/Dockstar

Just some notes on how to install Debian "Wheezy" on the Pogoplug/Dockstar:

If you google on how to install Debian on the Pogoplug/Dockstar/Seagate Goflex Home/NET, you will ultimately wind up to the url: http://projects.doozan.com/debian/

However, the script is designed for newer kernels, and may not work (the script will fail and  the logs will tell you that your "kernel is too old").

There are two ways of going about circumventing this problem:

1. Install Debian "Squeeze" and update to Wheezy:
    Find your devices's IP address and connect via SSH:
username: root password: (the password is 'stxadmin' on Seagate branded devices and 'ceadmin' on Pogoplug devices)
Partition your flash drive with fdisk:
fdisk /dev/sda # Configure partion 1 as Linux (I'd recommend making this at least 512Mb. The default bare-bones installation uses 280Mb.) # Configure partion 2 as Linux Swap (I used 256MB. Adjust according to your anticipated memory usage.) # Set partition 1 active
Download and run the Debian Squeeze installer:
cd /tmp wget http://projects.doozan.com/debian/dockstar.debian-squeeze.sh chmod +x dockstar.debian-squeeze.sh export PATH=$PATH:/usr/sbin:/sbin ./dockstar.debian-squeeze.sh

Update to Wheezy:


apt-get update apt-get dist-upgrade reboot
And Voila! You're running Debian Wheezy!


2. Install Arch Linux or some other Linux derivative, boot from that, login and:
Install Rescue system (this replaces the Pogoplug partition with a powerful rescue system.
cd /tmp wget http://jeff.doozan.com/debian/rescue/install_rescue.sh chmod +x install_rescue.sh ./install_rescue.sh
We also need to disable perl so the the debian-wheezy script does not bomb out. (after installing rescue)
mount -o remount,rw / chmod 666 /usr/bin/microperl rm /usr/sbin/debootstrap rm -rf /usr/share/debootstrap mount -o remount,ro /
then install Debian Wheezy as per original instructions.
cd /tmp wget http://projects.doozan.com/debian/kirkwood.debian-wheezy.sh chmod +x kirkwood.debian-wheezy.sh export PATH-$PATH:/usr/sbin:/sbin ./kirkwood.debian-wheezy.sh

This  way is only recommended when you are already running a Linux distro other than the firmware pogoplug distribution. In my case, I have my dockstar running on ArchLinux, but I wanted to try the new Debian Wheezy on it. At first try, it bombed out complaining of "kernel too old" from the log files. But when I   installed the Rescue Partition and installed wheezy again, it worked!
Posted by Roland at 2:36 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

Sunday, December 23, 2012

Pogoplug Security Camera

Pogoplug Security Monitoring System

Continuing on from our Raspberry Pi set-up of a streaming internet webcam, I have modified my setup to use a Pogoplug (or Dockstar, which is basically the same hardware) as my security camera system. The Pogoplug V2 Grey has a 1.2Ghz Marvel Kirkwood ARM9 processor while the Raspberry Pi has a 700Mhz Broadcom BCM2835 ARM176 core with hardware floating point. Basically the processing power of the Pogoplug is much more than the Raspberry Pi although graphically the Pi is much more capable with it's GPU.

But since my main purpose is to make a headless webcam security system (not plugged in to a TV or monitor), the Pogoplug is more suited for this application.

Here's a sample of the final output of my webpage:


















The top header is just a bunch of scripts I used to show the current temp, visitor info, current Winnipeg time and the time in Asia.

The webcam views are from local ports, but if you want this to be viewable from the internet, you would have to define routing tables using your router to route traffic from the internet port to a particular web stream.

In this case, if your pogoplug has an IP address of 192.168.1.99 and the webcam stream are from port 80 and 8080 (for each webcam), then you would have to define an incoming port (from the net, example port 88) and route it to local port of 192.168.1.99:80. If you have a DD-WRT router, you basically would have to just go to your router's IP (in my case 192.168.1.1) and pick the NAT/QoS tab, and setup Port From 88 to route to 192.168.1.99 and port 80...  This would mean, any reference to http://<youripaddress>:88 would automatically route to the pogoplug's port 80.



If your Internet service provider randomly assigns an IP address each time you connect to the net, you would need to know your new Internet IP address, but if you use a DNS redirector, you would just need to remember your website. 
In this example, I am using a free DNS redirector from DYNDNS to use the site <myfreesite>.gotdns.com and it is updated daily with my router's internet address. You can replace this with whatever web address you already have or subscribe to a free DNS redirector like DYNDNS. You can then automate your update to Dyndns by logging in to their site with your username/password and it will record your IP address as the address to go to whenever you logon.

DD-WRT has a DDNS tab that will automatically logon and update the DYNDNS table to your current IP.

 


Host name is your dynamic DNS website name, example: http://mywebsite.dyndns.com.

Here's a sample code form webpage:

Index.html

<!DOCTYPE HTML SYSTEM>
<html><head>
<title>Roland's webcams</title>
<meta http-equiv=refresh content="3600"></head><body>

<hr>
<table border="0"><tr>
<td>
<a href=http://myfreesite.gotdns.com:88/?action=stream>
<img src=http://myfreesite.gotdns.com:88/?action=stream height=260 width=360></a>
</td>
<td>
<a href=http://myfreesite.gotdns.com::89/?action=stream>
<img src=http://myfreesite.gotdns.com:89/?action=stream height=260 width=360></$
</td>

<td>
<a href=http://myfreesite.gotdns.com:90/?action=stream>
<img src=http://myfreesite.gotdns.com:90/?action=stream height=260 width=360></$
</td>
</tr>
</table>
<BR>


The first webcam grabs the output of my old NSLU2 (the predecessor of the Pogoplug) which is basically a NAS device that I reverted to a webcam server, while the latter two are hosted in my Pogoplug and runs two instances (actually 4, the other two are webcam image captures stored as JPGs) of MJPG-Streamer. 2 web services that serves the video stream (for each webcam) and 2 file streams that saves an image per second for the 2 webcams. The NSLU2 is not powerful enough to do image conversion (JPG to AVI) so I haven't been saving the stream.

The Pogoplug setup generates a webstream for each webcam (accessible from the internet from any device) and also a   jpeg of the image per second into a defined directory (cam1 and cam2). Every 2 hours, it shuts down the mjpg-streamer (using "pkill mjpg-streamer"), renames the cam directories  to camX-YYYY.MM.DD.hh.mm (X for the webcam number) and restarts the webcams/file streamer. Once it restarts the capture, it will then convert the renamed directory's JPG files to an AVI and when done, it zips the JPG into a file under the processed directory (deleting the jpgs in the process). After the zip process, it will delete the now empty camX-YYYY.MM.DD.hh.mm directory.

The JPG to AVI conversion is handled by ffmpeg and usually takes 40 minutes per camera. Zipping the files into a zip file takes around 5 minutes, so the basic processing time for both cameras is approximately 90 minutes. During those 90 minutes, any additional processing may push the processing time to conflict with the scheduled re-run of housekeeping.sh (i.e. a second instance of housekeeping.sh may run when the 90 minute process gets pushed beyond the 120 minute cron process). Since I made the pogoplug into a SAMBA server (use pacman to install SAMBA), I am able to go into the Pogoplug's drive from a Windows/Mac PC and copy the files (or watch the stored AVI) to my local machine. This eats up processing power from the Pogoplug, and if there was a huge file transfer process, housekeeping.sh may not have enough time to do all it's work within 120 minutes.

The default conversion is to an AVI file. Using better compression (MP4 format), it will take the Pogoplug more than an hour, so I opted to just zip the JPGs and convert those from a different PC as needed.



Basically my setup consists of:

1. Pogoplug Grey V2 (same as the more common Pogoplug Pink V2)
2. USB external portable 500GB hard drive
3. 2 pcs of Logitech Quickcam 9000 Pro webcams
4. Dlink Powerline Network adapter (or use a USB WIFI adapter/network port) - I'm using this because the location is a hard to reach.


The Pogoplug is running Arch Linux (the same version I installed in my Raspberry Pi), and I added the packages of mjpg-streamer, ffmpeg, and zip/unzip. (to install a Arch Linux Package, use pacman)

A great step-by-step instruction on how to install Arch Linux in a Pogoplug can be found here:
http://archlinuxarm.org/platforms/armv5/pogoplug-v2-pinkgray

After converting the Pogoplug to Arch Linux, just follow the same steps as with my previous posts on the Raspberry Pi Webcam server, but with modifications on the housekeeping.sh

housekeeping.sh:

#!/bin/bash
pkill mjpg_streamer
STRNAME1=cam1-$(date +%Y.%m.%d.%H%M)
STRNAME2=cam2-$(date +%Y.%m.%d.%H%M)
STRPATH1=/media/share/$STRNAME1
STRPATH2=/media/share/$STRNAME2
mv /media/share/cam1 $STRPATH1
mv /media/share/cam2 $STRPATH2
mkdir /media/share/cam1
mkdir /media/share/cam2
/usr/bin/mjpg_streamer  -i "input_uvc.so -d /dev/video0 -f 10 -r 960x720"\
  -o "output_http.so -p 80 -w /media/share/www"\
  -o "output_file.so -f /media/share/cam1 -d 1000"\
  -b
/usr/bin/mjpg_streamer  -i "input_uvc.so -d /dev/video1 -f 10 -r 960x720"\
  -o "output_http.so -p 8080 -w /media/share/www"\
  -o "output_file.so -f /media/share/cam2 -d 1000"\
  -b
for file in $STRPATH1/*.jpg; do
    printf -vsequenceImage $STRPATH1/%05d.jpg "$((++i))"
    [[ -e $sequenceImage ]] || \
        mv "$file" "$sequenceImage"
done
i=0
for file in $STRPATH2/*.jpg; do
    printf -vsequenceImage $STRPATH2/%05d.jpg "$((++i))"
    [[ -e $sequenceImage ]] || \
        mv "$file" "$sequenceImage"
done

ffmpeg -f image2 -i $STRPATH1/%05d.jpg /media/share/processed/$STRNAME1.avi

ffmpeg -f image2 -i $STRPATH2/%05d.jpg /media/share/processed/$STRNAME2.avi
zip -m /media/share/processed/$STRNAME1.zip $STRPATH1/*.jpg
rmdir $STRPATH1
zip -m /media/share/processed/$STRNAME2.zip $STRPATH2/*.jpg
rmdir $STRPATH2

The basic process is, at first run, kill all instances of MJPG-STREAMER, rename the cam1 and cam2 directory to a unique folder name, and then create a blank cam1 and cam2 directory. Launch MJPG-Streamer and store a picture every second. This process runs very quick so at most we only lose 1 second of video in the switch process. After that, the old cam1 directory is processed to rename all the files into a sequential file name convention, and the same is done for the cam2 directory.

The process takes a bit (approximately 5 minutes) and my old python script does this around 5 seconds, so I have yet to refine this step to make it run within the bash script.

The next step is to generate the AVI files from the JPG images, and this process takes around 40 minutes (each directory) and will probably eat around 70% CPU. However, this still leaves a bit more CPU muscle for basic stuffs like file copy, mpeg streaming and web services.

After the AVI generation process, the JPG files are zipped to a ZIP files and moved to the PROCESSED directory. The blank cam1 directory is then removed for a cleaner directory structure.



EDIT 6Mar2017: Here's my new script, using mencoder

#!/bin/bash
pkill mjpg_streamer
STRNAME1=pogoplug-$(date +%Y.%m.%d.%H%M)
STRDIR=/media/hdd/share/processed/$(date +%Y.%m)
if [ ! -d "$STRDIR" ]; then
   mkdir $STRDIR
fi
STRPATH1=/media/hdd/share/$STRNAME1
mv /media/hdd/share/cam1 $STRPATH1
mkdir /media/hdd/share/cam1
/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -d /dev/video0 -f 10 -r 1600x896"\
  -o "/usr/local/lib/output_http.so -p 80 -w /media/hdd/share"\
  -o "/usr/local/lib/output_file.so -f /media/hdd/share/cam1 -d 1000"\
  -b
if [ -f STRNAME1.txt ]
then
  rm STRNAME1.txt
fi
ls $STRPATH1/*.jpg > STRNAME1.txt
mencoder -nosound -mf fps=15 -o "$STRDIR/$STRNAME1.avi" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=8000 mf://@STRNAME1.txt
rm -r $STRPATH1


I've modified my original script to make it more faster and removed the secondary step of looping in files to rename it to a sequential number.. Since the files are sorted by date (ascending), I just generate the a text file with the names of the pictures, pass it to mencoder, which will generate the AVI file. The file name generated will have the current date and time so that I will know the sequence. I've removed the ZIP process as I do not need the old files, but you can put it back if you want (just copy the previous script)...
Posted by Roland at 10:20 AM 3 comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ▼  2024 (1)
    • ▼  February (1)
      • Raspi Mirror Kiosk setup
  • ►  2023 (1)
    • ►  January (1)
  • ►  2021 (1)
    • ►  April (1)
  • ►  2015 (2)
    • ►  December (1)
    • ►  February (1)
  • ►  2013 (1)
    • ►  February (1)
  • ►  2012 (3)
    • ►  December (1)
    • ►  October (1)
    • ►  September (1)

About Me

My photo
Roland
View my complete profile

Gadgets and Things

Awesome Inc. theme. Powered by Blogger.