Difference between revisions of "Video streaming device"

From Finninday
Jump to: navigation, search
Line 63: Line 63:
 
* https://libav.org/avconv.html#Video-and-Audio-grabbing
 
* https://libav.org/avconv.html#Video-and-Audio-grabbing
 
* http://www.raspberrypi.org/forums/viewtopic.php?f=36&t=18202
 
* http://www.raspberrypi.org/forums/viewtopic.php?f=36&t=18202
 +
 +
====avconv====
 +
This works on the server, but I'm not able to view it on the client:
 +
<pre>
 +
avconv -f video4linux2 -i /dev/video0 -vcodec mpeg2video -r 25 -pix_fmt yuv420p -me_method epzs -b 2600k -bt 256k -f rtp rtp://10.0.0.5:8888
 +
avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
 +
  built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
 +
[video4linux2 @ 0x1697740] Estimating duration from bitrate, this may be inaccurate
 +
Input #0, video4linux2, from '/dev/video0':
 +
  Duration: N/A, start: 4674.494925, bitrate: 48660 kb/s
 +
    Stream #0.0: Video: rawvideo, yuyv422, 352x288, 48660 kb/s, 1000k tbn, 30 tbc
 +
Output #0, rtp, to 'rtp://10.0.0.5:8888':
 +
  Metadata:
 +
    encoder        : Lavf54.20.4
 +
    Stream #0.0: Video: mpeg2video, yuv420p, 352x288, 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 10.0.0.5
 +
t=0 0
 +
a=tool:libavformat 54.20.4
 +
m=video 8888 RTP/AVP 32
 +
b=AS:2600
 +
 +
Press ctrl-c to stop encoding
 +
</pre>

Revision as of 02:39, 17 December 2014

background

I'm trying to come up with something like a raspberry pi with a webcam attached that I can use to stream video to any old web browser on the local network.

The first use of this may be to put a "window" into a room that has no natural light by setting up a webcam looking out a window and then dedicating a tablet to display the streamed video from the other window.

Extra points for layering an image of curtains on top of the stream to make it look more like a real window.

old webcam

I'm able to use cheese or VLC to view the output of the Venus webcam just fine.

find the right protocol

My first working attempt at this uses ogg (theora vorbis)

The server has an attached webcam via usb and runs vlc with these settings:

:sout=#transcode{vcodec=theo,vb=800,acodec=vorb,ab=128,channels=2,samplerate=44100}:http{dst=:8080/stream.ogg} :sout-keep

The client displays this url:

http://localhost:8080/stream.ogg

That arrangement works when hosted from my fedora 20 laptop using builtin webcam, but not so much when I host from the my ubuntu 14.10 desktop and an external USB webcam.

The lag is pretty bad compared to a video call like skype or hangouts. I should be able to do better with some tuning.

find details of external webcam video output

vlc recognizes the external webcam as a video capture device titled "Venus USB2.0 Camera"

Clicking on "Information..." about the Venus capture device shows this codec info:

codec: packed YUV 4:2:2, YU:U:Y:V (YUY2)
resolution: 800x600
frame rate: 12.5

When I'm using VLC to open the Venus webcam, and then display codec information, I see this:

video codec: Packed YUV 4:2:2, Y:U:Y:V (YUY2)
resolution: 1280x1024
frame rate: 7.5
audio codec: PCM S32 LE (s32l)
channels: stereo
sample rate: 48,000Hz
bits per sample: 32


using motion works

http://www.instructables.com/id/Raspberry-Pi-remote-webcam/

But the video frame rate is pretty low and uses all the rasp cpu.

other tools

ffmpeg sounded cool so I gave it a try and got a deprecation error:

*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.

So I tried avconv.

avconv

This works on the server, but I'm not able to view it on the client:

avconv -f video4linux2 -i /dev/video0 -vcodec mpeg2video -r 25 -pix_fmt yuv420p -me_method epzs -b 2600k -bt 256k -f rtp rtp://10.0.0.5:8888
avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
  built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
[video4linux2 @ 0x1697740] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
  Duration: N/A, start: 4674.494925, bitrate: 48660 kb/s
    Stream #0.0: Video: rawvideo, yuyv422, 352x288, 48660 kb/s, 1000k tbn, 30 tbc
Output #0, rtp, to 'rtp://10.0.0.5:8888':
  Metadata:
    encoder         : Lavf54.20.4
    Stream #0.0: Video: mpeg2video, yuv420p, 352x288, 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 10.0.0.5
t=0 0
a=tool:libavformat 54.20.4
m=video 8888 RTP/AVP 32
b=AS:2600

Press ctrl-c to stop encoding