RecordingInfo - Freevo Wiki
Keywords: Recording, Info

| RecordingInfo | UserPreferences

Freevo Wiki | FrontPage | RecentChanges | TitleIndex | WordIndex | SiteNavigation | HelpContents

# 1 Below Here is for 1.4.x Series

## 1.1 Intro

There are three different types of Freevo Recording. Tv Line In, Btaudio and ivtv. The first two depend on using the bttv module for your tv card. The third is for use only with the ivtv module for the wintv PVR type cards.

## 1.2 Btaudio

This process using the sound from btaudio kernel module and the pictures from your bttv module. This is the preffered freevo setup for recording and the default settings in VCR_CMD reflect this.

This setup is problematic though since not all cards support btaudio and some cards only thought to work in certain configurations. Btaudio setup is its own topic and help can be found here.

Once you have that setup you can change the default VCR_CMD's adevice to point to it.

This is also the best setup for doing timeshifting, thus it is reccomended to really try hard to get this setup to work for you.

## 1.3 TV Line In

### 1.3.1 description

This process using the line out sound from your tv card into the line in of your sound card for the sound and bttv for your pictures. This is a common bttv setup.

It has a couple inherit problems. First you will hear the program in the background when you are recording. And Second, You cannot run any apps that use the soundcard while recording(which pretty rules out everything except images and maybe running some scripts in commands plugin).

Another problem is that depending on your sound system you have to do different things to setup the recording.

VIA USERS: Note that if you have a VIA-based on-board sound card, you should uninstall the current drivers in your system and install the appropriate drivers found at http://www.viaarena.com . Then increase your IGain setting on your audio mixer to something greater than zero (ie: # aumix -l 0 -l R -i 35).

### 1.3.2 OSS instructions

Typically you need to use something like the following to mute and unmute the audio:

    # to unmute the audio
    aumix -l 80 -l R

    # to mute the audio
    aumix -l 0

Unfortuneately some Sound Blaster cards also need another variable tweaked when used with OSS. The soundblasters cards need and extra parameter (IGAIN) added to the aumix calls. for example:

    # to unmute the audio
    aumix -l 80 -l R -i 1

    # to mute the audio
    aumix -l 0 -i 0

Another variable that needs to change in the VCR_CMD is the adevice to /dev/dsp. You can do this by changing your VCR_CMD to a script setup similar to one here. (One good thing about controling recording from a script is that it makes it easy to experiment from the command line.) Or to change the VCR_CMD to include a 'soundonscript ;' + at thefront of the command and a '; soundoffscript' at the end.

    #example for an older pre tv:// syntax mencoder
    VCR_CMD = ( 'aumix -l 80 -l R; '+
                CONF.mencoder + ' ' +
                '-tv on:driver=v4l:input=0' +   # Input 0 = TV, Input 1 = Comp. V. in
                ':norm=%s' % CONF.tv +
                ':channel=%(channel)s' +         # Filled in by Freevo
                ':chanlist=us-cable' +          # Change
                ':width=%d:height=%d' % (TV_REC_SIZE[0], TV_REC_SIZE[1]) +
                ':outfmt=%s' % TV_REC_OUTFMT +
                ':device=%s' % TV_DEVICE +
                ':adevice=/dev/dsp' +
                ':audiorate=32000' +            # 44100 for better sound
                ':forceaudio:forcechan=1:' +    # Forced mono for bug in my driver
                'buffersize=64' +               # 64 Megabyte capture buffer, change?
                ' -ovc lavc -lavcopts ' +       # Mencoder lavcodec video codec
                'vcodec=mpeg4' +                # lavcodec mpeg-4
                ':vbitrate=1200:' +             # Change lower/higher, bitrate
                'keyint=30 ' +                  # Keyframe every 10 secs, change?
                '-oac mp3lame -lameopts ' +     # Use Lame for MP3 encoding
                'br=128:cbr:mode=3 ' +          # MP3 const. bitrate, 128 kbit/s
                '-ffourcc divx ' +              # Force 'divx' ident, better compat.
                '-endpos %(seconds)s ' +        # only mencoder uses this so do it here.
                '-o %(filename)s.avi ' +        # Filled in by Freevo
                '; aumix -l 0;')

    # example of newer tv:// syntax mencoder
    VCR_CMD = ( 'aumix -l 80 -l R; '+
                CONF.mencoder + ' ' +
                'tv:// ' +                      # New mplayer requires this.
                '-tv driver=v4l:input=0' +      # Input 0 = TV, Input 1 = Comp. V. in
                ':norm=%s' % CONF.tv +
                ':channel=%(channel)s' +        # Filled in by Freevo
                ':chanlist=us-cable' +          # Change
                ':width=%d:height=%d' % (TV_REC_SIZE[0], TV_REC_SIZE[1]) +
                ':outfmt=%s' % TV_REC_OUTFMT +
                ':device=%s' % TV_DEVICE +
                ':adevice=/dev/dsp' +
                ':audiorate=32000' +            # 44100 for better sound
                ':forceaudio:forcechan=1:' +    # Forced mono for bug in my driver
                'buffersize=64' +               # 64 Megabyte capture buffer, change?
                ' -ovc lavc -lavcopts ' +       # Mencoder lavcodec video codec
                'vcodec=mpeg4' +                # lavcodec mpeg-4
                ':vbitrate=1200:' +             # Change lower/higher, bitrate
                'keyint=30 ' +                  # Keyframe every 10 secs, change?
                '-oac mp3lame -lameopts ' +     # Use Lame for MP3 encoding
                'br=128:cbr:mode=3 ' +          # MP3 const. bitrate, 128 kbit/s
                '-ffourcc divx ' +              # Force 'divx' ident, better compat.
                '-endpos %(seconds)s ' +        # only mencoder uses this so do it here.
                '-o %(filename)s.avi ' +        # Filled in by Freevo
                '; aumix -l 0;')

### 1.3.3 ALSA

This Alsa example is from the freevo users list. you may need to use this script in place of the VCR_CMD. The script itself has the line to change for VCR_CMD in it:

    #!/bin/bash

    # use with this VCR_CMD:
    # VCR_CMD = ('/usr/local/freevo_data/tvrecord/tvrecord %(channel)s %(seconds)s "%(filename)s"')

    CHAN=$1
    TIME=$2
    NAME=$3

    WIDTH=360
    HEIGHT=288

    MENCODER=/usr/bin/mencoder
    AMIXER=/usr/bin/amixer

    NICE="nice -n -20"

    AUDIO="-oac mp3lame -lameopts cbr:br=256:mode=0"
    VIDEO="-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1600"
    DSP="adevice=/dev/sound/dsp"
    TV=" -tv driver=v4l:width=$WIDTH:height=$HEIGHT:outfmt=yuy2:input=0:device=/dev/v4l/video0:norm=PAL:chanlist=europe-west:channel=$CHAN:$DSP"

    $AMIXER -q sset CD 87% mute
    $AMIXER -q sset Capture 87%
    $AMIXER -q cset numid=30 1      # select capture source, 30 is capture source control, 1 = CD and 4 = line
    $AMIXER -q cset numid=31 1      # set capture source switch to 1 (= on)
    $NICE $MENCODER tv:// $TV $VIDEO $AUDIO -endpos $TIME -ffourcc divx -o  "$NAME.avi"
    $AMIXER -q sset CD 87% unmute   # unmute cd again to hear sound when using watching tv after recording

Some things to note:

- The source provided here is CD IN.
- The norm is PAL.
- chanlist is europe-west
- the numid used are specific to the author's card

You will most likely need to change these variables. A note from the scripts author on how to get the numbers used by numid:

    You have to change the script for your card.

    numid=30 is the mixersource for my soundcard, 'ceset numdid=30 1 ' is to
    select the cd as capture source (0 = mic, 1 = cd, 4 = line)
    and numid=31 is the capture switch

    run "amixer controls" to get the numid's
    run "amixer cset numid=30" to get the capture source items (change
    numid=30 with yor capture source), I think you will take 4, the line in
    so 'amixer cset numid=30 4' to select line in as capture

See btaudio page for using alsa with snd-bt87x module (the alsa btaudio equivalent) Not using OSS has the advantage for me that I can record from line-in with volume control muted, hence ENABLING timeshift recording. My record script, this is for a creative labs Soundblaster Live 5.1, using Alsa.

    #!/bin/bash

    # use with this VCR_CMD:
    # VCR_CMD = ('/usr/local/freevo_data/tvrecord/tvrecord %(channel)s %(seconds)s "%(filename)s"')

    CHAN=$1
    TIME=$2
    NAME=$3

    WIDTH=320
    HEIGHT=240

    MENCODER=/usr/local/bin/mencoder
    AMIXER=/usr/bin/amixer

    NICE="nice -n -20"

    AUDIO="-oac mp3lame -lameopts cbr:br=128:mode=3"
    VIDEO="-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1200:keyint=30"
    DSP="alsa:adevice=emu10k1"
    TV=" -tv driver=v4l:width=$WIDTH:height=$HEIGHT:outfmt=yuy2:input=0:device=/dev/video0:norm=PAL:chanlist=europe-west:channel=$CHAN:$DSP:forceaudio:forcechan=1:buffersize=64"

    $AMIXER -q sset Line 87% mute
    $AMIXER -q sset Capture 87%
    $AMIXER -q cset numid=63 4      # select capture source, 63 is capture source control, 1 = CD and 4 = line
    $AMIXER -q cset numid=64 1      # set capture source switch to 1 (= on)
    $NICE $MENCODER tv:// $TV $VIDEO $AUDIO -endpos $TIME -ffourcc divx -o  "$NAME.avi"
    $AMIXER -q sset Line 87% unmute   # unmute cd again to hear sound when using watching tv after recording

i've found that the recording server doesn't kill the mencoder process when you cancel a currently recording show when run in this way.

the recording server sends a kill -15 to the parent shell script, which kills it off, but mencoder lives on now owned by pid '1'

the trap in the following script helps with this:

    #!/usr/bin/ksh

    handler() {
        kill -15 `ps -eaf | grep mencoder | grep -v grep | awk '{print $2}'`
    }

    trap handler TERM

    NAME=$1
    TIME=$2

    WIDTH=512
    HEIGHT=384

    MENCODER=/usr/bin/mencoder
    AUMIX=/usr/bin/amixer

    AUDIO_OPTIONS="alsa:adevice=hw.0,0:audiorate=44100:forceaudio"
    VIDEO_OPTIONS="driver=v4l:input=0:norm=pal:freq=0.000:width=$WIDTH:height=$HEIGHT:device=/dev/video0"

    TV="$VIDEO_OPTIONS:$AUDIO_OPTIONS"

    AUDIO="-oac mp3lame -lameopts br=128:cbr"
    VIDEO="-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1400:keyint=30 -vf lavcdeint"

    $AUMIX -q set Line mute
    $AUMIX -q set Line 87%
    $AUMIX -q cset numid=12 0     # select input
    $AUMIX -q cset numid=14 87%   # capture volume
    $AUMIX -q cset numid=13 1     # turn on capture

    $MENCODER tv:// -tv $TV $VIDEO $AUDIO -endpos $TIME -ffourcc divx -o $NAME &
    wait

    $AUMIX -q cset numid=13 0
    $AUMIX -q set Line 0%
    $AUMIX -q set Line unmute

## 1.4 IVTV setup

In order to use the ivtv recording plugin have the following in your local_conf.py:

    plugin.remove('tv.generic_record')
    plugin_record = plugin.activate('tv.ivtv_record')

Also for ivtv_record you may set some recording options:

    IVTV_OPTIONS = {
        'input'         : 4,
        'resolution'    : '720x480',
        'aspect'        : 2,
        'audio_bitmask' : 233,
        'bframes'       : 3,
        'bitrate_mode'  : 1,
        'bitrate'       : 4000000,
        'bitrate_peak'  : 4000000,
        'dnr_mode'      : 0,
        'dnr_spatial'   : 0,
        'dnr_temporal'  : 0,
        'dnr_type'      : 0,
        'framerate'     : 0,
        'framespergop'  : 15,
        'gop_closure'   : 1,
        'pulldown'      : 0,
        'stream_type'   : 10,
    }

    # Please see freevo_config.py for details.

# 2 1.5.x freevo

Things have changed a little..

You can no longer use command sequences like:

    VCR_CMD = ( 'aumix -l 80 -l R; '+
                CONF.mencoder + ' ' +
                blah

In your VCR_CMD.

Instead, we now have VCR_CMD_PRE = 'command opts' and VCR_CMD_POST = 'commands opts'

If you were using the sugegsted config for alsa, then you will not need to make changes. However, if you are using something as above, you need to use VCR_PRE and VCR_POST.

## 2.1 bttv (bt8x8 cards) info

Someone needs to explain the mutlicard stuff..

## 2.2 ivtv info

Someone needs to explain the mutlicard stuff..

## 2.3 Use frequencies in mencoder instead of channels

The channel list is a convention on which frequencies are allowed to be broadcasted in some countries. Cable operators need more channels and have the possibilitie to use frequencies which are not allowed for Antenna transmission. (Frequencies, used by the military, is such a exemple). So first you need to add the non-standard frequencies to you're local_conf.py file. This is a illustrated example of my TV_CHANNELS settings

    TV_CHANNELS = [
        ( 'bbcworld', 'BBC World', 'bbcworld' ),
        ( 'bbc1', 'BBC1', 'bbc1' ),
        ( 'bbc2', 'BBC2', 'bbc2' ),
        ...

The last parameter of every item in the list will be mapped to a frequency

So this is a part of my FREQUENCY_TABLE The frequencies are in Khz

    FREQUENCY_TABLE = {
         'bbcworld' : 294250,
         'bbc1': 266250,
         'bbc2': 273250,
         ...

Check with you're local cable tv supplier (website?) to find out.

This would work correctly with Tvtime, but not with mencoder. As you see in this example, it will try to pass a channel parameter I have defined in freevo to mencoder

    2004/07/28 22:40 CEST [*RecordServer*] popen
    /usr/bin/mencoder tv:// -tv driver=v4l2:input=0:norm=pal:channel=bbcworld...

A channel setting mencoder doesn't understand.

Bassicly a tvtuner will tune in with a specific frequency and is not aware of channels. Channel descriptions are different, regarding the standard (pal,secam,ntsc) or the country you're living in. As I descibed above, Cable operators don't have to follow these conventions, cause they where designed with antenna broadcast in mind.

I've modified the VCR_CMD to use a frequency instead of channels. The mencoder recording program supports the use of freq instead of channels.

    #           ':channel=%(channel)s' +        # Filled in by Freevo
    #           ':freq=%(frequency)s' +        # Filled in by Freevo
               ':freq=%(frequencyMhz)s' +

The frequency in Khz defined in FREQUENCY_TABLE needs to be divided by 1000, since mencoder uses the frequency in Mhz

To be able to introduce the parameter frequencyMhz, wich is identical to default parameter frequency, except it's using Mhz instead of Khz as required by mencoder I modified the file ....freevo/tv/plugins/generic_record.py

These are my modifications

     def Record(self, rec_prog):
            frequency = self.fc.chanSet(str(rec_prog.tunerid), 'record plugin')
           # modif gedeco
            frequencyT = str(frequency)
            frequencyT1 = len(frequencyT)
            frequencyleftpointer = frequencyT1-3
            frequencyA = frequencyT[0:frequencyleftpointer]
            frequencyB = frequencyT[frequencyleftpointer:frequencyT1]
            frequencyMh = frequencyA + '.' + frequencyB
            frequencyMhz = str(frequencyMh)
           # end modif gedeco
            rec_prog.filename = tv_util.getProgFilename(rec_prog)

            cl_options = { 'channel'  : rec_prog.tunerid,
                           # modif gedeco
                           'frequencyMhz' : frequencyMhz,
                           # modif gedeco
                           'frequency' : frequency,

A python programmer will find this probably a kludge --- wich it is. I'm not a programmer. So somebody capable of streamlining this, go ahead. But using the frequency would be a much better way to drive mencoder, cause both are depending on different channel lists. Made to confuse.

Thnx to Mick, who put me on the right track

EditText of this page (last modified 2004-10-31 06:43:47) FindPage by browsing, title search , text search or an index Or try one of these actions: AttachFile, LikePages, LocalSiteMap, SpellCheck