「GV-MVP/RX」によるテレビ録画

「GV-MVP/RX」でテレビ録画を行います。
環境は以下の通りです。

kernel 2.6.23-gentoo-r6
ivtv 1.0.3-r1

なお、kernelが2.6.20系の場合はこちらを参照して下さい。

kernelの再構築

デフォルトのkernelだと正常に再生されないので、 こちらより 以下のファイルを入手します。
s7115f8p.tar(早送り修正)
tvau-f8p.tar(音量修正)
ダウンロードのページではivtvに上記のパッチファイルを適用していますが、自分はkernelに適用したので、それぞれのファイルを
drivers/media/video/saa7115.c
drivers/media/video/tvaudio.c
とリネームして、元のkernelのソースと入れ替えます。
その後、必要なkernelの設定をしてからコンパイルします。
自分の環境では以下のものが必要でした。

Device Drivers  --->
  Multimedia devices  --->
    <M>Video For Linux
      Video Capture Adapters  --->
        [ ] Autoselect pertinent encoders/decoders and other helper chips
              Encoders/decoders and other helper chips  --->
                 …
                <M> Simple audio decoder chips(*)
                 …
                <M> Micronas MSP34xx audio decoders
                 …
                <M> Wolfson Microelectronics WM8775 audio ADC with input mixer
                <M> Wolfson Microelectronics WM8739 stereo audio ADC(*)
                 …
                <M> Philips SAA7113/4/5 video decoders
                 …
                <M> Conexant CX2584x audio/video decoders
                 …
                <M> Conexant CX2341x MPEG encoders
                 …
                <M> Philips SAA7127/9 digital video encoders
                 …
                <M> NEC Electronics uPD64031A Ghost Reduction(*)
                <M> NEC Electronics uPD64083 3-Dimensional Y/C separation(*)
         …
        <M> BT848 Video For Linux
ドライバのインストール

環境によっては「coldplug」と「udev」がブロックされます。
「udev」を利用しないのであれば、「udev」をマスクしてインストールします。

Gentoo ~ # echo sys-fs/udev >> /etc/portage/package.mask <= 「udev」のマスク
Gentoo ~ # emerge ivtv

もしここでkernelの設定で足りないものがあった場合、以下のようなエラーが表示されるので、 必要なものを設定し、kernelを再構築します。

 * Checking for suitable kernel configuration options...
 *   CONFIG_VIDEO_TUNER:         is not set when it should be.
 *   CONFIG_VIDEO_TVEEPROM:      is not set when it should be.
 * Please check to make sure these options are set correctly.
 * Failure to do so may cause unexpected problems.
 * Once you have satisfied these options, please try merging
 * this package again.

なお、kernelの再構築で「make menuconfig」を使って再構築をする場合の必要なモジュールの探し方は こちらを参照。

ドライバのロード
Gentoo ~ # depmod -a
Gentoo ~ # modprobe ivtv tuner=46,46 ntsc=j

自動ロード

「Gentoo」起動時に自動でロードするようにします。

Gentoo ~ # vi /etc/modules.autoload.d/kernel-2.6 <= 設定ファイルの編集
ivtv tuner=46,46 ntsc=j <= 追加

Gentoo ~ # modules-update
動作確認

「Video standard」の設定

「Video standard」を「NTSC-M-JP」に設定します。

Gentoo ~ # v4l2-ctl -d /dev/video0 --get-standard <= 現在の設定を確認
Video standard = 0x00001000
        NTSC-M

上記のように「NTSC-M-JP」になっていない場合、以下のようにして変更します。

Gentoo ~ # v4l2-ctl -d /dev/video0 --list-standard <= 「NTSC-J」のindexを調べる
         …
        index       : 11
        ID          : 0x0000000000002000
        Name        : NTSC-J
        Frame period: 1001/30000
        Frame lines : 525
         …
Gentoo ~ # v4l2-ctl -d /dev/video0 --set-standard=11 <= Video standardの変更
Standard set to 00002000

起動時に「Video standard」の自動セット

基本的に上記の方法でデフォルト値が設定されますが、なんらかの理由により起動時にデフォルト値が変更されるようになってしまった場合、 以下のようなスクリプトを作成し対処します。

Gentoo ~ # vi vstd_setup.sh <= 「Video standard」変更スクリプト作成
#!/bin/sh

PATH=/usr/bin:/sbin:/bin

TMP=`v4l2-ctl -d /dev/video0 --list-standard | awk '/NTSC-J/ {print NR}'`
LINE=`expr $TMP - 2`
CHK=`v4l2-ctl -d /dev/video0 --list-standard | awk 'NR == '$LINE'{print $1}'`
if [ $CHK = 'index' ]
then
  SET=`v4l2-ctl -d /dev/video0 --list-standard | awk 'NR == '$LINE'{print $3}'`
else
  echo "Video standard Setup Error !!!"
  exit 1
fi

VSTD=`v4l2-ctl -d /dev/video0 --get-standard | awk 'NR == 1{print $4}'`
VALUE=`v4l2-ctl -d /dev/video0 --get-standard | awk 'NR == 2{print $1}'`

if [ $VSTD != '0x00002000' ]
then
  v4l2-ctl -d /dev/video0 --set-standard="$SET" > /dev/null 2>&1
elif [ $VALUE != 'NTSC-M-JP' ]
then
  v4l2-ctl -d /dev/video0 --set-standard="$SET" > /dev/null 2>&1
fi


Gentoo ~ # chmod 700 vstd_setup.sh <= 作成したスクリプトに実行権限付加

Gentoo起動時に自動的に実行するようにします。

Gentoo ~ # vi /etc/conf.d/local.start
/root/vstd_setup.sh <= 追加

チャンネルの設定

Gentoo ~ # ivtv-tune -d /dev/video0 -t japan-bcast -c 8 <= 8チャンネルに設定

録画

以下のコマンドでファイルが作られますが、終了は「Ctrl + C」で強制終了します。

Gentoo ~ # cat /dev/video0 > test.mpg
「record-v4l2.pl」の導入

Perlモジュールのインストール

「record-v4l2.pl」コマンドの動作に必要なPerlモジュールをインストールします。
なお、Video-FrequenciesとVideo-ivtvはブロックされているので、解除します。

Gentoo ~ # vi /etc/portage/package.keywords <= 設定ファイルの編集
dev-perl/Video-Frequencies ~x86 <= 追加
dev-perl/Video-ivtv ~x86 <= 追加

ブロックされているものを解除したらインストールします。

Gentoo ~ # emerge dev-perl/Video-Frequencies <= 「Video-Frequencies」のインストール
Gentoo ~ # emerge dev-perl/Video-ivtv <= 「Video-ivtv」のインストール
Gentoo ~ # emerge dev-perl/Config-IniFiles <= 「Config-IniFiles」のインストール
Gentoo ~ # emerge dev-perl/perl-tk <= 「perl-tk」のインストール

「record-v4l2.pl」コマンドの修正

「record-v4l2.pl」実行時に
Error calling setCodecInfo()!
等のエラーが表示されるので、修正します。

Gentoo ~ # vi /usr/bin/record-v4l2.pl <= 「record-v4l2.pl」コマンドの修正
  if ($ivtvVersion > 265) # > 0.1.9
  {
    $result = $ivtvObj->setEndGOP($tunerFD, $settings{CaptureLastGOP});
    if (!$result)
    {
      die "Error calling setEndGOP($settings{CaptureLastGOP})!\n";
     ↓

#      die "Error calling setEndGOP($settings{CaptureLastGOP})!\n"; <= コメントアウト
    }
  }


if ($changedSettings{codec})
{
  $result = $ivtvObj->setCodecInfo($tunerFD, @newCodecInfo);
  if (!$result)
  {
    die "Error calling setCodecInfo()!\n";
    ↓
#    die "Error calling setCodecInfo()!\n"; <= コメントアウト
  }
}

  # restore Codec values
  if ($changedSettings{codec})
  {
    $result = $ivtvObj->setCodecInfo($tunerFD, @codecInfo);
    if (!$result)
    {
      die "Error calling setCodecInfo()!\n";
      ↓
#      die "Error calling setCodecInfo()!\n"; <= コメントアウト
    }
  }

上記の変更は「dev-perl/Video-ivtv」をバージョンアップすると元に戻ってしまいますので、 バージョンアップ時には再び設定する必要があります。

「ivtv」の設定

設定ファイルは ~/.ivtvrc ですが、存在しない場合コマンド実行時に自動で作成されるので、 念の為、一度削除してからデフォルトの設定ファイルを作成します。

Gentoo ~ # rm ~/.ivtvrc <= 設定ファイルの削除
Gentoo ~ # record-v4l2.pl --version <= 設定ファイルの作成
Gentoo ~ # vi ~/.ivtvrc <= 設定ファイルの編集
OutputSettings=1
↓
OutputSettings=0 <= 変更

VideoStandard=NTSC
↓
VideoStandard=NTSC-J <= 変更

TunerNum=1
↓
TunerNum=0 <= 変更

DirectoryFormatString=%I-%c-%d
↓
DirectoryFormatString= <= 変更

FrequencyTable=ntsc-cable
↓
FrequencyTable=ntsc-bcast-jp <= 変更

「record-v4l2.pl」コマンドの実行

8チャンネルを5秒間録画し、カレントディレクトリにtest.mpgという名前で作成します。

Gentoo ~ # record-v4l2.pl -F `ivtv-tune -d /dev/video0 -t japan-bcast -c 8 | awk '{print $2}' | tr -d .` -t 5 -o test.mpg
▲ページのトップへ