Results 1 to 6 of 6

Thread: Disabling /dev/video0

  1. #1
    Join Date
    Dec 2009
    Beans
    19

    Disabling /dev/video0

    Hello,

    I have been looking around for a way to disable a video device through terminal. I have to webcams video0 and video1 which I need to disable through a script and re-enable at a later time.

    Any suggestions?

    Thanks in advance.

  2. #2
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Disabling /dev/video0

    Hi

    Quote Originally Posted by Lokie538 View Post
    Hello,

    I have been looking around for a way to disable a video device through terminal. I have to webcams video0 and video1 which I need to disable through a script and re-enable at a later time.

    Any suggestions?

    Thanks in advance.
    If it's a uvcvideo device then unload the uvcvideo module.

    Code:
    matthew@matthew-Aspire-7540 ~ % ls /dev/vid*
    /dev/video0
    matthew@matthew-Aspire-7540 ~ % sudo modprobe -r uvcvideo
    [sudo] password for matthew: 
    matthew@matthew-Aspire-7540 ~ % ls /dev/vid*             
    zsh: no matches found: /dev/vid*
    matthew@matthew-Aspire-7540 ~ % sudo modprobe  uvcvideo 
    matthew@matthew-Aspire-7540 ~ % ls /dev/vid*           
    /dev/video0
    matthew@matthew-Aspire-7540 ~ %
    That is one way for a uvc compatible video device.

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  3. #3
    Join Date
    Dec 2009
    Beans
    19

    Re: Disabling /dev/video0

    Thanks for the reply.

    What about if the device is in use and I only want to disable one of the two video devices?

    Sorry to be a pain.

  4. #4
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Disabling /dev/video0

    Hi

    What exactly do you mean by disable ?

    You can find out what has a lock on a video device node using lsof and terminate that program.

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  5. #5
    Join Date
    Dec 2009
    Beans
    19

    Re: Disabling /dev/video0

    Quote Originally Posted by matt_symes View Post
    Hi

    What exactly do you mean by disable ?

    You can find out what has a lock on a video device node using lsof and terminate that program.

    Kind regards
    Ok ill give you a quick run down on what Im trying to achieve and why. I have got zoneminder installed and its monitoring an IP camera and 2 web-cams. One of these web-cams is in my bedroom, where I don't want it to be functioning while I am home (as its my bedroom). So basically I want to create a perl script that checks if my phone or laptop is ping-able on the local network and if it is, turn one of the two webcams off.

    I had a look at some zone minder documentation and couldn't find a command to just turn a monitor off, so now I am investigating how to disable one of the two webcams through ubuntu itself.

    Any help towards my goal would be appreciated, but I will continue my search on google in the meanwhile.

  6. #6
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Disabling /dev/video0

    Hi

    What about unbinding the USB driver from the webcam ?

    I do not know whether this will work with a webcam but you should be able to test it quickly. I am also not sure how it will affect zoneminder as i have never used it.

    You can find the devices using the uvcvideo driver with....

    Code:
    ls -l /sys/bus/usb/drivers/uvcvideo/
    That is a small L above.

    Here is mine. I have one webcam highlighted with 2 functions.

    Code:
    matthew@matthew-Aspire-7540 ~ % ls -l /sys/bus/usb/drivers/uvcvideo/                        
    total 0
    lrwxrwxrwx 1 root root    0 May 16 17:25 2-5:1.0 -> ../../../../devices/pci0000:00/0000:00:13.2/usb2/2-5/2-5:1.0
    lrwxrwxrwx 1 root root    0 May 16 17:25 2-5:1.1 -> ../../../../devices/pci0000:00/0000:00:13.2/usb2/2-5/2-5:1.1
    --w------- 1 root root 4096 May 16 17:24 bind
    lrwxrwxrwx 1 root root    0 May 16 17:22 module -> ../../../../module/uvcvideo
    --w------- 1 root root 4096 May 16 17:22 new_id
    --w------- 1 root root 4096 May 16 17:22 remove_id
    --w------- 1 root root 4096 May 16 16:55 uevent
    --w------- 1 root root 4096 May 16 17:24 unbind
    matthew@matthew-Aspire-7540 ~ %
    The bus identifiers are highighted in bold.

    Unbind the device from the driver module with

    Code:
    echo '2-5:1.0' | sudo tee /sys/bus/usb/drivers/uvcvideo/unbind
    and rebind the device with

    Code:
    echo '2-5:1.0' | sudo tee /sys/bus/usb/drivers/uvcvideo/bind
    You will have a adjust yours with the correct bus identifier.

    Kind regards
    Last edited by matt_symes; May 16th, 2012 at 05:40 PM.
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •