Using A Webcam With Mplayer


cosam

Active Member
Joined
Sep 1, 2008
Messages
703
Location
Netherlands
Website
www.cosam.org
From Youtube thread:

WizardStan said:

What kind of FPS are we talking here? And look at it this way, falling down the stairs has gotta be better than, say, falling off the roof.
 
Last edited by a moderator:
Just mplayer. I set it for 30fps and that's what I was getting. Didn't have to overclock or anything.
 
I have a C200 but I can't get the sound to work with mplayer or VLC. Have I missed a setting somewhere to get it working?
 
I'm not entirely certain. I can play and record sound from the webcam separately, but no matter what options I give it (including forceaudio, which should force it to have audio whether it exists or not) mplayer always says "no sound". Don't know why. Maybe the v4l2 driver is incomplete on the Pandora and doesn't support audio.
 
The audio from the webcam will had it's own entry in /dev probably /dev/dsp1 but not necessarily. You can force the audio from the webcam using:
forceaudio:adevice=/dev/dsp1

edit: spelling gremlin
 
yes, I did that. As I said, even with "forceaudio" mplayer still says there's no audio. It's as if v4l2 isn't even trying to open the audio stream.
 
WizardStan said:
yes, I did that. As I said, even with "forceaudio" mplayer still says there's no audio. It's as if v4l2 isn't even trying to open the audio stream.
That is indeed very odd. If I had a C200 I could probably figure it out, since I've recently tackled this kind of problem with a Dazzle video input device. Of course, in the case of that - I eventually just had to use the line-in on my PC and by-pass the Dazzle because a design flaw caused horrible sound artifacts that they later corrected by patching .. (ahem) .. I mean, clobbering the audio with an aggressive filter... using the Windows driver.

There should be nothing stopping you from using the built-in mic of the Pandora as your audio source though.
 
Last edited by a moderator:
mindlord said:
There should be nothing stopping you from using the built-in mic of the Pandora as your audio source though.
You'd think so, but it wouldn't even do that. I can record from /dev/dsp1 in other ways, but for some reason mplayer just refuses to open anything. "Audio: no sound" it says. I think it's just being lazy.
 
Last edited by a moderator:
WizardStan said:
You'd think so, but it wouldn't even do that. I can record from /dev/dsp1 in other ways, but for some reason mplayer just refuses to open anything. "Audio: no sound" it says. I think it's just being lazy.
Do we have mencoder? If so, does it behave the same way? I would check but my Pandora is off for repairs. It may be that our implementation of mplayer is lean on features - to save space and because the porter figured you'd be using it to capture audio/video from a webcam. Although not being able to see /dev/dsp is... not sane.
 
Last edited by a moderator:
Well, at the risk of derailing this thread further, I see that Logitech advertises the C200 as as using "RightSound technology" for the audio. Could this be the problem?

EDIT:I went to Linux UVC and they have the C200 listed as device 046d:0802, working. Please excuse my ignorance, but doesn't that mean that it should automatically work using v4l2? I'm confused as to why there seems to be no audio feed available at all.
 
pootle said:
Well, at the risk of derailing this thread further, I see that Logitech advertises the C200 as as using "RightSound technology" for the audio. Could this be the problem?

EDIT:I went to Linux UVC and they have the C200 listed as device 046d:0802, working. Please excuse my ignorance, but doesn't that mean that it should automatically work using v4l2? I'm confused as to why there seems to be no audio feed available at all.
The audio is there. I can record separately from the microphone built into the webcam no problem. Getting mplayer to play sound from a "tv" source is what is causing the problem. And it doesn't matter what audio source I select: webcam or internal microphone, both are being skipped by mplayer. This is not a hardware problem, it is 100% something to do with either mplayer itself or v4l2 driver. I'm a little worried about this because if it's a problem with a webcam, then it will also likely be a problem with a TV tuner.
 
Last edited by a moderator:
Thanks for the reply. Could I ask you to start up a new thread with all of this information in it? I think that these audio issues would be better discussed separately. I would do it but my knowledge goes as far as "it's not working, don't know why, ask WizardStan for details".
 
Cool, what command-line options do you have to use to get this working?

edit: never mind I found it.
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0
 
and to try and get audio:
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0:forceaudio:adevice=/dev/dsp1
or /dev/dsp for the internal microphone. mplayer simply doesn't load the audio stream though, either way. It's weird.
You can test the audio works by typing
cat /dev/dsp1 > /dev/dsp
That will pipe the audio from the camera's microphone directly into the speakers. There's a couple seconds lag, but that's normal when doing it this way. It has to do with how pipes and files and stuff work.
 
Better to use 'dd if=/dev/dsp1 of=/dev/dsp' in my opinion, as you can then accurately tune the block and sync options to reduce latency.
 
:blink:
Why the heck didn't I think of that? Brilliant sir!
Seriously, I've been catting files and devices in The Real World for a long time and being all "ugh, stupid buffer! I wish I could control you!". It never occurred to me to use dd to actually do so! Thank you!
 
Problem solved. The key is in the "immediatemode" option
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0:forceaudio:adevice=/dev/dsp1:immediatemode=0
immediatemode=1, the default for mplayer, means do not record sound. immediatemode=0, the default for mencoder, means record sound. The idea is that, in immediate mode, you have a cable connecting your TV capture card directly to the line in on your audio card, so there is no need for mplayer to handle the audio since it is being sent directly to the audio card, or to external speakers, allowing mplayer to display the image immediately.
 
I'm quoting from another thread, but it really belongs here

re: 'driverless' cams
WizardStan said:
Pleng said:
Mplayer just gives a 'no such driver: v412' error :(
That's supposed to be an 'l' (elle) not a '1' (one): vee four elle two. Video For Linux 2.
mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0

edit: fixed the resolution. 320x240 works better than 640x480.

OK So I got mplayer to recognize the cam by being less of a turd and actually using the corrected command line, but I got no video output, just the following text.

MPlayer SVN-r30165-4.3.3 (C) 2000-2009 MPlayer Team

Playing tv://.
TV file format detected.
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <olschewski@zpr.uni-koeln.de>
comment: first try, more to come ;-)
Selected device: USB2.0 PC CAMERA
Capabilites: video capture streaming
supported norms:
inputs: 0 = Camera 1;
Current input: 0
Current format: MJPEG
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffmjpeg] vfm: ffmpeg (FFmpeg MJPEG)
==========================================================================
Audio: no sound
Starting playback...
V: 0.0 1/ 1 ??% ??% ??,?% 0 0 
V: 0.0 2/ 2 ??% ??% ??,?% 0 0 
V: 0.0 3/ 3 ??% ??% ??,?% 0 0 
V: 0.0 4/ 4 ??% ??% ??,?% 0 0 
V: 0.0 5/ 5 ??% ??% ??,?% 0 0 
V: 0.0 6/ 6 ??% ??% ??,?% 0 0 
V: 0.0 7/ 7 ??% ??% ??,?% 0 0 
V: 0.0 8/ 8 ??% ??% ??,?% 0 0 
V: 0.0 9/ 9 ??% ??% ??,?% 0 0 
V: 0.0 10/ 10 ??% ??% ??,?% 0 0 
V: 0.0 11/ 11 ??% ??% ??,?% 0 0 
V: 0.0 12/ 12 ??% ??% ??,?% 0 0 
V: 0.0 13/ 13 ??% ??% ??,?% 0 0 
V: 0.0 14/ 14 ??% ??% ??,?% 0 0 
V: 0.0 15/ 15 ??% ??% ??,?% 0 0 
V: 0.0 16/ 16 ??% ??% ??,?% 0 0 
V: 0.0 17/ 17 ??% ??% ??,?% 0 0 
V: 0.0 18/ 18 ??% ??% ??,?% 0 0 
V: 0.0 19/ 19 ??% ??% ??,?% 0 0 
V: 0.0 20/ 20 ??% ??% ??,?% 0 0 
v4l2: 0 frames successfully processed, 0 frames dropped.

Exiting... (Quit)

This was captured on the second attempt. On the first attempt I'm sure I saw something along the lines of 'one thing not found, using another thing instead'. I didn't pay too much attention to it because I assumed if it was output on the first run, it would also be output in the second run. I guess that might be the key? Doesn't seem to be much else of interest in the above dump, does there?

I think I'll see if I can find an identical cam at a retailers and make an individual purchase. Then I can spend more time with it. I don't really think Mantana will fancy buying a bulk load if they're not gonna work.
 
Last edited by a moderator:
Back
Top