[Chugalug] Recording from TV tuner card under Linux

Ed King chevyiinova at bellsouth.net
Tue Mar 26 13:48:11 UTC 2013


I finally got a Round Tuit

I don't know if this helps but here's some random info about my PVR-150 setup on Kubuntu.

# lsmod
Module                  Size  Used by
cx8800                 34944  0 
cx88xx                 68132  1 cx8800
bttv                  177012  0 
video_buf              26244  3 cx8800,cx88xx,bttv
ir_common              35460  2 cx88xx,bttv
compat_ioctl32          2304  2 cx8800,bttv
btcx_risc               5896  3 cx8800,cx88xx,bttv
lirc_i2c               11268  0 
lirc_dev               15860  1 lirc_i2c
rfcomm                 42136  2 
l2cap                  26240  11 rfcomm
bluetooth              57060  4 rfcomm,l2cap
vboxdrv                61104  0 
ppdev                  10244  0 
ipv6                  273892  18 
speedstep_lib           6404  0 
cpufreq_powersave       2688  0 
cpufreq_conservative     8072  0 
cpufreq_ondemand        9612  0 
cpufreq_stats           7232  0 
freq_table              5792  2 cpufreq_ondemand,cpufreq_stats
cpufreq_userspace       5280  0 
ac                      6148  0 
dock                   10656  0 
button                  8976  0 
container               5504  0 
sbs                    19592  0 
video                  18060  0 
battery                11012  0 
lp                     12580  0 
wm8775                  7180  0 
cx25840                26640  0 
tuner                  63144  0 
snd_intel8x0           34972  2 
snd_ac97_codec        100644  1 snd_intel8x0
ac97_bus                3200  1 snd_ac97_codec
snd_pcm_oss            44672  0 
snd_mixer_oss          17664  1 snd_pcm_oss
snd_pcm                80388  3 snd_intel8x0,snd_ac97_codec,snd_pcm_oss
snd_seq_dummy           4740  0 
snd_seq_oss            33152  0 
snd_seq_midi            9600  0 
snd_rawmidi            25728  1 snd_seq_midi
ivtv                  134928  0 
i2c_algo_bit            7428  3 cx88xx,bttv,ivtv
snd_seq_midi_event      8448  2 snd_seq_oss,snd_seq_midi
snd_seq                53232  6 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_midi_event
snd_timer              24324  2 snd_pcm,snd_seq
snd_seq_device          9228  5 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi,snd_seq
cx2341x                13316  1 ivtv
nvidia               4716020  22 
tveeprom               16784  3 cx88xx,bttv,ivtv
videodev               29312  4 cx8800,cx88xx,bttv,ivtv
v4l2_common            18432  9 cx8800,cx88xx,bttv,wm8775,cx25840,tuner,ivtv,cx2341x,videodev
v4l1_compat            15364  3 bttv,ivtv,videodev
parport_pc             37412  1 
parport                37448  3 ppdev,lp,parport_pc
i2c_core               26112  10 cx88xx,bttv,lirc_i2c,wm8775,cx25840,tuner,ivtv,i2c_algo_bit,nvidia,tveeprom
pcspkr                  4224  0 
snd                    54660  14 snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_seq_oss,snd_rawmidi,snd_seq,snd_timer,snd_seq_device
soundcore               8800  1 snd
iTCO_wdt               11940  0 
iTCO_vendor_support     4868  1 iTCO_wdt
psmouse                39952  0 
snd_page_alloc         11400  2 snd_intel8x0,snd_pcm
i82875p_edac            7172  0 
edac_mc                25808  1 i82875p_edac
serio_raw               8068  0 
intel_agp              25620  1 
agpgart                35016  2 nvidia,intel_agp
shpchp                 34580  0 
pci_hotplug            32704  1 shpchp
evdev                  11136  3 
ext3                  133896  1 
jbd                    60456  1 ext3
mbcache                 9732  1 ext3
sg                     36764  0 
sr_mod                 17828  0 
cdrom                  37536  1 sr_mod
sd_mod                 30336  3 
ata_piix               17540  2 
floppy                 60004  0 
tg3                   110980  0 
ata_generic             8452  0 
libata                125168  2 ata_piix,ata_generic
scsi_mod              147084  4 sg,sr_mod,sd_mod,libata
ehci_hcd               36492  0 
uhci_hcd               26640  0 
usbcore               138632  3 ehci_hcd,uhci_hcd
thermal                14344  0 
processor              32072  1 thermal
fan                     5764  0 
fuse                   47124  1 
apparmor               40728  0 
commoncap               8320  1 apparmor

# lspci
00:00.0 Host bridge: Intel Corporation 82875P/E7210 Memory Controller Hub (rev 02)
00:01.0 PCI bridge: Intel Corporation 82875P Processor to AGP Controller (rev 02)
00:06.0 System peripheral: Intel Corporation 82875P/E7210 Processor to I/O Memory Interface (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #3 (rev 02)
00:1d.7 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB2 EHCI Controller (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev c2)
00:1f.0 ISA bridge: Intel Corporation 82801EB/ER (ICH5/ICH5R) LPC Interface Bridge (rev 02)
00:1f.1 IDE interface: Intel Corporation 82801EB/ER (ICH5/ICH5R) IDE Controller (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801EB (ICH5) SATA Controller (rev 02)
00:1f.5 Multimedia audio controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller (rev 02)
05:02.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5782 Gigabit Ethernet (rev 03)
05:09.0 VGA compatible controller: nVidia Corporation NV11 [GeForce2 MX/MX 400] (rev b2)
05:0b.0 Multimedia video controller: Internext Compression Inc iTVC16 (CX23416) MPEG-2 Encoder (rev 01)


To capture a jpeg image from the PVR-150:

ffmpeg -i /dev/video0 -vcodec mjpeg -vframes 1 -an -s 720x480 /tmp/whatever.jpg

To capture a 60 second video from the PVR-150:
cat /dev/video0 > /tmp/myvideo.mpg; sleep 60; killall cat

Another way to record video:
mplayer -dumpstream -dumpfile /tmp/myvideo.mpg /dev/video0

Playback:
mplayer /tmp/myvideo.mpg

Real-time video:
mplayer /dev/video0

Beware that some x apps will NOT show video from the card and you will think your card is not setup properly...  I wasted a shitload of time before I figured that out ;-)   Seems like xawtv was one of them.


Channel selection (might want to put this in startup scripts so your card will continue to function as expected after a system reboot)
/usr/bin/v4l2-ctl -i 2


root at vdawg-desktop:/home/vdawg# dmesg
[    0.000000] Linux version 2.6.22-14-generic (buildd at palmer) (gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Sun Oct 14 23:05:12 GMT 2007 (Ubuntu 2.6.22-14.46-generic)
<snip>
[  192.081637] ivtv:  ==================== START INIT IVTV ====================
[  192.081642] ivtv:  version 1.0.0 (2.6.22-14-generic SMP mod_unload 586 ) loading
[  192.081735] ivtv0: Autodetected Hauppauge card (cx23416 based)
[  192.081776] ACPI: PCI Interrupt 0000:05:0b.0[A] -> GSI 22 (level, low) -> IRQ 21
[  192.743504] ivtv0: loaded v4l-cx2341x-enc.fw firmware (3612791400 bytes)
[  192.957264] ivtv0: Encoder revision: 0x02050032
[  192.957268] ivtv0: Recommended firmware version is 0x02060039.
[  193.015763] tveeprom 0-0050: Hauppauge model 26032, rev C199, serial# 8162953
[  193.015768] tveeprom 0-0050: tuner model is TCL 2002N 5H (idx 99, type 50)
[  193.015771] tveeprom 0-0050: TV standards NTSC(M) (eeprom 0x08)
[  193.015774] tveeprom 0-0050: audio processor is CX25841 (idx 35)
[  193.015777] tveeprom 0-0050: decoder processor is CX25841 (idx 28)
[  193.015780] tveeprom 0-0050: has no radio, has IR receiver, has IR transmitter
[  193.015783] ivtv0: Autodetected Hauppauge WinTV PVR-150
[  193.015786] ivtv0: reopen i2c bus for IR-blaster support
[  193.084546] tuner 0-0061: chip found @ 0xc2 (ivtv i2c driver #0)
[  193.253644] cx25840 0-0044: cx25841-23 found @ 0x88 (ivtv i2c driver #0)
[  196.649801] cx25840 0-0044: loaded v4l-cx25840.fw firmware (16382 bytes)
[  196.737982] wm8775 0-001b: chip found @ 0x36 (ivtv i2c driver #0)
[  196.783323] tuner 0-0061: type set to 50 (TCL 2002N)
[  197.096206] ivtv0: Registered device video0 for encoder MPEG (4 MB)
[  197.096528] ivtv0: Registered device video32 for encoder YUV (2 MB)
[  197.096861] ivtv0: Registered device vbi0 for encoder VBI (1 MB)
[  197.097076] ivtv0: Registered device video24 for encoder PCM audio (1 MB)
[  197.118967] ivtv0: Initialized Hauppauge WinTV PVR-150, card #0
[  197.119011] ACPI: PCI Interrupt 0000:00:1f.5[B] -> GSI 17 (level, low) -> IRQ 20
[  197.119040] PCI: Setting latency timer of device 0000:00:1f.5 to 64
[  197.537453] intel8x0_measure_ac97_clock: measured 54764 usecs
[  197.537457] intel8x0: clocking to 48000
[  197.539998] ivtv:  ====================  END INIT IVTV  ====================
<snip>

[  212.773016] lirc_dev: IR Remote Control driver registered, at major 61 
[  213.124699] bttv: driver version 0.9.17 loaded
[  213.124705] bttv: using 8 buffers with 2080k (520 pages) each for capture
[  213.201887] cx2388x v4l2 driver version 0.0.6 loaded
[  213.234786] lirc_i2c: chip 0x10020 found @ 0x71 (Hauppauge PVR150)
[  213.235082] lirc_dev: lirc_register_plugin: sample_rate: 10



A setup script that I do NOT use...
#!/bin/sh
# pvr150_init - initialise PVR150 capture card prior to use
# PAL-I for UK
v4l2-ctl -s pal-I
# MPEG-2 Program Stream
v4l2-ctl -c stream_type=0
v4l2-ctl -c insert_navigation_packets=0
v4l2-ctl -c stream_vbi_format=0
# 16x9
v4l2-ctl -c video_aspect=2
# 4x3
#v4l2-ctl -c video_aspect=1
v4l2-ctl -c video_bitrate=8000000
v4l2-ctl -c video_peak_bitrate=8000000
v4l2-ctl -c video_b_frames=2
v4l2-ctl -c video_gop_closure=1
# 48 kHz
v4l2-ctl -c audio_sampling_frequency=1
# MPEG-1/2 Layer II
v4l2-ctl -c audio_encoding=1
# 384 kbps
v4l2-ctl -c audio_layer_ii_bitrate=13
# Stereo
v4l2-ctl -c audio_stereo_mode=0
# No Emphasis
v4l2-ctl -c audio_emphasis=0
# No CRC
v4l2-ctl -c audio_crc=0
# set to composite input
v4l2-ctl -i 2
#87%
v4l2-ctl --set-ctrl=volume=57016




And another setup script that I do NOT use...
#PVR-150 card settings..
v4l2-ctl -c audio_layer_ii_bitrate=9 #192Kbps
v4l2-ctl -c audio_stereo_mode=3 #Mono
v4l2-ctl -c stream_type=0 #MPEG-2 Program Stream=0
v4l2-ctl -c video_bitrate=1400000 #Set Video Bitrate
v4l2-ctl -c video_bitrate_mode=1 #CBR
v4l2-ctl -c video_aspect=1 #4:3
v4l2-ctl --set-fmt-video=width=704,height=576 #Set resolution
v4l2-ctl --set-input=2 #Composite input



v4l2-ctl is your friend!

$ v4l2-ctl --all
Driver Info:
        Driver name   : ivtv
        Card type     : Hauppauge WinTV PVR-150
        Bus info      : 0000:05:0b.0
        Driver version: 65536
        Capabilities  : 0x01030051
                Video Capture
                VBI Capture
                Sliced VBI Capture
                Tuner
                Audio
                Read/Write
Format Video Capture:
        Width/Height  : 720/480
        Pixel Format  : MPEG
        Field         : Interlaced
        Bytes per Line: 0
        Size Image    : 131072
        Colorspace    : Broadcast NTSC/PAL (SMPTE170M/ITU601)
Format Sliced VBI Capture:
        Service Set    :
        Service Line  0:          /
        Service Line  1:          /
        Service Line  2:          /
        Service Line  3:          /
        Service Line  4:          /
        Service Line  5:          /
        Service Line  6:          /
        Service Line  7:          /
        Service Line  8:          /
        Service Line  9:          /
        Service Line 10:          /
        Service Line 11:          /
        Service Line 12:          /
        Service Line 13:          /
        Service Line 14:          /
        Service Line 15:          /
        Service Line 16:          /
        Service Line 17:          /
        Service Line 18:          /
        Service Line 19:          /
        Service Line 20:          /
        Service Line 21:          /
        Service Line 22:          /
        Service Line 23:          /
        I/O Size       : 0
Format VBI Capture:
        Sampling Rate   : 27000000 Hz
        Offset          : 248 samples (9.18519e-06 secs after leading edge)
        Samples per Line: 1440
        Sample Format   : GREY
        Start 1st Field : 10
        Count 1st Field : 12
        Start 2nd Field : 273
        Count 2nd Field : 12
Framebuffer Format:
        Capability    :
        Flags         :
        Width         : 0
        Height        : 0
        Pixel Format  :
        Bytes per Line: 0
        Size image    : 0
        Colorspace    : Unknown (00000000)
Crop Capability Video Capture:
        Bounds      : Left 0, Top 0, Width 720, Height 480
        Default     : Left 0, Top 0, Width 720, Height 480
        Pixel Aspect: 10/11
Crop Capability Video Output:
        Bounds      : Left 0, Top 0, Width 720, Height 480
        Default     : Left 0, Top 0, Width 720, Height 480
        Pixel Aspect: 10/11
Video input : 2 (Composite 1)
Audio input : 1 (Line In 1)
Frequency: 1076 (67.250000 MHz)
Video Standard = 0x00001000
        NTSC-M
Tuner:
        Capabilities         : 62.5 kHz multi-standard stereo lang1 lang2
        Frequency range      : 44.0 MHz - 958.0 MHz
        Signal strength      : 99%
        Current audio mode   : lang1
        Available subchannels: mono lang2





$ v4l2-ctl
Usage:
Common options:
  --all              display all information available
  -B, --get-fmt-sliced-vbi
                     query the sliced VBI capture format [VIDIOC_G_FMT]
  -b, --set-fmt-sliced-vbi=<mode>
                     set the sliced VBI capture format to <mode> [VIDIOC_S_FMT]
                     <mode> is a comma separated list of:
                     off:      turn off sliced VBI (cannot be combined with other modes)
                     teletext: teletext (PAL/SECAM)
                     cc:       closed caption (NTSC)
                     wss:      widescreen signal (PAL/SECAM)
                     vps:      VPS (PAL/SECAM)
  -C, --get-ctrl=<ctrl>[,<ctrl>...]
                     get the value of the controls [VIDIOC_G_EXT_CTRLS]
  -c, --set-ctrl=<ctrl>=<val>[,<ctrl>=<val>...]
                     set the controls to the values specified [VIDIOC_S_EXT_CTRLS]
  -D, --info         show driver info [VIDIOC_QUERYCAP]
  -d, --device=<dev> use device <dev> instead of /dev/video0
                     if <dev> is a single digit, then /dev/video<dev> is used
  -F, --get-freq     query the frequency [VIDIOC_G_FREQUENCY]
  -f, --set-freq=<freq>
                     set the frequency to <freq> MHz [VIDIOC_S_FREQUENCY]
  -h, --help         display this help message
  -I, --get-input    query the video input [VIDIOC_G_INPUT]
  -i, --set-input=<num>
                     set the video input to <num> [VIDIOC_S_INPUT]
  -l, --list-ctrls   display all controls and their values [VIDIOC_QUERYCTRL]
  -L, --list-ctrls-menus
                     display all controls, their values and the menus [VIDIOC_QUERYMENU]
  -N, --list-outputs display video outputs [VIDIOC_ENUMOUTPUT]
  -n, --list-inputs  display video inputs [VIDIOC_ENUMINPUT]
  -O, --get-output   query the video output [VIDIOC_G_OUTPUT]
  -o, --set-output=<num>
                     set the video output to <num> [VIDIOC_S_OUTPUT]
  -Q, --list-audio-outputs
                     display audio outputs [VIDIOC_ENUMAUDOUT]
  -q, --list-audio-inputs
                     display audio inputs [VIDIOC_ENUMAUDIO]
  -S, --get-standard
                     query the video standard [VIDIOC_G_STD]
  -s, --set-standard=<num>
                     set the video standard to <num> [VIDIOC_S_STD]
                     <num> can be a numerical v4l2_std value, or it can be one of:
                     pal-X (X = B/G/H/N/Nc/I/D/K/M/60) or just 'pal' (V4L2_STD_PAL)
                     ntsc-X (X = M/J/K) or just 'ntsc' (V4L2_STD_NTSC)
                     secam-X (X = B/G/H/D/K/L/Lc) or just 'secam' (V4L2_STD_SECAM)
  --list-standards   display supported video standards [VIDIOC_ENUMSTD]
  -T, --get-tuner    query the tuner settings [VIDIOC_G_TUNER]
  -t, --set-tuner=<mode>
                     set the audio mode of the tuner [VIDIOC_S_TUNER]
                     Possible values: mono, stereo, lang2, lang1, bilingual
  --list-formats     display supported video formats [VIDIOC_ENUM_FMT]
  -V, --get-fmt-video
                     query the video capture format [VIDIOC_G_FMT]
  -v, --set-fmt-video=width=<w>,height=<h>
                     set the video capture format [VIDIOC_S_FMT]
  --verbose          turn on verbose ioctl error reporting.

Uncommon options:
  --get-fmt-video-out
                     query the video output format [VIDIOC_G_FMT]
  --set-fmt-video-out=width=<w>,height=<h>
                     set the video output format [VIDIOC_S_FMT]
  --get-fmt-overlay
                     query the video overlay format [VIDIOC_G_FMT]
  --get-fmt-output-overlay
                     query the video output overlay format [VIDIOC_G_FMT]
  --set-fmt-output-overlay=chromakey=<key>,global_alpha=<alpha>
                     set the video output overlay format [VIDIOC_S_FMT]
  --get-sliced-vbi-cap
                     query the sliced VBI capture capabilities [VIDIOC_G_SLICED_VBI_CAP]
  --get-sliced-vbi-out-cap
                     query the sliced VBI output capabilities [VIDIOC_G_SLICED_VBI_CAP]
  --get-fmt-sliced-vbi-out
                     query the sliced VBI output format [VIDIOC_G_FMT]
  --set-fmt-sliced-vbi-out=<mode>
                     set the sliced VBI output format to <mode> [VIDIOC_S_FMT]
                     <mode> is a comma separated list of:
                     off:      turn off sliced VBI (cannot be combined with other modes)
                     teletext: teletext (PAL/SECAM)
                     cc:       closed caption (NTSC)
                     wss:      widescreen signal (PAL/SECAM)
                     vps:      VPS (PAL/SECAM)
  --get-fmt-vbi      query the VBI capture format [VIDIOC_G_FMT]
  --get-fmt-vbi-out  query the VBI output format [VIDIOC_G_FMT]
  --get-fbuf         query the overlay framebuffer data [VIDIOC_G_FBUF]
  --set-fbuf=chromakey=<0/1>,global_alpha=<0/1>,local_alpha=<0/1>,
             global_inv_alpha=<0/1>,local_inv_alpha=<0/1>
                     set the overlay framebuffer [VIDIOC_S_FBUF]
  --get-cropcap      query the crop capabilities [VIDIOC_CROPCAP]
  --get-crop         query the video capture crop window [VIDIOC_G_CROP]
  --set-crop=top=<x>,left=<y>,width=<w>,height=<h>
                     set the video capture crop window [VIDIOC_S_CROP]
  --get-cropcap-output
                     query the crop capabilities for video output [VIDIOC_CROPCAP]
  --get-crop-output  query the video output crop window [VIDIOC_G_CROP]
  --set-crop-output=top=<x>,left=<y>,width=<w>,height=<h>
                     set the video output crop window [VIDIOC_S_CROP]
  --get-cropcap-overlay
                     query the crop capabilities for video overlay [VIDIOC_CROPCAP]
  --get-crop-overlay query the video overlay crop window [VIDIOC_G_CROP]
  --set-crop-overlay=top=<x>,left=<y>,width=<w>,height=<h>
                     set the video overlay crop window [VIDIOC_S_CROP]
  --get-cropcap-output-overlay
                     query the crop capabilities for video output overlays [VIDIOC_CROPCAP]
  --get-crop-output-overlay
                     query the video output overlay crop window [VIDIOC_G_CROP]
  --set-crop-output-overlay=top=<x>,left=<y>,width=<w>,height=<h>
                     set the video output overlay crop window [VIDIOC_S_CROP]
  --get-audio-input  query the audio input [VIDIOC_G_AUDIO]
  --set-audio-input=<num>
                     set the audio input to <num> [VIDIOC_S_AUDIO]
  --get-audio-output query the audio output [VIDIOC_G_AUDOUT]
  --set-audio-output=<num>
                     set the audio output to <num> [VIDIOC_S_AUDOUT]
  --list-audio-outputs
                     display audio outputs [VIDIOC_ENUMAUDOUT]
  --list-audio-inputs
                     display audio inputs [VIDIOC_ENUMAUDIO]

Expert options:
  --streamoff        turn the stream off [VIDIOC_STREAMOFF]
  --streamon         turn the stream on [VIDIOC_STREAMOFF]
  --log-status       log the board status in the kernel log [VIDIOC_LOG_STATUS]


 


More information about the Chugalug mailing list