トップ 最新 追記

Masa's blog

検索キーワード:

2016年10月13日 USB video and audio capture cable(Princeton PCA-DAV3) with Slackware64-14.2 [長年日記]

_ Settings

/etc/modprobe.d/em28xx.conf

install em28xx /sbin/modprobe --ignore-install em28xx card=72; /bin/echo "117f 5207" > /sys/bus/usb/drivers/em28xx/new_id

/etc/udev/rules.d/99-pca-dav3.rules

SUBSYSTEM=="usb", ATTRS{idVendor}=="117f",ATTRS{idProduct}=="5207",RUN+="/sbin/modprobe em28xx card=72"

Stop Pulseaudio

PCA-DAV3 couldn't capture audio with Pulseaudio (and Jack). So I decide to stop Pulseaudio (and Jack) temporarily when I use PCA-DAV3 :P

$ cp /etc/pulse/client.conf ~/.pulse/client.conf

~/.pulse/client.conf

  • change to "autospawn = no"
  • change to "daemon-binary = /bin/true"

create ~/.asoundrc

pcm.!default {
	type hw
	card 0
}

ctl.!default {
	type hw
	card 0
}
$ pulseaudio --kill

Then PCA-DAV3 handle ALSA driver directly :)

_ Get informations

$ lsusb
Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 004: ID 117f:5207                                          <-- THIS IS PCA-DAV3
Bus 003 Device 003: ID 056e:0084 Elecom Co., Ltd
Bus 003 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ v4l2-ctl --list-device
Gadmei UTV330+ (usb-0000:00:1a.0-1.6):
        /dev/video0
        /dev/vbi0
$ cd /usr/src/linux
$ egrep -ir UTV330
./drivers/media/usb/em28xx
./drivers/media/usb/em28xx/em28xx-cards.c:      [EM2860_BOARD_GADMEI_UTV330] = {
./drivers/media/usb/em28xx/em28xx-cards.c:              .name         = "Gadmei UTV330",
./drivers/media/usb/em28xx/em28xx-cards.c: [EM2861_BOARD_GADMEI_UTV330PLUS] = {
./drivers/media/usb/em28xx/em28xx-cards.c:              .name         = "Gadmei UTV330+",
./drivers/media/usb/em28xx/em28xx-cards.c:                      .driver_info = EM2860_BOARD_GADMEI_UTV330 },
./drivers/media/usb/em28xx/em28xx-cards.c:      {0x4ba50080, EM2861_BOARD_GADMEI_UTV330PLUS, TUNER_TNF_5335MF},
./drivers/media/usb/em28xx/em28xx.h:#define EM2860_BOARD_GADMEI_UTV330 37
./drivers/media/usb/em28xx/em28xx.h:#define EM2861_BOARD_GADMEI_UTV330PLUS 72 <-- I choose this for card number of PCA-DAV3.
$ cat /proc/asound/cards
 0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xe4230000 irq 27
 1 [Device         ]: USB-Audio - USB 2861 Device                           <-- THIS IS PCA-DAV3
                      USB 2861 Device at usb-0000:00:1a.0-1.6, high speed   <-- THIS IS PCA-DAV3
$ cat /proc/asound/devices
  1:        : sequencer
  2: [ 0]   : control
  3: [ 0- 0]: digital audio playback
  4: [ 0- 0]: digital audio capture
  5: [ 0- 3]: digital audio playback
  6: [ 0- 0]: hardware dependent
  7: [ 0- 3]: hardware dependent
  8: [ 1]   : control                  <-- THIS IS PCA-DAV3
  9: [ 1- 0]: digital audio capture    <-- THIS IS PCA-DAV3
 33:        : timer
$ cat /proc/asound/modules
 0 snd_hda_intel
 1 snd_usb_audio   <-- THIS IS PCA-DAV3
$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VC Analog [ALC269VC Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Device [USB 2861 Device], device 0: USB Audio [USB Audio]   <-- THIS IS PCA-DAV3
  Subdevices: 0/1                                                   <-- THIS IS PCA-DAV3
  Subdevice #0: subdevice #0                                        <-- THIS IS PCA-DAV3

_ Play command example

$ mplayer tv:// -tv driver=v4l2:device=/dev/video0:norm=NTSC:input=1:width=640:height=480:fps=24:alsa:adevice=hw.1,0:amode=1:immediatemode=0:audiorate=48000 -vf pp=lb -aspect 4:3
  • driver=v4l2 ... driver for video
  • device=/dev/video0 ... device of PCA-DAV3 for video
  • norm=NTSC ... must be specified value for PCA-DAV3
  • input=1 ... input from composit
  • width=640:height=480:fps=24 ... output size, framerate
  • alsa ... driver for audio
  • adevice=hw.1,0 ... device of PCA-DAV3 for audio
  • amode=1 ... input is stereo
  • immediatemode=0 ... capture both of video and audio
  • audiorate=48000 ... must be specified value for PCA-DAV3
  • -vf pp=lb ... de-interlace
  • -aspect 4:3 ... aspect ratio

_ Capture command example(mencoder)

$ mencoder -really-quiet tv:// -tv driver=v4l2:device=/dev/video0:norm=NTSC:input=1:width=640:height=480:alsa:adevice=hw.1,0:amode=1:immediatemode=0:audiorate=48000 -ovc x264 -x264encopts "bitrate=1000" -oac mp3lame -lameopts "br=224" -of lavf -lavfopts "format=mp4" -vf pp=lb -endpos 01:10:00 -aspect 4:3 -o out.mp4
  • -ovc x264 ... video codec
  • -x264encopts "bitrate=1000" ... video bitrate
  • -oac mp3lame ... audio codec
  • -lameopts "br=224" ... audio bitrate
  • -of lavf -lavfopts "format=mp4"
  • -endpos 00:02:00 ... recording time
  • -o out.mp4 ... output file name

_ Capture command example(ffmpeg with v4l2-ctl)

You need to set video standard to NTSC and video input to composite(1) and audio mute to disable(0) before running ffmpeg.

$ v4l2-ctl --set-standard=ntsc --set-input=1 --set-ctrl=mute=0

and then You can run ffmpeg correctly :)

$ ffmpeg -loglevel error -y -f v4l2 -channel 1 -s 640x480 -thread_queue_size 1024 -i /dev/video0 -f alsa -thread_queue_size 1024 -i hw:1,0 -acodec libfaac -ab 224k -vcodec libx264 -b:v 1000k -bsf:a aac_adtstoasc -vsync -1 -async 100 -deinterlace -to "01:10:00" -f mp4 out2.mp4
  • -loglevel error ... reduce log message
  • -y ... over write mode
  • -f v4l2 ... specify video4linux2 for video format
  • -channel 1 ... specify composite for video input
  • -s 640x480 ... output video size
  • -thread_queue_size 1024 ... buffer for video stream to fix "ALSA buffer xrun"
  • -i /dev/video0 ... video device
  • -f alsa ... specify alsa for audio format
  • -thread_queue_size 1024 ... buffer for audio stream to fix "ALSA buffer xrun"
  • -i hw:1,0 ... audio device
  • -acodec libfaac ... audio codec
  • -ab 224k ... audio bitrate
  • -vcodec libx264 ... video codec
  • -b:v 1000k video bitrate
  • -bsf:a aac_adtstoasc ... Convert MPEG-2/4 AAC ADTS to MPEG-4 Audio Specific Configuration bitstream filter
  • -vsync -1 -async 100 ... sync video and audio
  • -deinterlace ... de-interlace
  • -to "01:10:00" ... recording time
  • -f mp4 ... output file format
  • out2.mp4 ... output file name

_ After finishing to use PCA-DAV3

Restore audio environment to original state.

$ rm ~/.pulse/client.conf
$ rm ~/.asoundrc
$ pulseaudio --start