Capturing Video / Converting Hi8 Using avconv With Conexant/Brooktree 878 Tuner Card

These are some notes I took while converting some old Hi8 tapes I had into H.264 format for archival.

The biggest problem I ran into was available CPU horsepower. Anything less than a Core2Quad is probably not going to cut it for realtime Main Profile encoding. It will simply drop huge numbers of frames. I had a Core2Duo at the time and had to swap in 2 more cores. Encoding a 720x480p stream using the Main Profile at 6 – 8 mbps caused three of the cores to saturate during the entire process.

The commands I used to set up the capture were as follows.

Setting to use Composite input

$ v4l2-ctl -i 2
Video input set to 2 (S-Video: no hsync lock.)

If you don’t select the correct input channel, the avconv call will usually see a blue “no signal” screen.

Setting to use NTSC standard

$ v4l2-ctl –set-standard ntsc
Standard set to 0000b000

If you don’t select the correct broadcast / line encoding standard, your images will look all messed up, aspect ratio could be affected as well.

Capturing 480p Using avconv With x264 And AAC

$ avconv -f alsa -i pulse -f video4linux2 -channel 2 -video_size 720×480 -i /dev/video0 -codec:a libfaac -b:a 192k -codec:v libx264 -b:v 6144k -vprofile main Output.mp4

The settings in play here are:

  • -f alsa -i pulse —

    Selects the audio input. On Ubuntu, PulseAudio needed to be the input device, or I would get a hang.

  • -f video4linux2 -channel 2 -video_size 720×480 -i /dev/video0 —

    Selects the video input and parameters. Channel 2 is the S-Video input of the card I was using, and is the same number used in the v4l2-ctl command above.

  • -codec:a libfaac -b:a 192k —

    192kbps AAC encoding

  • -codec:v libx264 -b:v 6144k -vprofile main —

    6144kbps Main Profile H.264 encoding

I have to say here that I’m very glad the avconv authors finally cleaned up the command-line syntax from the bad old days of the ffmpeg command-line parser. It’s a breath of fresh air to have options finally make sense and follow some pattern that is easier to remember and behaves consistently.

dmesg

[ 28.022337] bttv: driver version 0.9.19 loaded
[ 28.022340] bttv: using 8 buffers with 2080k (520 pages) each for capture
[ 28.022784] bttv: Bt8xx card found (0)
[ 28.022799] bttv 0000:05:02.0: PCI INT A -> GSI 23 (level, low) -> IRQ 23
[ 28.022813] bttv: 0: Bt878 (rev 17) at 0000:05:02.0, irq: 23, latency: 64, mmio: 0xf6ffe000
[ 28.023134] bttv: 0: detected: Leadtek WinFast TV 2000 [card=34], PCI subsystem ID is 107d:6606
[ 28.023137] bttv: 0: using: Leadtek WinFast 2000/ WinFast 2000 XP [card=34,autodetected]
[ 28.023246] bttv: 0: tuner type=5
[ 28.028205] i2c-core: driver [msp3400] using legacy suspend method
[ 28.028208] i2c-core: driver [msp3400] using legacy resume method
[ 28.048071] bttv: 0: audio absent, no audio device found!
[ 28.052130] i2c-core: driver [tuner] using legacy suspend method
[ 28.052133] i2c-core: driver [tuner] using legacy resume method
[ 28.061435] tuner 1-0061: Tuner -1 found with type(s) Radio TV.
[ 28.074112] tuner-simple 1-0061: creating new instance
[ 28.074115] tuner-simple 1-0061: type set to 5 (Philips PAL_BG (FI1216 and compatibles))
[ 28.075195] bttv: 0: registered device video0
[ 28.075265] bttv: 0: registered device vbi0
[ 28.075335] bttv: 0: registered device radio0
[ 28.075385] bttv: 0: Setting PLL: 28636363 => 35468950 (needs up to 100ms)
[ 28.077748] [drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
[ 28.077751] [drm] No driver support for vblank timestamp query.
[ 28.090043] IR Sony protocol handler initialized
[ 28.104182] bttv: PLL set ok

cat /proc/asound/cards

0 [Intel ]: HDA-Intel – HDA Intel
HDA Intel at 0xf7ffc000 irq 46
1 [Bt878 ]: Bt87x – Brooktree Bt878
Brooktree Bt878 at 0xf6fff000, irq 23

cat /proc/asound/devices

1: : sequencer
2: [ 1- 1]: digital audio capture
3: [ 1- 0]: digital audio capture
4: [ 1] : control
5: [ 0- 1]: digital audio playback
6: [ 0- 1]: digital audio capture
7: [ 0- 0]: digital audio playback
8: [ 0- 0]: digital audio capture
9: [ 0- 0]: hardware dependent
10: [ 0] : control
11: [ 2- 9]: digital audio playback
12: [ 2- 8]: digital audio playback
13: [ 2- 7]: digital audio playback
14: [ 2- 3]: digital audio playback
15: [ 2- 3]: hardware dependent
16: [ 2- 2]: hardware dependent
17: [ 2- 1]: hardware dependent
18: [ 2- 0]: hardware dependent
19: [ 2] : control
33: : timer

lspci

05:02.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
05:02.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)

Installing v4l2-ctl

$ sudo apt-get install v4l-utils
[sudo] password for max:
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
libv4l-0 libv4lconvert0
The following NEW packages will be installed:
v4l-utils
The following packages will be upgraded:
libv4l-0 libv4lconvert0
2 upgraded, 1 newly installed, 0 to remove and 323 not upgraded.
Need to get 240 kB of archives.
After this operation, 342 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://de.archive.ubuntu.com/ubuntu/ precise-updates/main libv4l-0 amd64 0.8.6-1ubuntu2 [41.7 kB]
Get:2 http://de.archive.ubuntu.com/ubuntu/ precise-updates/main libv4lconvert0 amd64 0.8.6-1ubuntu2 [81.5 kB]
Get:3 http://de.archive.ubuntu.com/ubuntu/ precise-updates/universe v4l-utils amd64 0.8.6-1ubuntu2 [117 kB]
Fetched 240 kB in 0s (377 kB/s)

v4l2-ctl -n

ioctl: VIDIOC_ENUMINPUT
Input : 0
Name : Television
Type : 0x00000001
Audioset : 0x00000001
Tuner : 0x00000000
Standard : 0x0000000000FFBFFF (PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60 NTSC-M/M-JP/M-KR SECAM-B/D/G/H/K/K1/L/Lc)
Status : 0x00000100 (no hsync lock.)
Capabilities: 0x00000004 (SD presets)

Input : 1
Name : Composite1
Type : 0x00000002
Audioset : 0x00000001
Tuner : 0x00000000
Standard : 0x0000000000FFBFFF (PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60 NTSC-M/M-JP/M-KR SECAM-B/D/G/H/K/K1/L/Lc)
Status : 0x00000000 (ok)
Capabilities: 0x00000004 (SD presets)

Input : 2
Name : S-Video
Type : 0x00000002
Audioset : 0x00000001
Tuner : 0x00000000
Standard : 0x0000000000FFBFFF (PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60 NTSC-M/M-JP/M-KR SECAM-B/D/G/H/K/K1/L/Lc)
Status : 0x00000000 (ok)
Capabilities: 0x00000004 (SD presets)

Input : 3
Name : Composite3
Type : 0x00000002
Audioset : 0x00000001
Tuner : 0x00000000
Standard : 0x0000000000FFBFFF (PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60 NTSC-M/M-JP/M-KR SECAM-B/D/G/H/K/K1/L/Lc)
Status : 0x00000000 (ok)
Capabilities: 0x00000004 (SD presets)

v4l2-ctl –all

Driver Info (not using libv4l2):
Driver name : bttv
Card type : BT878 video (Leadtek WinFast 20
Bus info : PCI:0000:05:02.0
Driver version: 3.2.14
Capabilities : 0x05010015
Video Capture
Video Overlay
VBI Capture
Tuner
Read/Write
Streaming
Format Video Capture:
Width/Height : 320/240
Pixel Format : ‘YU12’
Field : Interlaced
Bytes per Line: 320
Size Image : 115200
Colorspace : Unknown (00000000)
Format Video Overlay:
Left/Top : 0/0
Width/Height: 320/240
Field : Any
Chroma Key : 0x00000000
Global Alpha: 0x00
Clip Count : 0
Clip Bitmap : No
Format VBI Capture:
Sampling Rate : 35468950 Hz
Offset : 244 samples (6.87926e-06 secs after leading edge)
Samples per Line: 2048
Sample Format : GREY
Start 1st Field : 7
Count 1st Field : 16
Start 2nd Field : 320
Count 2nd Field : 16
Framebuffer Format:
Capability : Clipping List
Flags :
Width : 0
Height : 0
Pixel Format : ”
Bytes per Line: 0
Size image : 0
Colorspace : Unknown (00000000)
Crop Capability Invalid:
Bounds : Left 68, Top 16, Width 1063, Height 608
Default : Left 186, Top 46, Width 924, Height 576
Pixel Aspect: 1135/944
Crop: Left 186, Top 46, Width 924, Height 576
Video input : 0 (Television: no hsync lock.)
Audio input : 0 (audio)
Frequency: 0 (0.000000 MHz)
Video Standard = 0x000000ff
PAL-B/B1/G/H/I/D/D1/K
Streaming Parameters Video Capture:
Frames per second: 25.000 (25/1)
Read buffers : 0
Tuner:
Name : Television
Capabilities : 62.5 kHz multi-standard
Frequency range : 44.0 MHz – 958.0 MHz
Signal strength/AFC : 0%/0
Current audio mode : lang1
Available subchannels: mono
Priority: 2

4 thoughts on “Capturing Video / Converting Hi8 Using avconv With Conexant/Brooktree 878 Tuner Card”

  1. Thanks for your post. I have a similar setup and I am running Linx Mint 14. I followed your sequence of commands and get the follwing error:

    matt@matt-mint ~ $ avconv -f alsa -i pulse -f video4linux2 -channel 2 -video_size 720×480 -i /dev/video0 -codec:a libfaac -b:a 192k -codec:v libx264 -b:v 6144k -vprofile main Output.mp4
    avconv version 0.8.4-6:0.8.4-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
    built on Nov 6 2012 16:51:11 with gcc 4.7.2
    [alsa @ 0x12b9060] capture with some ALSA plugins, especially dsnoop, may hang.
    [alsa @ 0x12b9060] Estimating duration from bitrate, this may be inaccurate
    Input #0, alsa, from ‘pulse’:
    Duration: N/A, start: 1356315277.699272, bitrate: N/A
    Stream #0.0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
    [video4linux2 @ 0x12b9840] Could not parse video size ‘720×480’.
    /dev/video0: Invalid argument

    I have read the man page and search for similar error messages but have not yet found a solution. I would greatly appreciate any suggestions.

    1. Seems like the capture device doesn’t support that video size? So you might have to back it down to 640×480 or something else. There’s the v4l2-ctl program that shows available video formats, I believe with the “–list-formats” option and the “-V, –get-fmt-video” option.

      There’s a manpage for v4l2-ctl here.

  2. With slower machines it’s better to capture with higher bitrate and less compression. If you have the time (and the disk space!) use a lossless codec like huffyuv or UT Video and then convert that file to x264 with slower, unachievable in realtime, settings giving you a much lower bitrate at virtually the same quality.
    I’m able to capture in an old single core Pentium 4 using -preset ultrafast and libmp3lame as the audio codec at relatively high bitrates, but still much lower than lossless bitrates. My settings:
    sudo avconv -f alsa -i pulse -f video4linux2 -channel 1 -i /dev/video0 -codec:a libmp3lame -b:a 192k -codec:v libx264 -b:v 8000k -vprofile main -preset ultrafast -tune film Output4.mkv
    Using -preset veryfast may also cut it.

  3. Hi!
    Very glad to find Your post.
    As I know, it is no need to use
    v4l2-ctl -i 2
    becouse later You use
    avconv -f alsa -i pulse -f video4linux2 -channel 2 …

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.