Linux Video Capture

If you have a TV tuner card with AV-IN feature. You just need to plug in the Video-in cable (from whatever device) into the card and it does the work. Now, how can one see the video output of this card on linux ?

I thought their might be someway to do so using any player (like MPlayer), of course there will be some setup or configuration needed. After a while of searching and experimenting I got it :

First you need V4L and MPlayer (I think VLC works too)

Usually, you will find all of them with your distribution (If v4l was missing you can try compiling it from source)

  1. First install v4l, v4l-tools(xawtv) with its dependencies.

    Now, an Important check to do is to try

    # mplayer tv://

    Maybe it will work as desired or maybe it will read the card but show you an input that you don't want if so then see MPlayer output recognized that your card have multiple inputs available and try this

    # mplayer tv:// -tv driver=v4l2:input=1

    And substitute that "1" with the desired input ID or try them all to find it out.
    You may need to add a device path to v4l options according to your system it may be /dev/video0 or any thing similar so it would be like

    # mplayer tv:// -tv driver=v4l2:device=/dev/video0:input=3

    If this check didn't succeed continue to next step...

  2. Here comes the variable part ...
    Note: this configuration helped with my LifeView FlyTV Prime 30FM. You should search for your card model here : LinuxTV Wiki Homepage -- This should give you the proper module name (to replace saa7134 if it is not suitable for your card) and the card id number.

    Now, in shell, type :

    # lsmod | grep saa7134

    If there is an output for this we need to remove (unload) the module to insert it again with proper options

    # rmmod saa7134

    Then (or if no output for lsmod above) We insert the module with the options from

    # modprobe saa7134 card=2 tuner=39
  3. Then run this
    # mplayer tv:// -tv driver=v4l2:device=/dev/video0:input=3:amode=1

    Note: according to ur card u may need to adjust different settings (i.e. device=/dev/video1:input=0/adevice=bla/bla)

  4. Now you should be able to watch, but .. what about the capture ?
    Capturing video using MEncoder (MPlayer's brother) is not very different .. The following encodes 30 minutes of video only to an avi file using MPEG2.
    #  mencoder tv:// -tv driver=v4l2:device=/dev/video0:input=3 -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=800000:vqscale=0  -of avi -o epesode1.avi -endpos 00:30:00

    Adding some audio encoding options will, in normal cases, record audio too, there is an example of such options with the next command.

    In some cases the audio input in the card won't work (this happened with me) and as you know, usually, people don't like to watch videos that don't have any sound, so here is a solution (that suited me) to record the audio with the video (there may be easier ones that suits your hardware and configuration) :

    1. Plug the two AV-IN audio cables into one of the capture devices of the sound card (Mic or Line-in)
    2. Choose that device the capture device of alsa (supposing you are already using alsa, which is the common case), you can use alsamixer to do so.
    3. Use this command
      #  mencoder tv:// -tv driver=v4l2:device=/dev/video0:input=3:alsa:adevice=hw.0,0:immediatemode=0 -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=800000:vqscale=0 -oac mp3lame -lameopts cbr:br=96 -of avi -o epesode1.avi -endpos 00:30:00

      Change encoding options to suit you, also consider removing immediatemode option if things are good without it (it should be used if there is a problem without it)

I posted about this on Frihost forums a while ago.


Capturing video with mencoder

Thanks Mahmoud! After looking at various websites, none that offered solutions that worked yours worked first time! I like the way you got the video capture to work first using mplayer then progressing onto using mencoder for the recording. You should be a teacher. What was missing from my code was the input=1.


Glad I could Help

You are most certainly welcome, and thanks for your kind words.