| YaK:: The Yak tries Linux Webcam Video | [Changes] [Calendar] [Search] [Index] [PhotoTags] |
Using Ubuntu Desktop 8.02 (Hardy Heron), a little Logitech pokéball-shaped webcam is automatically recognized by the kernel.
With System > Administration > Synaptic Package Manager, we search for "webcam" and find "camorama".
Install it, and run "camorama" at the command line. It just works.
...
What we want:
A videoconference server and client screen, for multiple people to connect to.
Records cam video to avi
ffmpeg -r 20 -f video4linux2 -s 352x288 -i /dev/video0 -an -f avi ./test.avi
Streams to a player at 192.169.9.107 listening on port 1234
ffmpeg -f video4linux2 -s cif -r 15 -i /dev/video0 -v 0 -vcodec mpeg4 -f mpegts udp:192.168.9.107:1234
ffserver sample config file: http://www.ffmpeg.org/sample.html
ubuntu webcam through ffserver and ffmpeg example: http://ubuntuforums.org/archive/index.php/t-665607.html
|
10062 ? S 0:01 gedit file:///home/strick/build/ffmpegTest/ffserverEx2.conf
10109 pts/1 S+ 0:04 ffserver -d -f ffserverEx2.conf 10120 pts/3 S+ 0:55 ffmpeg -r 15 -s 352x288 -f video4linux2 -i /dev/video0 http://localhost:8090/feed1.ffm |
Port 8090 # bind to all IPs aliased or not BindAddress 0.0.0.0 # max number of simultaneous clients MaxClients 1000 # max bandwidth per-client (kb/s) MaxBandwidth 10000 # Suppress that if you want to launch ffserver as a daemon. NoDaemon <Feed feed1.ffm> File /tmp/feed1.ffm FileMaxSize 5M </Feed> # ASF output - for windows media player <Stream test.mpg> # the source feed Feed feed1.ffm # the output stream format - ASF Format mpegts VideoCodec mpeg4 # this must match the ffmpeg -r argument VideoFrameRate 15 # generally leave this is a large number VideoBufferSize 80000 # another quality tweak VideoBitRate 200 # quality ranges - 1-31 (1 = best, 31 = worst) VideoQMin 1 VideoQMax 5 VideoSize 352x288 # this sets how many seconds in past to start PreRoll 0 # wecams don't have audio Noaudio </Stream> |
combines video: ffmpeg -i test1.avi -i test2.avi -vcodec copy -vcodec copy test12.avi -newvideo
gstreamer test: gst-launch-0.10 videotestsrc \! autovideosink
gstreamer + commandline toys: http://noraisin.net/~jan/diary/?p=40
|
More Working Stuff:
gst-launch-0.10 v4l2src ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! xvimagesink gst-launch-0.10 -v -vv v4l2src ! queue ! video/x-raw-yuv,width=320,height=240,framerate="(fraction)10/1" ! queue ! videorate ! videoscale ! ffmpegcolorspace ! xvimagesink Sender: might be working: but not with receiver? gst-launch-0.10 -v -vv v4l2src ! queue ! video/x-raw-yuv,width=320,height=240,framerate="(fraction)10/1" ! queue ! videorate ! videoscale ! ffmpegcolorspace ! queue ! tcpserversink host=192.168.9.106 port=5555
|
OLPC on GStreamer: http://wiki.laptop.org/go/GStreamer
~ Saturday Jan 11, 2009 - Found out Uhura was using an old version of Ubuntu. Upgraded it to the latest version and Video LAN Client works in capturing video now. VLC 0.9.x uses Video4Linux2 which has better support for webcams.
~Ryan
~ I think VLC interfaces or bindings are the way to go. http://wiki.videolan.org/Interface VLC already works to stream and capture, we can build a new interface for it, tuned to our needs. See "Build an application on VLC" here: http://wiki.videolan.org/Developers_Corner
~Ryan
MORE NOTESshowing all 19 messages [Show 3 7 *10* 14 30 100 999 days or 10 *30* 50 100 999 messages] |
|
|
[edit]
|
|
|
[edit]
|
|
|
[edit]
|
|
WORKS ON WINDOWS:
$ /c/gstreamer/bin/gst-launch-0.10.exe videotestsrc ! video/x-raw-yuv,width=800,height=600 ! ffmpegcolorspace ! dshowvideosink |
|
|
[edit]
|
|
FROM WINDOWS TO LINUX, one frame every 5 secs or so:
$ /c/gstreamer/bin/gst-launch-0.10.exe dshowvideosrc ! video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! theoraenc ! queue ! gdppay ! udpsink host=192.168.0.156 port=4321
|
|
|
[edit]
|
|
RECEIVING IT ON LINUX:
gst-launch-0.10 udpsrc port=4321 ! gdpdepay ! theoradec ! video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! xvimagesink (must start the receiver first, then the sender) |
|
|
[edit]
|
|
Broadcast:
[lx] gst-launch -v v4l2src ! video/x-raw-yuv,width=640,height=480,"framerate=(fraction)10/1" ! smokeenc keyframe=30 ! progressreport ! udpsink port=5000 Listen: [lx] gst-launch-0.10 -v udpsrc port=5000 ! smokedec ! video/x-raw-yuv ! xvimagesink [win] /c/gstreamer/bin/gst-launch-0.10.exe -v udpsrc port=5000 ! smokedec ! video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! dshowvideosink |
|
|
[edit]
|
strick@uhura:~/Desktop$ cat /tmp/gstreamer-dual-video.shar cat <<'END' >linux-recv.txt DISPLAY=unix:0 gst-launch-0.10 -v udpsrc port=5000 ! smokedec ! video/x-raw-yuv ! xvimagesink END cat <<'END' >linux-send.txt gst-launch-0.10 -v v4l2src ! video/x-raw-yuv,width=640,height=480,framerate="(fraction)10/1" ! smokeenc keyframe=30 ! udpsink port=5000 host=192.168.0.155 END cat <<'END' >win-recv.txt gst-launch-0.10.exe -v udpsrc port=5000 blocksize=64000 buffer-size=99999 ! smokedec ! video/x-raw-yuv ! ffmpegcolorspace ! dshowvideosink END cat <<'END' >win-send.txt /c/gstreamer/bin/gst-launch-0.10.exe -v dshowvideosrc ! video/x-raw-yuv,width=640,height=480,"framerate=(fraction)10/1" ! smokeenc keyframe=30 ! progressreport ! udpsink port=5000 host=192.168.0.156 END strick@uhura:~/Desktop$ |
|
|
[edit]
|
|
LINUX AUDIO SENDER:
gst-launch-0.10 alsasrc ! audioconvert -v ! audio/x-raw-int,channels=1 ! mulawenc ! audio/x-mulaw,channels=1,rate=8000 ! udpsink port=9001 host=127.0.0.1 LINUX AUDIO RECEIVER: gst-launch-0.10 -vvv -m udpsrc port=9001 ! audio/x-mulaw,channels=1,rate=8000 ! queue ! mulawdec ! audio/x-raw-int,channels=1 ! alsasink
|
|
|
[edit]
|
|
SMOKE UDP
gst-launch-0.10 -vm v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=\(fraction\)5/1,format=\(fourcc\)YUY2 ! ffmpegcolorspace ! smokeenc ! udpsink port=9876 host=pidi sync=false
gst-launch-0.10 udpsrc port=9876 ! smokedec ! xvimagesink |
|
|
[edit]
|
|
SMOKE GDPPAY TCP
GST_DEBUG=3 gst-launch-0.10 -vm v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=\(fraction\)5/1,format=\(fourcc\)YUY2 ! ffmpegcolorspace ! smokeenc ! video/x-smoke, width=640, height=480, framerate=\(fraction\)5/1 ! gdppay ! tcpclientsink port=9876 host=pidi sync=false gst-launch-0.10 tcpserversrc port=9876 host=pidi ! gdpdepay ! smokedec ! xvimagesink |
|
|
[edit]
|
|
MPEG1 GDPPAY TCP
gst-launch-0.10 -vm v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=\(fraction\)5/1,format=\(fourcc\)YUY2 ! ffmpegcolorspace ! ffenc_mpeg1video ! gdppay ! tcpclientsink port=9876 host=pidi gst-launch-0.10 tcpserversrc -vm port=9876 host=pidi ! gdpdepay ! ffdec_mpegvideo ! xvimagesink |
|
|
[edit]
|
AUDIO MULAW UDPalsasrc blocksize=4096 <= leads to 512-byte UDP packets
gst-launch-0.10 alsasrc ! audioconvert -v ! audio/x-raw-int,channels=1 ! mulawenc ! audio/x-mulaw,channels=1,rate=8000 ! identity dump=true ! udpsink port=9001 host=127.0.0.1 sync=false /pipeline0/identity0: last-message = "chain ******* (identity0:sink)i (80 bytes, timestamp: 0:00:01.680000000, duration: 0:00:00.010000000, offset: -1, offset_end: -1, flags: 0) 0x7f1d84001740" 00000000 (0x792490): af af b0 b0 b0 b0 af af b0 b0 b0 b0 af af af af ................ 00000010 (0x7924a0): af af af af af af af af af af af af af af af af ................ 00000020 (0x7924b0): af af af af af af af af af ae ae ae ae ae af af ................ 00000030 (0x7924c0): ae ae af af ae ae ae af ae ae ae ae ae ae ae ae ................ 00000040 (0x7924d0): af af ae ae ae ae af ae ae ae ae af af af af af ................ gst-launch-0.10 -vvv -m udpsrc port=9001 ! audio/x-mulaw,channels=1,rate=8000 ! mulawdec ! audio/x-raw-int,channels=1 ! alsasink provide-clock=false sync=false buffer-time=200000
/pipeline0/identity0: last-message = "chain ******* (identity0:sink)i (160 bytes, timestamp: 0:00:09.101903000, duration: 0:00:00.010000000, offset: -1, offset_end: -1, flags: 0) 0x77e540" 00000000 (0x7a9270): fc 16 fc 18 fc 18 fc 16 fc 17 fc 1d 7c 28 7c 30 ............|(|0 00000010 (0x7a9280): 7c 30 7c 2e 7c 2c 7c 28 7c 26 7c 2a 7c 2c 7c 2a |0|.|,|(|&|*|,|* 00000020 (0x7a9290): 7c 2a 7c 2c 7c 30 7c 32 7c 32 7c 32 7c 2c 7c 26 |*|,|0|2|2|2|,|& 00000030 (0x7a92a0): 7c 24 7c 24 7c 26 7c 26 7c 24 7c 22 fc 1c fc 16 |$|$|&|&|$|".... 00000040 (0x7a92b0): fc 12 3c 0d 3c 09 5c 07 9c 06 cc 02 64 fb 44 f7 ..<.<.\.....d.D. 00000050 (0x7a92c0): c4 f3 04 ed 04 ee c4 f3 04 ef 04 e7 04 e3 84 dd ................ 00000060 (0x7a92d0): 84 dd 04 e1 04 e2 84 df 84 d5 84 cf 84 df a4 fb ................ 00000070 (0x7a92e0): 7c 20 7c 34 7c 2c fc 1b 3c 0d 9c 03 bc 09 fc 11 | |4|,..<....... 00000080 (0x7a92f0): fc 12 bc 0d ac 01 a4 00 bc 09 fc 14 7c 22 7c 24 ............|"|$ 00000090 (0x7a9300): fc 1b fc 0f bc 08 bc 0b fc 12 fc 16 fc 17 fc 13 ................ |
|
|
[edit]
|
|
UDP Demo with select()
# Based on Demo code from http://www.evolt.org/node/60276
# by Premshree Pillai, Mumbai University, India.
import select
import sys
from socket import *
host = "localhost"
port = 21567
buf = 1024
addr = (host,port)
DUMPERS = {}
def dump(data, addr):
print "GOT <%s> from %s" % (data, addr)
print type(data)
UDPSock = socket(AF_INET,SOCK_DGRAM)
if sys.argv[1:] and sys.argv[1] == 's':
UDPSock.bind(addr)
DUMPERS[UDPSock] = dump
rd, wr, er = select.select([UDPSock], [], [], 999)
print rd, wr, er
data,addr = rd[0].recvfrom(buf)
DUMPERS[rd[0]](data, addr)
else:
data = "I wish I were an Oscar Meyer Wiener!"
UDPSock.sendto(data,addr)
Server prints:
[<socket._socketobject object at 0xb7d371ec>] [] []
GOT <I wish I were an Oscar Meyer Wiener!> from ('127.0.0.1', 58621)
<type 'str'>
|
|
|
[edit]
|
|
install pycrypt
$ evince /usr/share/doc/python-crypto/pycrypt.ps.gz
strick@retro:~$ python
Python 2.5.2 (r252:60911, Jul 22 2009, 15:35:03)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Crypto.Hash import MD5
>>> m = MD5.new()
>>> m.update('abc')
>>> m.hexdigest()
'900150983cd24fb0d6963f7d28e17f72'
>>> from Crypto.Cipher import AES
>>> from Crypto.Cipher import Blowfish
>>> b=Blowfish.new('passwd', Blowfish.MODE_CBC, 8*'x')
>>> z=b.encrypt('abcdefgh')
>>> b=Blowfish.new('passwd', Blowfish.MODE_CBC, 8*'x')
>>> b.decrypt(z)
'abcdefgh'
>>>from Crypto.PublicKey import RSA
>>> rk=RSA.generate(384,lambda n: open('/dev/urandom').read(n))
>>> rk
<Crypto.PublicKey.RSA.RSAobj_c instance at 0xb76dbfac>
>>>
>>> hash = MD5.new('foo').digest()
>>> hash
'\xac\xbd\x18\xdbL\xc2\xf8\\\xed\xefeO\xcc\xc4\xa4\xd8'
>>> sig = rk.sign(hash, '')
>>> sig
(5635910766727867518384394844488772812542483416326736205994225419700197466916507571003891072480941350727262782912755L,)
>>> rk.verify(hash, sig)
True
>>> rk.verify(hash[:-1], sig)
False
>>>
|
|
|
[edit]
|
|
For Windows Python25:
http://www.voidspace.org.uk/python/modules.shtml#pycrypto
|
|
|
[edit]
|
|
|
[edit]
|
|
http://www.gstreamer-winbuild.ylatuya.es/doku.php
For Python 2.5: It warns C:/Python25 already exists. I say Continue. |
|
|
[edit]
|
|
# /home/strick/repos/owlvc
[strick@albus owlvc]$ python2.4 mux.py hub xyzzy
root@uhura:/home/strick/owlvc# python2.5 mux.py poke xyzzy BAR 2 Xyz albus.yak.net 55
GC Timeout: ('128.61.105.188', 9999)
Recent Add: ('128.61.105.188', 55045)
Repeat except ('128.61.105.188', 55045) consider ('128.61.105.188', 55045)
[] [] [] [] [] [] [] [] [] ['#70370'] ## RecvFrom:#70370 : ('128.61.105.188', 55045) -> ['0x3', '0x41', '0x62', '0x63', '0x4a', '0xdb', '0xe5', '0x35', '0x1', '0x0', '0x0', '0x66', '0x0', '0x0', '0x0', '0x3', '0x46', '0x4f', '0x4f', '0xb4', '0xd5', '0x4c', '0xd5']
Repeat except ('128.61.105.188', 55045) consider ('128.61.105.188', 55045)
[] [] ['#70370'] ## RecvFrom:#70370 : ('128.61.105.188', 9999) -> ['0x3', '0x58', '0x79', '0x7a', '0x4a', '0xdb', '0xe5', '0x38', '0x2', '0x0', '0x0', '0x66', '0x0', '0x0', '0x0', '0x3', '0x42', '0x41', '0x52', '0xdc', '0xad', '0x3', '0x60']
Recent Add: ('128.61.105.188', 9999)
Repeat except ('128.61.105.188', 9999) consider ('128.61.105.188', 9999)
Repeat except ('128.61.105.188', 9999) consider ('128.61.105.188', 55045)
## SendTo:#70370 -> ('128.61.105.188', 55045) : ['0x2', '0x58', '0x79', '0x7a', '0x4a', '0xdb', '0xe5', '0x38', '0x2', '0x0', '0x0', '0x66', '0x0', '0x0', '0x0', '0x3', '0x42', '0x41', '0x52', '0xdc', '0xad', '0x3', '0x60']
[] [] [] [] []
strick@PC ~/work/owlvc
$ python25 mux.py poke xyzzy FOO 1 Abc albus.yak.net 555
## SendTo:#23403 -> ('albus.yak.net', 555) : ['0x3', '0x41', '0x62', '0x63', '
0x4a', '0xdb', '0xe5', '0x35', '0x1', '0x0', '0x0', '0x66', '0x0', '0x0', '0x0',
'0x3', '0x46', '0x4f', '0x4f', '0xb4', '0xd5', '0x4c', '0xd5']
[strick@albus owlvc]$ rsync -ave 'ssh -vp22' ../owlvc/ strick@172.24.40.135:owlvc/ |
|
|
[edit]
|
|
This is "WinDump.exe udp" output, on Windows XP.
These are fragmented UDP packets, typically 10K to 30K size. They leave the XP box successfully & arrive at 75-144-20-99 successfully. When 75-144-20-99 sends a packet back, it looks like only the first fragment (with the UDP header) makes it back. Why not the other fragments? The same kind of fragmented UDP do arrive back -- through the exact same routers & masquarade -- on a linux box on the same network, same switch, as this Windows box. So I think the problem has to be in XP.
20:56:03.008291 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.008303 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.063024 IP 75-144-20-99-ca.sfba.comcastbusiness.net.55055 > STRICK-CORP. mshome.net.9899: UDP, length 14248 20:56:03.215487 IP STRICK-CORP.mshome.net.9899 > 75-144-20-99-ca.sfba.comcastbus iness.net.55055: UDP, length 21334 20:56:03.215515 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215528 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215541 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215553 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215565 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215578 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215590 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215602 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215614 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215627 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215639 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215652 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215663 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.215675 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.262692 IP 75-144-20-99-ca.sfba.comcastbusiness.net.55055 > STRICK-CORP. mshome.net.9899: UDP, length 13950 20:56:03.426976 IP STRICK-CORP.mshome.net.9899 > 75-144-20-99-ca.sfba.comcastbus iness.net.55055: UDP, length 21288 20:56:03.427005 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427018 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427030 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427043 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427055 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427067 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427080 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427092 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427104 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427116 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427128 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427140 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427152 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.427164 IP STRICK-CORP.mshome.net > 75-144-20-99-ca.sfba.comcastbusiness .net: udp 20:56:03.463705 IP 75-144-20-99-ca.sfba.comcastbusiness.net.55055 > STRICK-CORP. mshome.net.9899: UDP, length 14300 |
| (last modified 2009-10-15) [Login] |