Viewing a webcam with MPlayer in Linux

By | January 9, 2009

MPlayer has tons of other uses besides viewing video files. For example, you can view your webcam with it:

mplayer -cache 128 -tv driver=v4l:width=640:height=480:outfmt=i420 -vc rawi420 -vo xv tv://

5 thoughts on “Viewing a webcam with MPlayer in Linux

  1. Fotis

    I am sending you the result of issuing the command you tipped.

    $ mplayer -cache 128 -tv driver=v4l:width=640:height=480:outfmt=i420 -vc rawi420 -vo xv tv://
    MPlayer 1.0rc2-4.3.2 (C) 2000-2007 MPlayer Team
    CPU: Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz (Family: 6, Model: 15, Stepping: 13)
    CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
    Compiled with runtime CPU detection.
    Option msglevel: Unknown suboption 5
    Warning unknown option msglevel at line 5
    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.

    Playing tv://.
    Cache fill: 0.00% (0 bytes)
    TV file format detected.
    Selected driver: v4l
    name: Video 4 Linux input
    author: Alex Beregszaszi
    comment: under development
    =================================================================
    WARNING: YOU ARE USING V4L DEMUXER WITH V4L2 DRIVERS!!!
    As the V4L1 compatibility layer is broken, this may not work.
    If you encounter any problems, use driver=v4l2 instead.
    Bugreports on driver=v4l with v4l2 drivers will be ignored.
    =================================================================
    Selected device: Sirius USB2.0 Camera
    Capabilites: capture
    Device type: 1
    Supported sizes: 48×32 => 640×480
    Inputs: 1
    ioctl get channel failed: Invalid argument
    ioctl set chan failed: Invalid argument
    ioctl set chan failed: Invalid argument
    Error: Cannot set norm!
    Selected input hasn’t got a tuner!
    ioctl set picture failed: Invalid argument
    The ‘outfmt’ of ‘Planar I420’ is likely not supported by your card

    MPlayer interrupted by signal 11 in module: demux_open
    – MPlayer crashed by bad usage of CPU/FPU/RAM.
    Recompile MPlayer with –enable-debug and make a ‘gdb’ backtrace and
    disassembly. Details in DOCS/HTML/en/bugreports_what.html#bugreports_crash.
    – MPlayer crashed. This shouldn’t happen.
    It can be a bug in the MPlayer code _or_ in your drivers _or_ in your
    gcc version. If you think it’s MPlayer’s fault, please read
    DOCS/HTML/en/bugreports.html and follow the instructions there. We can’t and
    won’t help unless you provide this information when reporting a possible bug.

    Reply
  2. thugangel

    Fotis, use v4l2 instead of v4l. Also, dropping “-vc rawi420” would help.

    mplayer -cache 128 -tv driver=v4l2:width=640:height=480 -vo xv tv://

    Reply
  3. anmol rana

    i am using compulab’s cm-t3530 kit (Cortex-A8) running angstrom linux. Mplayer doesnt respond when i click on the gui.

    from command line i get the following error when i type what u said. i attach the logitech web came

    playing tv://
    cache fill :0.00% (0 bytes)
    tv file format detected
    selected driver v4l2
    name: video 4 linux 2 input
    author :Martin….
    comment : first try, more to come:
    v4l2:unable to open’/dev/video0′: no such file or directory
    v4l2:ioctl set mute failed:bad file descriptor
    v4l2: 0 frames successfully processed, 0 fames dropped

    regards

    Reply
  4. JajkoCK

    anmol rana: have you plugged in some camera device?
    “unable to open’/dev/video0?: no such file or directory” message tells that not. In other case, if you have /dev/video1 for example, you should to pass this information to a program like that:
    “(…)driver=v4l2:device=/dev/video1:(…)”

    Reply
  5. anmol rana

    i get this error

    playing tv://

    TV file format detected

    selected driver:v4l2

    name: Video 4 linux 2 input

    author : Martin Ol………

    comment: first try, more to come 🙂

    v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.

    selected device: camera

    capabilities: video capture read/write streaming

    supported norms:

    inputs: 0 = STV06xx;

    Current input : 0

    current format: unknown (0X47425247)

    tv.c:norm_from_string(pal):Bogus norm parameter, setting default

    v4l2: ioctl enum norm failed: Invalid argument

    Error: Cannot set norm!

    Selected input hasn’t got a tuner!

    v4l2: cannot get fps

    v4l2: ioctl set mute failed: Invalid argument

    v4l2: ioctl query control failed: Invalid argument

    v4l2: ioctl query control failed: invalid argument

    ——————————————————-

    cannot find codec matching selected -vo and video format 0X47425247

    ———————————————————

    v4l2: ioctl set mute failed: Invalid argument

    v4l2: 0 frames successfully processed, 0 frames dropped

    Exiting……. (end of file)

    thnks

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *