Forums/Bluecherry BC- series driver support/FAQ

Using the Bluecherry hardware compression open source Linux drivers (MPEG-4 / H.264)

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:

  • 4-port: 1 input per port and 1 virtual input for all 4 inputs in 4-up mode.
  • 8-port: 1 input per port and 2 virtual inputs for 4-up on inputs 1-4 and 5-8 respectively.
  • 16-port: 1 input per port and 5 virtual inputs for 4-up on inputs 1-5, 5-8, 9-12 and 13-16 and 1 virtual input for 16-up on all inputs.


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

User photo
Robert Watson

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?

March 20, 2011 20:55.
User photo
Curtis Hall
Bluecherry

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

March 21, 2011 09:18.
User photo
Robert Watson

I'm not a Linux developer, is this something we could contract to develop a 
Linux daemon to stream from your cards 

March 21, 2011 19:24.
User photo
Curtis Hall
Bluecherry

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

March 21, 2011 19:25.
User photo
Andy Schmitt

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. ;)

March 28, 2011 12:30.
User photo
RogerOdle

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?

April 05, 2011 13:58.
User photo
Ben Collins
Bluecherry

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?

April 06, 2011 10:31.
User photo
RogerOdle

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.

===========================================

  V4L/DVB: v4l videobuf: rename videobuf_queue_to_vmalloc to videobuf_queue_to_vaddr

Ths function returns the virtual kernel address of the buffer and has
nothing to do with allocation.
================================

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.

April 06, 2011 11:56.
User photo
Ben Collins
Bluecherry

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.

April 06, 2011 12:48.
User photo
RogerOdle

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.

April 06, 2011 13:06.
User photo
RogerOdle

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.

April 06, 2011 13:34.
User photo
Ben Collins
Bluecherry

Then I suspect you just need to adjust the kernel version checks in the current code that says to use those new APIs.

April 06, 2011 13:38.
User photo
RogerOdle

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.

April 07, 2011 15:27.
User photo
Robert Watson

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

Processors 4
Model Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz
CPU Speed 2 GHz
Cache Size 2.00 MB
System Bogomips 21333.86
PCI Devices
- Audio device: Intel Corporation N10/ICH 7 Family High Definition Audio Controller
- Ethernet controller: Atheros Communications AR8131 Gigabit Ethernet
- Ethernet controller: VIA Technologies, Inc. VT6105M [Rhine-III]
- Host bridge: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller
- IDE interface: Intel Corporation N10/ICH7 Family SATA IDE Controller
- ISA bridge: Intel Corporation 82801GB/GR
- Multimedia video controller: Bluecherry BC-08240A 8 port MPEG4 video encoder / decoder
- Network controller: Atheros Communications Inc. AR5008 Wireless Network Adapter
- PCI bridge: Intel Corporation 82801 PCI Bridge
- PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 1
- PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 2
- SMBus: Intel Corporation N10/ICH 7 Family SMBus Controller
- USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #2
- USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #3
- USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #4
- USB Controller: Intel Corporation N10/ICH 7 Family USB2 EHCI Controller
- USB Controller: Intel Corporation N10/ICH7 Family USB UHCI Controller #1
- VGA compatible controller: Intel Corporation 82G33/G31 Express Integrated Graphics Controller
IDE Devices none
SCSI Devices
- ATA External Disk 0 (Direct-Access)
- ATA Maxtor 6V320F0 (Direct-Access)
- ATA Maxtor 6V320F0 (Direct-Access)
- HL-DT-ST DVDRAM GH24NS50 (CD-ROM)
USB Devices
- (4x) Linux Foundation 1.1 root hub
- Linux Foundation 2.0 root hub

So .....what to do next.

  1. rebuild system on new hardware.....
  2. try bluecherry software and if it works then hardware ok, driver bad for this  system config

Any great ideas???????

April 13, 2011 18:29.
User photo
RogerOdle

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.

April 13, 2011 18:44.
User photo
Robert Watson


strings /dev/video0 > /tmp/test.txt will crash  the system

April 13, 2011 19:26.
User photo
RogerOdle

I have never heard of using this on a device node.  What is

strings /dev/video0

supposed to do?

April 13, 2011 19:31.
User photo
Robert Watson

good question......something Andy was doing to I guess capture video0  settings?  I'll look into this further ....

April 13, 2011 19:33.
User photo
Robert Watson

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

April 13, 2011 21:15.
User photo
RogerOdle

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.

April 14, 2011 16:06.
User photo
RogerOdle

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.

April 18, 2011 16:43.
User photo
Robert Watson

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? 

May 17, 2011 19:02.
User photo
Curtis Hall
Bluecherry

The driver should be loaded on startup, did you run 'sudo depmod -a'?  Can you paste the output of lspci?

May 17, 2011 19:09.
User photo
RogerOdle

Do you have a code example for selecting which video input is monitored by the display port using V4L2?

May 19, 2011 19:46.
User photo
Andrew

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

May 31, 2011 05:18.
User photo
Curtis Hall
Bluecherry

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

May 31, 2011 16:57.
User photo
Andrew

i'm trying  compile but no success. :(  Some defines missing. Now trying native compilation.

June 01, 2011 00:36.
User photo
Ben Collins
Bluecherry

It's quite possible you will need to recompile that kernel with v4l2 and sound core enabled, among other things.

June 01, 2011 07:07.
User photo
Andrew

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

June 02, 2011 01:24.
User photo
Ben Collins
Bluecherry

Do you have a linux x86 based mips cross-compiler and kernel headers I can use to help with that?

June 02, 2011 08:05.
User photo
Andrew

yes of course. I can give you access to our server. Or board access for native compilation.

June 06, 2011 00:02.
User photo
Denis Fedorov
Hey guys.
If you get result with compile driver on MIPS, let me know.
It is very important for me.
June 07, 2011 09:59.
User photo
Ben Collins
Bluecherry

If you could give me ssh access to the server and the compile directory, I can go from there.

June 07, 2011 10:54.
User photo
Andrew

Can you give me your email address?  I send you all information about connection.

June 20, 2011 01:48.
User photo
Curtis Hall
Bluecherry

This thread is getting rather long.  Please create new posts for any questions:

http://support.bluecherrydvr.com/forums/214485-hardware-compression...

June 20, 2011 16:07.