Chapter 8.  Stream from an acquisition card or a webcam

Table of Contents

Install the Video for Linux drivers
Stream with VLC
Stream with VLS

Note

This is possible under GNU/Linux only.

Install the Video for Linux drivers

If you want to stream from an acquisition card or a webcam, a video4linux driver must be available for it. You can find more information about video4linux and supported devices here.

Compile the right module for your device, and insert it into your kernel (Some video4linux modules are shipped with the 2.4.x Linux kernels). You can test your device by using any of the listed programs in the Video: TV and PVR/DVR section of this page.

Note that v4l2 modules will also work with VLC.

Stream with VLC

Note

You must add --enable-v4l to ./configure to use this feature.


% vlc -vvv v4l:/dev/video:norm=secam:frequency=543250:size=640x480:channel=0:adev=/dev/dsp:audio=0
--sout '#transcode{vcodec=mp4v,acodec=mpga,vb=3000,ab=256,vt=800000,keyint=80,deinterlace}:std{access=udp,mux=ts,url=239.255.12.13}' --ttl 12

where:

  • /dev/video is the device corresponding to your acquisition card or your webcam,

  • norm=secam is name of the standard of the analogic signal (possible values are pal, secam, and ntsc),

  • frequency=543250 is the frequency of the channel in kHz (Warning : for VLC < 0.6.1, Frequency is channel frequency in MHz multiplied by 16),

  • size=640x480 is the size of the video you want (you can also put the standard size like subqcif (128x96), qsif (160x120), qcif (176x144), sif (320x240), cif (352x288) or vga (640x480)),

  • channel=0 is the number of the channel (usually 0 is for tuner, 1 for composite and 2 for svideo),

  • adev=/dev/dsp is the audio device,

  • audio=1 is the number of the audio channel (usually 0 is for mono and 1 for stereo),

  • vcodec=mp4v is the video format you want to encode in (mp4v is MPEG-4, mpgv is MPEG-1, and there is also h263, DIV1, DIV2, DIV3, I420, I422, I444, RV24, YUY2),

  • acodec=mpga is the audio format you want to encode in (mpga is MPEG audio layer 2, a52 is A52 i.e. AC3 sound),

  • vb=3000 is the video bitrate in Kbit/s es el bitrate de vídeo en Kbit/s ,

  • ab=256 is the audio bitrate in Kbit/s

  • vt=800000 is the video bitrate tolerance in bit/s,

  • keyint=80 is the maximum interval between two "I" images in number of images,

  • deinterlace tells VLC to deinterlace the video on the fly,

  • 192.168.0.42 is either:

    • the IP address of the machine you want to unicast to;

    • or the DNS name the machine you want to unicast to;

    • or a multicast IP address.

  • 12 is the value of the TTL (Time To Live) of your IP packets (which means that the stream will be able to cross 11 routers).

Stream with VLS

Note

You need the SVN version of VLS. When you compile it, you must do a ./bootstrap and ./configure --enable-v4l --with-ffmpeg=PATH (where PATH is the absolute path to the directory where you compiled ffmpeg, and not the relative path !).

There is no command line interface for this input for the moment, so you will have to use the configuration file.

Here is a typical configuration file vls.cfgto run VLS with a v4l device:

# vls.cfg (VLS configuration file)
# Example of the VideoLAN HOWTO for the Video for Linux input

BEGIN "Inputs"

  webcam       = "v4l"

END

BEGIN "webcam"

  # V4L device
  Device        = "/dev/video"

  # Channel Source : Webcam is often "0"
  #                  TV Card, may be Tuner(0), Composite(1), Svideo(2)
  Channel       = "0"

  # Norm: PAL=0, NTSC=1, SECAM=2
  Norm          = "0"

  # Frequency of the channel in Mhz, multiplied by 16 (tuner cards only)
  Frequency     = "7668"

  # Size possibilities: can be either:
  # - empty string : default size
  # - width x height
  # - subQCIF(128x96), QSIF(160x120), QCIF(176x144), SIF(320x240),
  #   CIF(352x288), VGA (640x480)
  Size          = ""

  # DeInterlace: "0" = no ; "1" = yes
  DeInterlace   = "0"

  # Video compression format: "mpeg1" or "mpeg4"
  Compression   = "mpeg4"

  # Video bitrate (approx.) in kbps
  Bitrate       = "500"

  # Quality: "1.0" (good) to "31.0" (bad)
  Quality       = "1.0"

  # Sound device
  AudioDevice   = "/dev/dsp"

  # Audio compression format: "mp2", "mp3" or "ogg"
  AudioCompression = "mp2"

  # Audio bitrate in kpbs
  AudioBitrate  = "64"

  # Audio frequency ("16000", "22050", "24000", "32000", "44100" or "48000")
  AudioFreq     = "16000"

  # Audio channel: "1" = mono ; "2" = stereo
  AudioChannel  = "2"

END

BEGIN "Channels"

  channel1       = "network"

END

BEGIN "channel1"

  # Unicast or multicast IP address
  DstHost = "192.168.0.42"

  # Destination port
  DstPort = "1234"

  # If it's a multicast IP address, uncomment the line below
  #Type    = "multicast"

  # If it's a multicast IP address, set the "Time To Live" below
  #TTL     = "12"

END

BEGIN "LaunchOnStartUp"

  command1 = "start video channel1 webcam"

END

Once you have adapted the configuration file above, run VLS:

% vls -vv -f vls.cfg