cosmicboy
Posts: 17
Joined: Mon Sep 03, 2012 9:25 am

output webcam directly via hdmi on tv

Mon Sep 17, 2012 9:08 am

Hello,

can anyone point me to how to display webcam images/movies directly on the tv via hdmi?
I have tried with mplayer but that does not do the trick for me.

Thanks for any hints
Marcel

User avatar
Bencom
Posts: 56
Joined: Wed Mar 07, 2012 10:40 pm
Location: New Zealand
Contact: Website

Re: output webcam directly via hdmi on tv

Tue Sep 18, 2012 3:48 am

startx and open a terminal then type.
mplayer tv://

See what it says. It may work. The two camera's I have do not work.
Basically the current (My bad again unstable) stable release has issues.
Last edited by Bencom on Tue Sep 18, 2012 4:07 am, edited 1 time in total.

User avatar
Bencom
Posts: 56
Joined: Wed Mar 07, 2012 10:40 pm
Location: New Zealand
Contact: Website

Re: output webcam directly via hdmi on tv

Tue Sep 18, 2012 4:05 am

My bad... apt-get install mplayer

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: output webcam directly via hdmi on tv

Tue Sep 18, 2012 4:24 am

Use vlc and open device /dev/video0 ?
You will need X to do that though.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
Bencom
Posts: 56
Joined: Wed Mar 07, 2012 10:40 pm
Location: New Zealand
Contact: Website

Re: output webcam directly via hdmi on tv

Tue Sep 18, 2012 6:24 am

VLC hates me. I have changed owners/permissions on video0 but have not been able to open it and no the logs give little clues without going deeper and maybe running in verbose/debug mode.

But nothing video works atm for me running an up to date wheezy.

Code: Select all

avconv -f video4linux2 -i /dev/video0 -vcodec mpeg2video -r 25 -pix_fmt yuv420p -me_method epzs -b 2600k -bt 256k -f rtp rtp://192.168.44.150:5004
avconv version 0.8.2-6:0.8.2-1+rpi1+b1, Copyright (c) 2000-2011 the Libav developers
  built on Jun 27 2012 01:07:05 with gcc 4.6.3
[video4linux2 @ 0x1d642e0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
  Duration: N/A, start: 217.090263, bitrate: 36864 kb/s
    Stream #0.0: Video: rawvideo, yuyv422, 320x240, 36864 kb/s, 30 tbr, 1000k tbn, 30 tbc
[buffer @ 0x1d642a0] w:320 h:240 pixfmt:yuyv422
[avsink @ 0x1d65ac0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x1d66080] w:320 h:240 fmt:yuyv422 -> w:320 h:240 fmt:yuv420p flags:0x4
Output #0, rtp, to 'rtp://192.168.44.150:5004':
  Metadata:
    encoder         : Lavf53.21.0
    Stream #0.0: Video: mpeg2video, yuv420p, 320x240, q=2-31, 2600 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> mpeg2video)
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.44.150
t=0 0
a=tool:libavformat 53.21.0
m=video 5004 RTP/AVP 32
b=AS:2600

Press ctrl-c to stop encoding
ioctl(VIDIOC_DQBUF): Input/output errorkB time=122.40 bitrate=1518.7kbits/s dup=2684 drop=0    
frame= 3061 fps= 25 q=1.6 Lsize=   22691kB time=122.40 bitrate=1518.7kbits/s dup=2684 drop=0    
video:22358kB audio:0kB global headers:0kB muxing overhead 1.487329%
Since getting my RPi's I have been working on making slow frame rate video and low rate audio available via tcp/http/rtp whatever.
Motion is ideal but has no audio. But I only need audio on demand when someone wants to enter.
Gate opener application. Several times it appeared upgraded software broke video and quick updates fixed them again.

The issues I have cross applications so it can not be the applications. The error, ioctl(VIDIOC_DQBUF): Input/output error, appears to come from the kernel.

User avatar
Bencom
Posts: 56
Joined: Wed Mar 07, 2012 10:40 pm
Location: New Zealand
Contact: Website

Re: output webcam directly via hdmi on tv

Tue Sep 18, 2012 6:38 am

I am also reluctant to throw resources into the issues such as new hubs and camera's at this point in time. Such things function no problems on a XP machine and worked on the RPi at some point. Also issues with usb have been prominent and I believe I have seen fixes rolled out. At first I could not run camera, keyboard and mouse together without a drop in tcp bandwidth to zero. Unplug the keyboard or mouse and traffic flowed again. No mater to me as the machine will be headless. This issue appears to have disappeared and another raised its ugly head as I am now able to run camera and Logitech MK320 wireless combo. The hub I have had more joy with is a unbranded 7 port powered hub.

Frustrating and a killer for development time on other aspects of the system and more time here reading and writing.

User avatar
Bencom
Posts: 56
Joined: Wed Mar 07, 2012 10:40 pm
Location: New Zealand
Contact: Website

Re: output webcam directly via hdmi on tv

Tue Sep 18, 2012 7:57 am

One more test with stuff I knew was running.
Steaming video was a breeze and multi day tests fine. But now...
Running the RPi headless with a fresh boot the machine ran fine for a while (Minute or so).
Then errors out. Running the same command sees real slow video with segmentation of the image.
The second crash destroyed the frame rate and size. The image is supposed to be 320x240 but after crash changed to 640x480 and the frame rate increased to 50 from 25 but the video is segmented and updates slow and the bps rate at the mux is up and down instead of steady as it is when things work nice. And I don't know anymore. :)

It would be nice if someone can reproduce on other camera's. The Genuis FaceCam1020 is a pretty up to date camera.

Code: Select all

~# avconv -f video4linux2 -i /dev/video0 -vcodec mpeg2video -r 25 -pix_fmt yuv420p -me_method epzs -b 2600k -bt 256k -f rtp rtp://192.168.44.150:5004
avconv version 0.8.2-6:0.8.2-1+rpi1+b1, Copyright (c) 2000-2011 the Libav developers
  built on Jun 27 2012 01:07:05 with gcc 4.6.3
[video4linux2 @ 0x16ff2e0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
  Duration: N/A, start: 77.850263, bitrate: 36864 kb/s
    Stream #0.0: Video: rawvideo, yuyv422, 320x240, 36864 kb/s, 30 tbr, 1000k tbn, 30 tbc
[buffer @ 0x16ff2a0] w:320 h:240 pixfmt:yuyv422
[avsink @ 0x1700ac0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x1701080] w:320 h:240 fmt:yuyv422 -> w:320 h:240 fmt:yuv420p flags:0x4
Output #0, rtp, to 'rtp://192.168.44.150:5004':
  Metadata:
    encoder         : Lavf53.21.0
    Stream #0.0: Video: mpeg2video, yuv420p, 320x240, q=2-31, 2600 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> mpeg2video)
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.44.150
t=0 0
a=tool:libavformat 53.21.0
m=video 5004 RTP/AVP 32
b=AS:2600

Press ctrl-c to stop encoding
ioctl(VIDIOC_DQBUF): Input/output errorkB time=58.76 bitrate=1356.0kbits/s dup=1269 drop=0    
frame= 1471 fps= 25 q=2.0 Lsize=    9756kB time=58.80 bitrate=1359.3kbits/s dup=1269 drop=0    
video:9608kB audio:0kB global headers:0kB muxing overhead 1.542968%
[email protected]:~# avconv -f video4linux2 -i /dev/video0 -vcodec mpeg2video -r 25 -pix_fmt yuv420p -me_method epzs -b 2600k -bt 256k -f rtp rtp://192.168.44.150:5004
avconv version 0.8.2-6:0.8.2-1+rpi1+b1, Copyright (c) 2000-2011 the Libav developers
  built on Jun 27 2012 01:07:05 with gcc 4.6.3
[video4linux2 @ 0x119e2e0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
  Duration: N/A, start: 188.574576, bitrate: 36864 kb/s
    Stream #0.0: Video: rawvideo, yuyv422, 320x240, 36864 kb/s, 30 tbr, 1000k tbn, 30 tbc
[buffer @ 0x119e2a0] w:320 h:240 pixfmt:yuyv422
[avsink @ 0x119fac0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x11a0080] w:320 h:240 fmt:yuyv422 -> w:320 h:240 fmt:yuv420p flags:0x4
Output #0, rtp, to 'rtp://192.168.44.150:5004':
  Metadata:
    encoder         : Lavf53.21.0
    Stream #0.0: Video: mpeg2video, yuv420p, 320x240, q=2-31, 2600 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> mpeg2video)
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.44.150
t=0 0
a=tool:libavformat 53.21.0
m=video 5004 RTP/AVP 32
b=AS:2600

Press ctrl-c to stop encoding
ioctl(VIDIOC_DQBUF): Input/output errorkB time=37.20 bitrate=1272.4kbits/s dup=798 drop=0    
frame=  938 fps= 25 q=2.0 Lsize=    5867kB time=37.48 bitrate=1282.3kbits/s dup=803 drop=0    
video:5771kB audio:0kB global headers:0kB muxing overhead 1.659189%
[email protected]:~# avconv -f video4linux2 -i /dev/video0 -vcodec mpeg2video -r 25 -pix_fmt yuv420p -me_method epzs -b 2600k -bt 256k -f rtp rtp://192.168.44.150:5004
avconv version 0.8.2-6:0.8.2-1+rpi1+b1, Copyright (c) 2000-2011 the Libav developers
  built on Jun 27 2012 01:07:05 with gcc 4.6.3
[video4linux2 @ 0x19722e0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
  Duration: N/A, start: 273.526595, bitrate: 147456 kb/s
    Stream #0.0: Video: rawvideo, yuyv422, 640x480, 147456 kb/s, 30 tbr, 1000k tbn, 30 tbc
[buffer @ 0x19722a0] w:640 h:480 pixfmt:yuyv422
[avsink @ 0x1973ac0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x1974080] w:640 h:480 fmt:yuyv422 -> w:640 h:480 fmt:yuv420p flags:0x4
Output #0, rtp, to 'rtp://192.168.44.150:5004':
  Metadata:
    encoder         : Lavf53.21.0
    Stream #0.0: Video: mpeg2video, yuv420p, 640x480, q=2-31, 2600 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> mpeg2video)
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.44.150
t=0 0
a=tool:libavformat 53.21.0
m=video 5004 RTP/AVP 32
b=AS:2600

Press ctrl-c to stop encoding
^C^Ce=  362 fps=  7 q=2.0 size=    3820kB time=14.44 bitrate=2167.3kbits/s dup=357 drop=0 

cosmicboy
Posts: 17
Joined: Mon Sep 03, 2012 9:25 am

Re: output webcam directly via hdmi on tv

Tue Sep 18, 2012 8:01 am

Hello, streaming video using ffserver does work, however when I am starting the following command, all I receive is a green square on the tv:

mplayer tv:///dev/video0 -fps 10

I do have a logitec C270 webcam, if this information is of any interest.

User avatar
Bencom
Posts: 56
Joined: Wed Mar 07, 2012 10:40 pm
Location: New Zealand
Contact: Website

Re: output webcam directly via hdmi on tv

Tue Sep 18, 2012 8:15 am

I tested this command and got segmented images in between the green screens with the Genuis and nothing with the Logitech. Given the finding regarding things changing after errors I guess I need to test with a fresh boot. Possibly the problem is with buffer code in the video core.

User avatar
Bencom
Posts: 56
Joined: Wed Mar 07, 2012 10:40 pm
Location: New Zealand
Contact: Website

Re: output webcam directly via hdmi on tv

Tue Sep 18, 2012 8:56 am

With a fresh boot. Genius FaceCam 1020... Same result. Best result with fps = 1 with a few segmented images when it gets it right otherwise green screen of death.

I would expect this is the most basic way to get a camera image to screen.

Code: Select all

mplayer -v tv:///dev/video0 -fps 1
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
CPU: ARM
get_path('codecs.conf') -> '/root/.mplayer/codecs.conf'
Reading optional codecs config file /root/.mplayer/codecs.conf: No such file or directory
Reading optional codecs config file /etc/mplayer/codecs.conf: No such file or directory
Using built-in default codecs.conf.
init_freetype
Using Unoptimized OnScreenDisplay
get_path('fonts') -> '/root/.mplayer/fonts'
Configuration: --prefix=/usr --confdir=/etc/mplayer --enable-xvmc --enable-menu --disable-arts --language=all --disable-dvdread-internal --disable-libdvdcss-internal --disable-libmpeg2-internal --disable-ffmpeg_a --enable-debug --enable-joystick --disable-gui
CommandLine: '-v' 'tv:///dev/video0' '-fps' '1'
Using nanosleep() timing
get_path('input.conf') -> '/root/.mplayer/input.conf'
Reading optional input config file /root/.mplayer/input.conf: No such file or directory
Parsing input config file /etc/mplayer/input.conf
Input config file /etc/mplayer/input.conf parsed: 92 binds
Setting up LIRC support...
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
get_path('video0.conf') -> '/root/.mplayer/video0.conf'

Playing tv:///dev/video0.
get_path('sub/') -> '/root/.mplayer/sub/'
The filename option must be an integer: dev/video0
Struct tv, field filename parsing error: dev/video0
STREAM: [tv] tv:///dev/video0
STREAM: Description: TV Input
STREAM: Author: Benjamin Zores, Albeu
STREAM: Comment: 
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <[email protected]>
 comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: FaceCam 1020
 Capabilities:  video capture  streaming
 supported norms:
 inputs: 0 = Camera 1;
 Current input: 0
 Format YUYV   (16 bits, YUV 4:2:2 (YUYV)): Packed YUY2
 Format MJPEG  ( 0 bits, MJPEG): Unknown 0x47504a4d
 Current format: YUYV
v4l2: set format: YVU420
v4l2: ioctl set format failed: Invalid argument
v4l2: set format: YUV420
v4l2: ioctl set format failed: Invalid argument
v4l2: set format: UYVY
v4l2: ioctl set format failed: Invalid argument
v4l2: set format: YUYV
v4l2: set input: 0
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
Selected norm : pal
v4l2: ioctl enum norm failed: Invalid argument
Error: Cannot set norm!
Selected input hasn't got a tuner!
==> Found video stream: 0
v4l2: get format: YUYV
v4l2: get fps: 30.000000
v4l2: get width: 640
v4l2: get height: 480
Using a ring buffer for maximum 2 frames, 1 MB total size.
v4l2: ioctl set mute failed: Invalid argument
v4l2: set Brightness: -128 [-128, 127]
v4l2: set Hue: -128 [-128, 127]
v4l2: set Saturation: 200 [0, 200]
v4l2: set Contrast: 255 [60, 255]
[V] filefmt:9  fourcc:0x32595559  size:640x480  fps:30.000  ftime:=0.0333
get_path('sub/') -> '/root/.mplayer/sub/'
v4l2: going to capture
X11 opening display: 
vo: couldn't open the X11 display ()!
X11 opening display: 
vo: couldn't open the X11 display ()!
SDL SetVideoMode failed: OpenGL not available
X11 opening display: 
vo: couldn't open the X11 display ()!
VO XOverlay need a subdriver
v4l2: select timeout
[VO_SDL] Using driver: fbcon.
X11 opening display: 
vo: couldn't open the X11 display ()!
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
VDec: vo config request - 640 x 480 (preferred colorspace: Packed YUY2)
Trying filter chain: vo
VDec: using Packed YUY2 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
VO Config (640x480->640x480,flags=0,'MPlayer',0x32595559)
VO: [sdl] 640x480 => 640x480 Packed YUY2 
VO: Description: SDL YUV/RGB/BGR renderer (SDL v1.1.7+ only!)
VO: Author: Ryan C. Gordon <[email protected]>, Felix Buenemann <[email protected]>
SDL: Using 0x32595559 (Packed YUY2) image format
SDL: using hardware-surface
SDL: setting zoomed fullscreen with modeswitching
SDL Mode: 0:  1600 x 1200
SDL Mode: 1:  1920 x 1080
SDL Mode: 2:  1280 x 1024
SDL Mode: 3:  1024 x 1024
SDL Mode: 4:  1280 x 960
SDL Mode: 5:  1152 x 864
SDL Mode: 6:  1024 x 768
SDL Mode: 7:  800 x 600
SDL Mode: 8:  768 x 576
SDL Mode: 9:  640 x 480
SET SDL Mode: 9:  640 x 480
Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)
==========================================================================
Audio: no sound
Freeing 0 unused audio chunks.
FPS forced to be 1.000  (ftime: 1.000).
Starting playback...
*** [vo] Exporting mp_image_t, 640x480x16bpp YUV packed, 614400 bytes
Unicode font: 5179 glyphs.
Unicode font: 5179 glyphs.
V:   0.0   2/  2  0% 13%  0.0% 0 0 
v4l2: select timeout
V:   0.0   3/  3  0%  7%  0.0% 0 0 
v4l2: select timeout
V:   0.0   4/  4  0%  5%  0.0% 0 0 
v4l2: select timeout
V:   0.0   5/  5  0%  4%  0.0% 0 0 
v4l2: select timeout
V:   0.0   6/  6  0%  4%  0.0% 0 0 
v4l2: select timeout
V:   0.0   9/  9  0%  3%  0.0% 0 0 
v4l2: select timeout
V:   0.0  10/ 10  0%  3%  0.0% 0 0 
v4l2: select timeout
V:   0.0  11/ 11  0%  2%  0.0% 0 0 
v4l2: select timeout
V:   0.0  12/ 12  0%  2%  0.0% 0 0 


MPlayer interrupted by signal 2 in module: sleep_timer
V:   0.0  13/ 13  0%  2%  0.0% 0 0 
Uninit video: raw
v4l2: select timeout
v4l2: ioctl set mute failed: Invalid argument
v4l2: 6 frames successfully processed, 271 frames dropped.
v4l2: up to 1 video frames buffered.
vo: x11 uninit called but X11 not initialized..

Return to “Graphics, sound and multimedia”