First, you will need RPi-Cam-Web-Interface installed and working on the pi(s) in question. To save yourself some hair-pulling, install this first, as their install script tends to kind of wipe out any existing server and web content you might have on your pi already. Shame on sloppy script writers, but it's so convoluted in there, I haven't fixed it. The install will wipe out for example /etc/nginx/sites-available/default. I prefer NGINX on pi's as I don't have a life invested in learning apache configuration, and it's faster and simpler by far. I did use the /html option for where to put the camera stuff, so I'd have the rest of /var/www for my own content. For example, one of my raspis has PHPBB running on it as kind of a super notepad for my private use! All the LAN of things ones also have their own content and CGI servers. The skinny on that can be found on the board elsewhere.
You will then need Samba on the pi (and on the other end if it's linux, which I'll assume for this, since it's all I run). You will need lines something like these at the end of /etc/samba/smb.conf:
- Code: Select all
[cam]
comment = camera on pi (use its network name for clarity)
browseable = yes
path = /var/www/html
guest ok = yes
read only = no
The above alone doesn't necessarily give write permissions to a guest if they aren't allowed at the pi end. Using the pi file browser, check and adjust permissions as required. In particular, the file /var/www/html/FIFO needs to be world-writable by anybody. I of course have added a few other shares to these pis, like for /home/pi/ and a public space on a big USB stick mounted on the filesystem. Makes it easier to remote-administer the pi in question. With TightVNC, you can have a remote GUI even on an otherwise headless pi (subject of another post, but run vncserver :1 from a terminal (or ssh) in the pi so you can put in a password before putting that command in say, /etc/rc.d or it'll never fly).
It works out that /var/www/html/FIFO is indeed a fifo, and it's the one raspimjpeg reads to get commands. Now that we have samba sharing that, we can send commands just like the web interface would do, but we don't need a browser to do that anymore, and of course, with code, if we needed to do say, 3 of them at a time (as I do) - it's now easy, no navigating and clicking required.
Here is example code in perl to do one of them - record for 10 seconds, which can run from some other machine on your LAN.
- Code: Select all
#!/usr/bin/perl
use warnings;
use strict;
use Filesys::SmbClient;
my $fh; # file handle
my $smb = new Filesys::SmbClient(username => "pi",password => "dotdot", workgroup => "MOUNTAIN");
print "starting\n"; # for user comfort - a sidetone
$fh = $smb->open(">smb://fusorpi/fcam/FIFO") or die "couldn't open FIFO $!";
$smb->write($fh, "ca 1") or die "couldn't write FIFO $!"; #ca 1 is the command to capture
$smb->close($fh);
print "sleeping\n"; # user comfort
sleep(10); # get ten seconds worth before we stop it
print "stop capture\n"; # stop it
$fh = $smb->open(">smb://fusorpi/fcam/FIFO") or die "couldn't open FIFO $!";
$smb->write($fh, "ca 0") or die "couldn't write FIFO $!";
$smb->close($fh);
print "done\n";
This does look quite a bit better when it's syntax-highlighted in say, gedit. Don't leave home without syntax highlighting!
It turns out that Filesys::SmbClient isn't in the standard perl distribution (no surprise). It also happens that cpanminus and friends won't install this correctly, as samba is now a later version than they know how to look for the includes for.
And, by default, samba doesn't even install the required header files at all,much less where they are expected. The simplest workaround is to just download the archive here: http://search.cpan.org/~alian/Filesys-S ... bClient.pm and then installing it manually, which makes it ask for where some of this stuff is. But first, you have to install ibsmbclient-dev to get the header file for the library at all! I use package manager for that. I've also installed "locate" on my machines, so a simple sudo updatedb will find whatever you need to find with a subsequent locate somecrap. You'll need to know where the libsmbclient stuff is to do the module install.
The module install is the usual manual perl thing. After extracting this somewhere, get a terminal there and do
perl Makefile.PL
make
sudo make install
Which won't work unless you do the above things first...
Once you've got this working, you can get the captured video files from /var/www/html/media - if you know what they are named, right now, it's a timestamp.mp4. You could just get *.mp4, and erase that directory before starting capture, or somehow set a name (probably needs some editing in the php or java to get that). I'm still working on doing that part programatically myself, but when I get it - and I will - I'll post it in a follow up to this thread. It might just be a simple script to mount the share and do a file copy..quick and dirty works too.