Using the Ion "Video Forever" USB video capture box on Linux

:!: Warning :!:
For some reason the audio inputs on the Video Forever won't work if PulseAudio attaches to them.
If it seems like the audio input on your card just doesn't work, follow the steps below to make PulseAudio ignore it.
I haven't bothered to debug this, because capturing through ALSA should give better A/V synchronisation anyway.

The Ion “Video Forever” is a fairly unremarkable USB2 video capture box. Hardware wise, it's very similar to the Terratec Grabby (linuxtv wiki link) but uses a different AC97 codec. I picked it up for some years ago from a Maplins bargain-bin for £30.

It identifies itself to the USB host as:

  • USB ID EB1A:5124 (Vendor ID 0xEB1A, Product ID 0x5124)
  • Product string “USB VIDBOX FW”
  • Serial number “USB2.0 VIDBOX FW”

It has composite and S-Video video inputs, and stereo audio inputs.

The EM28xx driver doesn't detect the Video Forever by default. To work around this –

Edit /etc/modules to add this line:

em28xx

Create /etc/modprobe.d/local-em28xx-ionvideo.conf with the following contents:

options em28xx card=67
install em28xx /sbin/modprobe --ignore-install em28xx $CMDLINE_OPTS && { echo eb1a 5124 > /sys/bus/usb/drivers/em28xx/new_id ; : ; }

These two changes cause the em28xx driver to load on boot, override the detected board ID to 67, and add the new USB ID to the em28xx driver when it loads.

Now create /etc/udev/rules.d/99-local-videoforever.rules with the following contents:

# Make PulseAudio ignore the Ion Video Forever capture card (it only works with ALSA)
SUBSYSTEM=="sound", ATTRS{idVendor}=="eb1a", ATTRS{idProduct}=="5124", ENV{PULSE_IGNORE}="1"

Here's a script to record the video from the Video Forever into an MP4 file:

#!/bin/bash -xe
 
# Start by finding the EM28xx device names
VDEV=$(readlink -f /dev/v4l/by-id/usb-eb1a_* | head -n1)
ADEV=$(grep -l 'eb1a:5124' /proc/asound/card*/usbid | head -n1 |sed -e 's:.*card::' -e's:/usbid::')
 
echo "Video device ${VDEV}"
echo "Audio device ${ADEV}"
 
 
# --- Set defaults ---
 
# Default to MPEG-4 AVC video compression at the specified bitrate, with AAC audio
# This is necessary to produce MP4 video which can be decoded with hardware decoders e.g. NVDEC
VSET="-profile:v high -pix_fmt yuv420p -level:v 4.1 -vcodec libx264"
VBITRATE=4M
 
# AAC audio
ASET="-acodec aac"
 
# Video encode preset
PRESET="-preset veryfast -b:v $VBITRATE"
 
# Default to scaling by storing the video as-captured but setting the DAR.
# Assume 4:3 unless we're told otherwise.
SCALE="-vf setdar=dar=4/3"
 
# --- Parse command line parameters ---
while (( "$#" )); do
	case "$1" in
		ffv1)
			# Switch to FFV1 (lossless) compression with uncompressed audio
			# --- Uncomment this to switch to Lossless FFV1.3, YUV422 mode, with a GOP size of 1
			# --- See https://trac.ffmpeg.org/wiki/Encode/FFV1
			# --- Output size is ~21-28GB per hour, per https://www.reddit.com/r/DataHoarder/comments/da1zpt/comment/f1n40dd/
			ASET="-acodec copy"
			VSET="-vcodec ffv1 -level 3 -coder 1 -context 1 -g 1 -slicecrc 1 -pix_fmt yuv422p -rtbufsize 50M"
			PRESET=""
			;;
 
		4x3)
			# Display aspect ratio: 4x3 (default)
			SCALE="-vf setdar=dar=4/3"
			;;
 
		16x9 | widescreen)
			# Display aspect ratio: 16x9 widescreen
			SCALE="-vf setdar=dar=16/9"
			;;
 
		mono-left)
			# Mono audio on the left channel only
			AMAP="-map_channel 1.0.0 -map_channel 1.0.0"
			;;
 
		mono-right)
			# Mono audio on the right channel only
			AMAP="-map_channel 1.0.1 -map_channel 1.0.1"
			;;
 
		*)
			break
			;;
 
		esac
	shift
done
 
 
# --- Run FFPMEG ---
 
ffmpeg \
	-f v4l2 -thread_queue_size 256 -video_size 720x576 -i ${VDEV} \
	-f alsa -thread_queue_size 1024 -i hw:${ADEV},0 \
	$SCALE \
	$VSET \
	$ASET \
	$AMAP \
	$PRESET \
	$1

The script is run like this:

./capture.sh [options] filename.mkv

The options available are:

  • ffv1: Uses FFV1 lossless compression with uncompressed audio instead of MPEG-4+AAC. If you have the disk space, capturing to FFV1 then transcoding will give better results (less chance of skipped frames).
  • 4×3, 16×9 or widescreen: Set the Display Aspect Ratio in the output file. This doesn't modify the pixel data captured from the card, only how it's shown during playback.
  • mono-left and mono-right are used to capture mono sources, where a single audio channel is passed into the left or right channel respectively. The mono channel will be converted into a stereo stream with both channels the same.

The PCB is labelled “EzCAP116 3.0”

Major parts on the board:

  • eMPIA EM2860 chipset
  • Silan SC8113 (SAA7113 clone) video decoder
  • 24C02 EEPROM
  • Sigmatel/IDT STAC9752AX-PRG AC97 audio processor
  • 12MHz crystal
  • 24.576MHz crystal
Find me on Mastodon
  • Last modified: 2024/10/16 14:43
  • by philpem