Archive Page 10
I’ve started a new project: a DSP tutorial for amateur radio enthusiasts (or anyone interested in encoding/decoding FSK, PSK etc. signals). The tutorial currently contains posts about how to generate a sine wave, how to calculate FFT, determining the dominant frequency, using different filtering methods and how to generate a single-sideband signal.
You can view the pages here.
Here’s how you can use a Leadtek DTV dongle mini USB DVB-T (or any RTL2832 based) adapter under Linux.
1. download and unpack latest v4l-dvb snapshot from http://linuxtv.org/hg/v4l-dvb to /usr/src/v4l-dvb
2. download the RTL2832U driver and unpack it to /usr/src/v4l-dvb/linux/drivers/media/dvb/dvb-usb
» …continue reading ‘Leadtek DTV mini dongle on Linux’
I made a few new widgets for Android using the Duke Nukem widget template. These are for those Hungarian users who are familiar with the original funny videos.
I’ve updated my webcam site, webcam.nonoo.hu. Now I’m using two Microsoft LifeCam Cinema webcams with 720p resolution, one in my window facing east and one on the roof facing west (this one is connected to my server using a 20m active USB extension cable).
The whole system which captures and processes images to a daily YouTube timelapse video is here:
It also contains udev files for webcam image controls and naming, cron.d file for generating the timelapse movie and the init.d script to start the auto image capture every half minutes. You can also use a wav file for background sound under the generated video. See this post.
I’m using a modified version of uvccapture for capturing images from the webcams. As these cams are high resolution ones, USB bandwidth limitations apply, so I can’t open them simultaneously. I grab a frame from one camera at a time. See the webcam-capture script on how I capture images from the cams.
Temperature data is taken from my temperature database. See this post.
The taken images won’t get uploaded to the webcam.nonoo.hu server, the server downloads the latest file from my home server when a client asks for it. This way my home server’s slow ADSL upload (80k/s…) won’t be used needlessly.
I’m using infinite focus, no white balance correction and auto exposure correction on my webcams. To set these settings, I’m using v4l2ctrl. It can export the current settings using v4l2ctrl -d /dev/video -s file, and after editing it can load it to the specified device: v4l2ctrl -d /dev/video -l file
I’m using this file for my Microsoft LifeCam Cinema webcams:
1 2 3 4 5 | 9963788:White Balance Temperature, Auto:0 10094858: Focus (absolute):0 10094860: Focus, Auto:0 10094861: Zoom, Absolute:0 10094849: Exposure, Auto:3 |
It gets loaded everytime the webcam is attached to the USB port with udev. The udev rules for my webcams are:
1 2 3 4 | # webcam kelet KERNELS=="1-8", SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="075d", NAME="video0", RUN+="/usr/bin/v4l2ctrl -d /dev/video0 -l /usr/local/webcam/kelet/v4l2ctrlsettings" # webcam nyugat KERNELS=="1-2.4.4", SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="075d", NAME="video1", RUN+="/usr/bin/v4l2ctrl -d /dev/video1 -l /usr/local/webcam/nyugat/v4l2ctrlsettings" |
I found out these udev patterns using udevadm info -a -p $(udevadm info -q path -n /dev/video).
I have a simple DIY lo-fi microphone on the pine tree in front of our house:
I record 20 sec long samples with it, every 4th hour. Then these wav files get mixed together to produce a 2 minute long output which I can use as a background sound under my automatic webcam timelapse videos.
Audio recording is done with sound-recorder, further processing is with sox in three steps:
- fading & padding: the end of the first file gets a fadeout, the beginning of the last file gets a fadein, other files get both fadeins and outs, then every file gets a silence in the beginning, length is calculated using: (filenum-1)*($lengt
h-5) - mixing: the first file gets mixed with the second, then this mix gets mixed with the third file and so on, they will be mixed together because of the previously applied padding
- normalizing, compressing and fading: after normalizing and compressing, it applies fadein to the beginning and fadeout to the end of the whole file
I’m using these scripts. webcam-recordsound is the cron file, you have to put it under /etc/cron.d, recordsounds start recording of a 20 sec long wav file, mixsounds mixes the recordings together and applies (audio) compression on them. common.sh contains the log function which I use in the scripts.
If you want to simulate device unplug and replug from software, use this tool:
usbreset /dev/bus/usb/001/006
(001 is the bus ID, 006 is the device ID, you can find these for your device using lsusb)
I’m using Microsoft LifeCam Cinema webcams, which support both YUYV and MJPEG capture modes. However, in YUYV mode, auto exposure correction doesn’t work correctly (or maybe at all). After resetting (or plugging out and in) a webcam, the exposure will be at max, and it won’t auto change if I use the YUYV mode. In MJPEG mode, it needs a few secs to compensate a light change.
So my changes in uvccapture-0.5:
- I added a -D
option to uvccapture for this. After opening the /dev/videoX device, it waits for the given predelay secs and then it captures the frame. This way when the camera is in MJPEG mode, it can auto change the exposure while uvccapture is predelaying. - Corrected JPEG header output, when saving MJPEG frames. The default routines in uvccapture saved an unreadable JPEG file, now it’s fixed.
- It parses output filenames with strftime, so this will save the full date in the filename: -o%Y%m%d%H%M%S.jpg
- Only saves JPEG when -o
is set - No auto YUYV capture, by default it uses MJPEG, if you want it, use the -m switch
- Resetting brightness/contrast/saturation/gain controls only when one of the regarding cmdline option is used
Merged the following modifications by Reece Arnott and John:
- changed the include statements in uvccapture.c and v4l2uvc.c from linux/videodev.h to linux/videodev2.h
- added the -i cmdline switch to have the ability to have an initializing script run before an image is captured (this means that -D option could be done with -w -i<script>
- predelay sleep optionally keeps taking 1 image/sec (-W cmdline switch)
- daemon feature with -b cmdline switch
- additional post delay option
Current version: uvccapture-0.5-nonoo-r4
Debian packages built by John:
I’m using uvccapture this way (to allow my Microsoft LifeCam Cinemas to auto adjust exposure):
uvccapture -v -d/dev/video -x1280 -y720 -D4
uvccapture -v -d/dev/video -x1280 -y720 -D3 -o%Y%m%d%H%M%S.jpg
(Yes, two sequential calls to uvccapture, one with 7 secs predelay is no go, I need two calls. The first call won’t save anything, just opens the device and waits given secs).
Just a note for myself :)
1 | ffmpeg -i %04d.jpg -f image2pipe -vcodec copy - | ffmpeg -r 4 -f image2pipe -vcodec mjpeg -i - -vcodec mpeg4 -vb 7000000 -an -y out.avi |
About me
I'm Nonoo. This is my blog about music, sounds, filmmaking, amateur radio, computers, programming, electronics and other things I'm obsessed with.
... »