1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Webcam programs working with webcamd in FreeBSD

Discussion in 'Porting New Software' started by Chuchubi, Jun 18, 2010.

  1. Chuchubi

    Chuchubi New Member

    Messages:
    30
    Likes Received:
    0
    Some time ago a lot of people where complaining about FreeBSD not having the possibility to use a webcam. Okay, we had a gspca driver and some other drivers but only for v4l1 and most of them don't work anymore. Now we have webcamd and v4l2 and we (The FreeBSD people) can take advantage of that. Webcamd have a lot of drivers and also the important UVC driver. There are a lot of programs that are working with a webcam on linux and now these programs can work on FreeBSD. I have succesfully compiled and run the following programs on FreeBSD:

    wxcam
    guvcview
    effectv
    luvcview
    uvcview
    mplayer
    mencoder
    mjpg_streamer
    uvc_streamer
    camorama
    camserv
    motion
    xawtv
    zoneminder

    I have screenshots of this programs running on FreeBSD 8.0 release. For more information, go to http://www.rockafunk.org/

    Making ports of all of this programs can easy be done. I already have the patches. Any help is welcome.
     
  2. zeiz

    zeiz New Member

    Messages:
    691
    Likes Received:
    0
    Tried to get my Logitech webcam working with webcamd and cuse4bsd but no luck :(
     
  3. Chuchubi

    Chuchubi New Member

    Messages:
    30
    Likes Received:
    0
    Can you be more specific what is not working? Can you post some error messages. How did you install webcamd? There is a port of webcamd and you also need to install v4l_compat and libv4l. Do /dev/video0 exist?
     
  4. adamk

    adamk New Member

    Messages:
    1,624
    Likes Received:
    0
    mplayer and vlc work here. Skype and flash are still non-functioning (just gives green static). At least when I last tried about 2 weeks ago.

    Adam
     
  5. Chuchubi

    Chuchubi New Member

    Messages:
    30
    Likes Received:
    0
    I have tried skype but no luck yet. For the video in skype to work, some patching need to be done in the kernel source. Skype on FreeBSD work under linux emulation and I think the patches only work only the pwc driver. The patches can be found at http://opal.com/freebsd/sys/compat/linux/.
     
  6. sk8harddiefast

    sk8harddiefast Member

    Messages:
    2,008
    Likes Received:
    3
    Me too. Same problem with Zeiz. If i remember right it was refused to see camera on usb port or something like that.
     
  7. Chuchubi

    Chuchubi New Member

    Messages:
    30
    Likes Received:
    0
    Do /dev/video0 exists? How do you start webcamd? First you need to load cuse4bsd by doing kldload cuse4bsd Then do a dmesg in a terminal to find out the ugen number. My logitec camera gives "ugen4.3".

    Load webcamd like this:
    # As root or use sudo

    webcamd -d ugen4.3 -i 0 -v 0

    Also change the permissions of your video device.
    # As root or use sudo

    chmod 666 /dev/video0

    Test with pwcview:

    pwcview
     
  8. Chuchubi

    Chuchubi New Member

    Messages:
    30
    Likes Received:
    0
    Install webcamd instructions

    I see that some people have problems installing webcamd. I like to help so I have written here how I have done it.

    Get the latest port tarballs for v4l_compat, libv4l, pwcview and webcamd.
    Also get the cuse4bsd source.
    Just follow the instructions to do that.
    ######################################################################

    http://www.freebsd.org/cgi/cvsweb.cgi/ports/multimedia/v4l_compat/

    Code:
    tar xvzf v4l_compat.tar.gz
    
    cd v4l_compat
    
    sudo make install
    ----------------------------------------------------------------------

    http://www.freebsd.org/cgi/cvsweb.cgi/ports/multimedia/libv4l/

    Code:
    tar xvzf libv4l.tar.gz
    
    cd libv4l
    
    sudo make install
    ----------------------------------------------------------------------

    http://www.freebsd.org/cgi/cvsweb.cgi/ports/multimedia/pwcview/

    Code:
    tar xvzf pwcview.tar.gz
    
    cd pwcview
    
    sudo make install
    ----------------------------------------------------------------------

    Get cuse4bsd and install it

    Code:
    svn --username anonsvn --password anonsvn checkout svn://svn.turbocat.net/i4b/trunk/usbcam/cuse4bsd
    
    cd cuse4bsd
    
    sudo make all install
    ----------------------------------------------------------------------

    http://www.freebsd.org/cgi/cvsweb.cgi/ports/multimedia/webcamd/

    Code:
    tar xvzf webcamd.tar.gz
    
    cd webcamd
    
    sudo make install
    ----------------------------------------------------------------------
    # restart devd

    Code:
    sudo /etc/rc.d/devd restart
    ----------------------------------------------------------------------
    Code:
    sudo kldload cuse4bsd
    ----------------------------------------------------------------------
    # Plugin your webcam and find out the ugen it is using.

    Code:
    dmesg
    # If it is ugen4.2

    Code:
    webcamd -d ugen4.2 -i 0 -v 0
    # If it is ugen2.2

    Code:
    webcamd -d ugen2.2 -i 0 -v 0
    # change permission of device
    # You can also do that with /etc/devfs.rules
    # add path 'video*' mode 0666

    Code:
    sudo chmod 666 /dev/video
    # Test

    Code:
    pwcview
    I hope this helps.
     
  9. sk8harddiefast

    sk8harddiefast Member

    Messages:
    2,008
    Likes Received:
    3
    I give a try again :)
     
  10. zeiz

    zeiz New Member

    Messages:
    691
    Likes Received:
    0
    Actually tried Skype :)
    Anyway:
    Code:
    $ pwcview
    Warning short read, got only 6174 of 115200 bytes
    .................................................
    "Green box" and multiple warnings like above.

    Code:
    $ ls -l /dev/video0
    crw-rw-rw-  1 root  operator    0, 138 Jun 19 21:54 /dev/video0
    /etc/rc.conf
    Code:
    webcamd_enable="YES"
    /boot/loader.conf
    Code:
    cuse4bsd_load="YES"
    pwc_load="YES"
    Code:
    $ ls /var/db/pkg | grep v4l
    libv4l-0.6.4
    v4l_compat-1.0.20100403_1
    
    /etc/devfs.conf
    Code:
    perm   video0   0666
    Code:
    # webcamd -d ugen2.2 -i 0 -v 0
    Webcamd is already running for ugen2.2.0
    
    Ports were up-to-date
     
  11. Chuchubi

    Chuchubi New Member

    Messages:
    30
    Likes Received:
    0
    Hi zeiz, if your webcam supports the pwc driver you should only load that driver. If you put
    Code:
    webcamd_enable="YES"
    in your rc.conf the webcamd driver will load on boot. And when you then do
    Code:
    webcamd -d ugen2.2 -i 0 -v 0
    you load the driver for the second time. Do not load the pwc driver and webcamd together.
     
  12. zeiz

    zeiz New Member

    Messages:
    691
    Likes Received:
    0
    Understandable. I just shown that webcamd is loaded.
    However
    Did you mean that webcamd will be loaded by pwc driver and thus no need in webcamd_enable="YES" in /etc/rc.conf?
     
  13. adamk

    adamk New Member

    Messages:
    1,624
    Likes Received:
    0
    pwc is a driver for specific webcams.. webcamd + cuse4bsd should be used for webcams *not* supported by pwc.

    Adam
     
  14. zeiz

    zeiz New Member

    Messages:
    691
    Likes Received:
    0
    Thanks but how could you comment this:
    ? cuse4bsd loaded, webcam loaded and then pwcview started. But you said that pwc is only for some webcams. Did you mean that for other webcams cuse4bsd+webcamd must be loaded to make pwcview working? And for those supported by pwc no need in both cuse4bsd and webcamd?
    Sorry if I'm really dumb today :)
     
  15. adamk

    adamk New Member

    Messages:
    1,624
    Likes Received:
    0
    There is the pwc driver (for specific webcams) and then there is the pwcview program, which is not specific to the pwc driver.

    Adam
     
  16. Chuchubi

    Chuchubi New Member

    Messages:
    30
    Likes Received:
    0
    pwcview

    You are right. The program pwcview is just a program to view /dev/video0. The driver does not matter for pwcview. The pwc driver however is just for webcams supporting this driver. If you dont have such a webcam you dont have to load the pwc driver. So you are right!
     
  17. zeiz

    zeiz New Member

    Messages:
    691
    Likes Received:
    0
    So, assuming that pwcview works for both following cases, should I use webcamd + pwc if my webcam supported and webcamd + cuse4bsd othewise?
     
  18. adamk

    adamk New Member

    Messages:
    1,624
    Likes Received:
    0
    Wow, you really are having a hard time with this:

    If your card is supported by the pwc driver, use it (do not use webcamd). If it's not supported by the pwc driver use cuse4bsd+webcamd.

    Adam
     
  19. zeiz

    zeiz New Member

    Messages:
    691
    Likes Received:
    0
    I left the wedding right after 4 a.m but they finished at 7:30 :)
     
  20. lme@

    lme@ Administrator Staff Member Developer

    Messages:
    617
    Likes Received:
    7
    Chuchubi: Do you plan to create some PRs with the patches, so they get into the ports collection?
     
  21. zeiz

    zeiz New Member

    Messages:
    691
    Likes Received:
    0
    Got it working. Thanks, Chuchubi!
    A couple of problems are here.
    First video0 looks always being created under root credentials and editing of /etc/defaults/devfs.rules or /etc/devfs.rules or /etc/devfs.conf doesn't work here. Only chmod works for given session.

    Second: during boot webcam first fails to start:
    Code:
    Starting webcamd
    /libexec/libexc/ld-elf.so.1: Shared object libcuse4bsd.so.1 not found required by "webcamd"
    /usr/local/etc/rc.d/webcamd: WARNING: failed to start webcamd
    ELF ldconfig path: ..... /usr/local/lib ....
    However
    Code:
    find / -name libcuse4bsd.so.1
    /usr/local/lib/libcuse4bsd.so.1
    
    Nevertheless webcamd starts later. I am on 9-current, it could be the -current problem.

    Skype (tarball: skype_static-2.0.0.72-oss.tar.bz2) doesn't work yet: both video and audio.
    On Linux same webcam works fine.
     
  22. Chuchubi

    Chuchubi New Member

    Messages:
    30
    Likes Received:
    0
    I would like to create the ports but I have to do a lot of reading and that may take some time. My experience with writing a port from scratch is very little at the moment. I have edited and upgraded some existing ports that were left alone by the maintainers. That is why any help is welcome. If you want to help I will send you the patches. Just let me know.
     
  23. lme@

    lme@ Administrator Staff Member Developer

    Messages:
    617
    Likes Received:
    7
    Great, just send me your patches and I'll take a look at it.
     
  24. Chuchubi

    Chuchubi New Member

    Messages:
    30
    Likes Received:
    0
    patches

    I will send you the patches this weekend. Thanks!
     
  25. lme@

    lme@ Administrator Staff Member Developer

    Messages:
    617
    Likes Received:
    7
    Sorry, I haven't found the time to take a look at it... :(
    You can also send them to multimedia@freebsd.org so a lot of people can see it.