Curtis Hall
posted this on August 10, 2010 20:04
Below is a technical overview for using our MPEG-4 and H.264 PCI / PCIe / Mini-PCI capture cards. First, you need to download the driver from Github:
Once the driver is loaded you will notice that there are two types of v4l2 devices created for each card. One device for the display port (also drives the single composite video output) that produces uncompressed YUV and one for each input that produces compressed video in either MPEG-4 or MJPEG.
We'll start with the display port device. As mentioned the display port is also shared with the RCA video output on the card. So, changing the display port layouts will also change the video output.
When loading the driver, a display port is created as the first device for that card. You can see in dmesg output something like this:
solo6010 0000:03:01.0: PCI INT A -> GSI 22 (level, low) -> IRQ 22 solo6010 0000:03:01.0: Enabled 2 i2c adapters solo6010 0000:03:01.0: Initialized 4 tw28xx chips: tw2864[4] solo6010 0000:03:01.0: Display as /dev/video0 with 16 inputs (5 extended) solo6010 0000:03:01.0: Encoders as /dev/video1-16 solo6010 0000:03:01.0: Alsa sound card as Softlogic0
This is for a 16-port card. The output for a 4-port card would show "Encoders as /dev/video1-4" and similarly for 8-port show /dev/video1-8.
The display port allows you to view and configure what is shown on the video out port of the card. The device has several inputs and depends on which card you have installed:
You do not have to open this device for the video output of the card to work. If you wanted to display channels 1-4 in 'quad view' on the display port you could simply change the inputs with V4L2 ioctl's or with mplayer:
mplayer tv://0/4
This is useful if you want to have live display to a CRT and use a simple program that rotates through the inputs (or multi-up virtual inputs) a few second intervals.
You can still use vlc, mplayer or whatever to view this device (you can open it multiple times).
Now for the encoder devices. There's one device for each physical input on the card. The driver will allow you to record MPEG-4 and MJPEG from the same device (but you must open it twice, one for each feed). The video format cannot be configured once recording starts. So if you open the device for MPEG-4 and full D1 resultion at 30fps, that's what you're going to get if you also open a simultaneous record for MJPEG.
However, it's good to note here that MJPEG will automatically skip frames when recording. This allows you to pipe the output to a network connection (e.g. MJPEG over HTTP) with no worry of the remote connection being overloaded on bandwidth.
Unlike any card before this supported by v4l2, our hardware compression cards produce containerless MPEG-4 frames. Most v4l2 applications expect some sort of MPEG-2 stream such as program or transport. Since these programs do not expect MPEG-4 raw frames, We are not aware of any that are capable of playing the encoders directly (much less being able to record from them). You can do something simple like 'cat /dev/video1' and pipe it to vlc, or write a program that just writes the frames to disk (most programs can play the raw m4v files produced from the driver).
Below is a mplayer example on how to play the first channels MJPEG feed:
mplayer -tv device=/dev/video1:outfmt=mjpeg tv://
Since most applications will want to record to disk, the easiest way is to write the video frames straight out to disk.
Now on to the audio. The cards produce what is known as G.723, which is a voice codec typically found on phone systems (especially VoIP).
Since Alsa currently doesn't have a format for G.723, the driver shows it as unsigned 8-bit PCM audio. We have sent a patch that was included in alsa-kernel (hopefully getting synced to mainline soon). But this only defines the correct format, it doesn't change the way you handle it at all. You must convert G.723-24 (3-bit samples at 8khz) yourself.
Comments
I'm not a linux driver guru so excuse me if this question seems off but is it possible to setup a rtmp stream or mpeg ts stream using this card?
Technically yes, but the transport application between the driver and the RTMP would need to support the MPEG-4 or H.264 that comes off the card. Gstreamer could work for this, but gstreamer need some modification to work with the stream that the card outputs.
Thanks
I'm not a Linux developer, is this something we could contract to develop a
Linux daemon to stream from your cards
We are pretty busy at the moment ourselves, but with a little work you could probably find a gstreamer developer who would take on the project.
Thanks
Robert, my company is composed of Linux devs who did what you're talking about on our own security apparatus using ffmpeg and Red 5 on a Ubuntu system. We set up two of them using a lower-end card (PV149), but based on the method we used, I'm certain it'll work on this one too. We'd be happy to set it up for you, send us a mail at sales@parthenonsoftware.com if you're interested and we can talk and get you a bid.
Curtis, feel free to let others know who want to do this if you guys are slammed. We did this as an in-house project, but we wouldn't mind recouping some of our research costs by doing this for other people who need this. Apologies for the shameless plug. ;)
I just got the latest git update. I am using the capture card in a Fedora based product. Currently it is using Fedora 14 and the kernel is 2.6.35 generation. It appears that the current minimum kernel supported by the driver is 2.6.37. Is this the case? Fedora 15 will be based on 2.6.38 but it will not be released until sometime in may. In the mean time, I only have the old driver. Is there a way to use the new driver with Fedora 14?
Is the brightness and contrast control working in the new driver?
My test bed for the latest driver is 2.6.32 kernel. If you are seeing a problem compiling or using it on 2.6.35, could you elaborate some more please?
I couldn't get videobuf-dms-config.c to compile because the structure videobuf_mapping did not contain the end or start fields. I tracked this change down to a commit to the 2.6.35 kernel. There are comments about changing vmalloc to vaddr.
===========================================
I also had missing field problems with struct videobuf_qtype_ops that were made in the 2.6.34 kernel. Some of the comments indicate that the functionality was largely duplicated in three different places so there was some shuffling around in the API to simplify it.
There are a lot of little changes. I am thinking of getting a new copy of videobuf-dma-config.c from the 2.6.35 kernel sources to try out all the changes at once.
Are you using the github sources? All of this is fixed in the current tree, which compiles with 2.6.32-2.6.38 in my builds.
Yes I was. The download comment said the tar ball was an optional download so I thought they were the same. I just grabbed the first one listed.
I downloaded the tarball bluecherrydvr-solo6x10-2.3.0-1-3-g8ef7c61.tar.gz and videobuf-dma-config.c still references the obsolete fields in the structure. I checked the sources from kernel.org. The start and end fields in 2.6.35.12 are still present. They are missing from the 2.6.38.2 kernel. Fedora back ports many driver related things. videobuf-core.h has the same structure as the 2.6.38.2 kernel.
struct videobuf_mapping {
unsigned int count;
struct videobuf_queue *q;
};
I will try the 2.6.38 version of the file.
Then I suspect you just need to adjust the kernel version checks in the current code that says to use those new APIs.
Dropping in the the 2.6.38 version of the videobuf-dma-conf.c worked. It required the kernel version test changes and a couple of type casts. The changes to the soloxxx.c files were very minor. This was done with Fedora 14 but these changes will probably work for Fedora 15 also.
I do not know what you license policy is. I don't think that I have any rights in these changes. So for whatever it is worth, I give you permission use these changes anyway you wish. I am not making any claims on these code changes as I consider them your property.
Ben,
Andy(Parthenon Software) and I have spent the last two weeks trying to get this working.
Initial try on a clearOS server (kernel 2.6.32) caused a system lockup with no error messages generated and req'ing a hard reboot.
Upgraded kernel (generic kernel.org 2.6.38.2) and tried again.....same result :(
Andy's feeling is that it's a hardware thing.....
My system :
Hardware Information
So .....what to do next.
Any great ideas???????
I am using an COTS rack mount PC with almost the same hardware (RealTech ethernet instread of Atheros). I am using the 4 port version of the card. I am using Fedora 14 now and have operated the card with Fedora 12 and Fedora 13. The original driver did not support control of brightness or contrast but I recently updated the driver which is now working with Fedora 14 (Kernel=2.6.35). (I had to make some minor adjustments to the driver (see previous posts).
I have never had a system lockup with the original SOLO driver or the updated SOLO driver.
The most common reason for a lockup that I have seen during development was a sever slow down in system performance when a memory leak swamped the swap drive space. This was not a true lock up but the system was so slow that trying to get a terminal open so that the bad application could be terminated was impractical.
strings /dev/video0 > /tmp/test.txt will crash the system
I have never heard of using this on a device node. What is
strings /dev/video0
supposed to do?
good question......something Andy was doing to I guess capture video0 settings? I'll look into this further ....
this is my dmseg log on boot if that gives any clues
......
Enabling Softlogic 6x10 Driver v2.3.0
solo6x10 0000:03:00.0: Probing Softlogic 6010
solo6x10 0000:03:00.0: PCI INT A -> GSI 20 (level, low) -> IRQ 20
solo6x10 0000:03:00.0: Enabled 2 i2c adapters
solo6x10 0000:03:00.0: Using NTSC video format
...
solo6x10 0000:03:00.0: Initialized 2 tw28xx chips: tw2865[1] tw2864[1]
solo6x10 0000:03:00.0: Display as /dev/video0 with 8 inputs (2 extended)
solo6x10 0000:03:00.0: Encoders as /dev/video1-8
solo6x10 0000:03:00.0: Alsa sound card as Softlogic0
I have been looking for an example for controlling the monitor port of the encoder card. It defaults to monitoring channel 1 but I need to switch to the other channels so I can monitor while I adjust video parameters.
I have seen V4L examples that involve setting up output buffers but that doesn't seem to fit the hardware. The compression card seem to be capable of connecting the input ports to the output monitor port internally. I haven't seen an example for operating a card of this type.
I have observed what seems to be an unequal distribution of the work load in the driver between the encoder video inputs. I was operating three port with a separate thread for each input. I monitored the file growth counting the byteused values from the V4L buffer information. I noticed that the file size for port 1 grows 3 times as fast as the file for port 3 and the file for port 2 grows twice as fast as the file for port 3. All ports are identically configured and processed sequentially by the same code so none is treated differently than any other.
I thought that this was an indication of thread starvation. I restructured the code so that all three ports were processed sequentially in one thread and observed the same behaviour.
This application is also monitoring the cameras live with a BT878 based capture card. This is one of the cheaper cards that has four inputs but only one capture circuit so it is only watching one camera a time. This is handled in an independent thread so it should have no impact on the performance on any particular recorder input.
I've transferred my efforts to using this card on an ubuntu server 11 setup. Did a git clone of the bluecherry source and ran make, make install as suggested in the readme. No errors encountered. rebooted but dmesg doesn't show solo drivers? Is this a dynamically loaded module or do I need to update-initramfs?
The driver should be loaded on startup, did you run 'sudo depmod -a'? Can you paste the output of lspci?
Do you have a code example for selecting which video input is monitored by the display port using V4L2?
is it possible to compile this driver under mips platform? I'm trying to use minipci card on Ubiquiti router station pro and openwrt with kernel 2.6.37.6
Andrew,
I'm not sure if it would compile or not, but I'm thinking it won't. We do not have access to any MIPS hardware.
Thanks
i'm trying compile but no success. :( Some defines missing. Now trying native compilation.
It's quite possible you will need to recompile that kernel with v4l2 and sound core enabled, among other things.
All this things compiled but i always get error in v4l2 section. Like this:
make KERNELDIR=../linux-2.6.37.6
make -C ../linux-2.6.37.6 M=/root/solo6x10 modules
make[1]: Entering directory `/root/linux-2.6.37.6'
CC [M] /root/solo6x10/solo6010-core.o
/root/solo6x10/solo6010-core.c: In function 'solo6010_pci_probe':
/root/solo6x10/solo6010-core.c:191: error: implicit declaration of function 'mdelay'
make[2]: *** [/root/solo6x10/solo6010-core.o] Error 1
make[1]: *** [_module_/root/solo6x10] Error 2
make[1]: Leaving directory `/root/linux-2.6.37.6'
make: *** [all] Error 2
missing include file <linux/delay.h> but on x86 debian lenny this driver build's fine. o_O
Do you have a linux x86 based mips cross-compiler and kernel headers I can use to help with that?
yes of course. I can give you access to our server. Or board access for native compilation.
If you could give me ssh access to the server and the compile directory, I can go from there.
Can you give me your email address? I send you all information about connection.
This thread is getting rather long. Please create new posts for any questions:
http://support.bluecherrydvr.com/forums/214485-hardware-compression...