contention for /dev/video0 by two devices

On my recently built a 64-bit (AMD) machine with OpenSuse 12.3 as the only OS, in order to learn while playing, I have been exploring with mencoder on the command line to get my EasyCap DC60 USB capture device going. Once almost there, as a diversion, I plugged in my Logitech C910 USB webcam. It snatched the /dev/video0 device node and I cannot get it back.

With neither device plugged in, video0 is not present in /dev. When only the cam is plugged in, video0 is in /dev.

With only the EasyCap plugged in, em28xx adds devices v4l, vbio and video0 to /dev, exactly as it did previously. But mencoder now sees nothing on the /dev/video0 device.

It seems to me that I need to take over assignment of a /dev/videoN for it. I have installed v4l2-ctl and nosed around but it seems to be about device settings, whereas I need to set some driver configuration parameter(s) I think. But I cannot find out which one(s), where to find it(them) or how to set or change it(them) safely. I had one shot, editng the tv.conf file, shifting the active em28xx to minor 3, as below:

cat /etc/modprobe.d/50-tv.conf

alias char-major-81 videodev

YaST configured TV card

tv.nouniqkey0:Easy Cap Capture DC-60

alias char-major-81-0 off
alias char-major-81-1 off
alias char-major-81-2 off
alias char-major-81-3 em28xx
options em28xx card=64

YAST2 then saw the TV device as number 3, but em28xx still set up device node /dev/video0 instead of video3 as I had hoped, so I have reversed that.

Am I looking in the right direction? Please advise on what I sould do, or what I should read?

Thanks,
Roger

I don’t have a good handle on what you’re trying to do (and I don’t have time to read this again the moment), but udev rules can be used to generate persistent (predictable) naming if required. It’s just a matter of creating a custom rule to uniquely identify and name the particular hardware device. I’ll just point you at some links to give you the basic idea, and leave you to flesh out the details

Device Filenames and udev - MythTV Official Wiki
LinHES - Predictable video assignment for HD-PVR using udev
https://wiki.archlinux.org/index.php/Udev#Video_devices

I don’t have a TV card, nor have I recently attempted to conduct a video capture with mencoder. I do have a Logitech C910 webcam thou. I note with my webcam plugged in since the last boot, I have the following kernel modules loaded:


oldcpu@corei7-920:/dev> lsmod | grep video
uvcvideo               84941  0 
videobuf2_core         35910  1 uvcvideo
videodev              129333  2 uvcvideo,videobuf2_core
videobuf2_vmalloc      13021  1 uvcvideo
videobuf2_memops       13645  1 videobuf2_vmalloc

I recall that there was an mplayer vs mplayer2 software fork, where one difference between the two versions was mplayer came with mencoder and mplayer2 did not … one thing that I have been told is that support for mencoder has stopped in mplayer. Hence if that is true, even if you do succeed, mencoder is IMHO likely to be phased out (TBD ? timeframe) and not longer available. Hence your efforts wrt mencoder even if successful, will not be something you can use for too long.

The command line I used to caputure video (with no sound) with mencoder some years back was:


mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -ofps 60 -nosound -ovc lavc -lavcopts vcodec=mjpeg -o test.avi

and with sound (which was desynchronized to the video):


mencoder tv:// -tv driver=v4l2:width=800:height=600:device=/dev/video0:forceaudio:immediatemode=0:alsa:adevice=hw.1,0 -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o webcam.avi

Given the future of mencoder is somewhat bleak, I don’t plan to spend any more time investigating mencoder use.

What works for me with ffmpeg (in case you decide to try that instead of mencoder (where audio synchronisation is closer) :


ffmpeg -f alsa -ac 2 -i hw:1,0 -itsoffset 00:00:00.5 -f video4linux2 -s 320x240 -i /dev/video0 out.mpg

where the offset can be tuned to try to obtain better audio/voice synchronisation.

old thread is here: https://forums.opensuse.org/english/other-forums/community-fun/general-chit-chat/415024-webcam-microphone-command-line-fun.html but I caution that some of worked in that thread does not work now, as applications and openSUSE has changed since. ie the lines with /dev/dsp or /dev/dsp1 no longer work ‘as is’.

What mencoder execution lines are you using ?

Many thanks, Deano. I have taken a peep at the LinHES article and would say that you perfectly understood what I am after and this will let me find the solution. I’ll report progress.

The name MythTV makes me quake as I believe it is a giant which I am keen to conquer when my knowledge and experience are far greater than at the moment.

Thanks again for your input.

Thanks for your input. (Bet my human CPU is older than yours!)

My difficulty was not with mencoder, but with the seizure by the cam (or more accurately the driver) of video0. In fact I only want to use mencoder to grab the content from a handful of VHS tapes to be stored on disc. I will probably never acquire more tapes, so the doubt over mencoder’s prospects do not worry me. But I do like always to know the nature of problems and get them sorted.

I had got the video going fine with the -nosound option as it seemed wise to tackle one thing at a time. The next step was to take a look at alsa and get the sound. The grand scheme was then to do an uncompressed (huge) grab of both to hard disc and then experiment with that to get the final form. Once I have control over who gets video0 device node, I shall carry on along that road.

Thanks for your helpt.

On 05/16/2013 07:06 AM, rogersim wrote:
>
> Many thanks, Deano. I have taken a peep at the LinHES article and would
> say that you perfectly understood what I am after and this will let me
> find the solution. I’ll report progress.
>
> The name MythTV makes me quake as I believe it is a giant which I am
> keen to conquer when my knowledge and experience are far greater than at
> the moment.

Sorry to come to this thread late, but udev is exactly the way you keep the
/dev/videoX devices the same boot after boot.

MythTV has a nearly vertical learning curve as is true for nearly every
complicated piece of software. I too have a device that uses em28xx as its
driver. In my case, sound is complicated as it seems that my sound card has a
faulty line input circuit, and I have to use the USB sound driver to input
sound. MythTV has problems with that configuration so I took that tuner away
from MythTV and use TvTime for the video and sox for the audio. As it is only
used for live TV, the lack of recording is not a problem.

BTW, my human CPU is 73. It is possible for ancient equipment to function.

Am slightly abashed to find that a whole chapter (12) of the manual is devoted to udev, which is what is needed to handle my problem. Thanks for confirmation that I am now headed in the right direction. There was I wielding a hammer, unaware that somebody had invented the nutcracker.

OK, your processor is two years older than mine.

Thanks for the update. Let us know how you get on.