Projet

Général

Profil

GStreamer » Historique » Version 2

P.G Bareges, 25/02/2013 22:13

1 1 P.G Bareges
h1. GStreamer
2 1 P.G Bareges
3 1 P.G Bareges
4 2 P.G Bareges
h2. command line 
5 2 P.G Bareges
h3. simple theora encoding stream over udp 
6 1 P.G Bareges
7 1 P.G Bareges
<pre>
8 1 P.G Bareges
Sender : 
9 1 P.G Bareges
 gst-launch-0.10 -v v4l2src device=/dev/video0 ! \
10 1 P.G Bareges
 'video/x-raw-yuv,width=640,height=480,framerate=30/1' ! \
11 1 P.G Bareges
 theoraenc ! udpsink host=10.20.0.62 port=1234
12 1 P.G Bareges
13 1 P.G Bareges
Receiver :
14 1 P.G Bareges
gst-launch-0.10 -v udpsrc port=1234 \
15 1 P.G Bareges
 caps="video/x-theora, width=640, height=480, framerate=30/1, pixel-aspect-ratio=1/1" ! \
16 1 P.G Bareges
 theoradec ! xvimagesink 
17 1 P.G Bareges
18 1 P.G Bareges
stats on i7-2620M
19 1 P.G Bareges
20 1 P.G Bareges
 ps -eo psr,pid,tid,class,rtprio,ni,pri,pcpu,stat,wchan:14,comm | grep [g]st
21 1 P.G Bareges
  3 23360 23360 TS       -   0  19  8.6 Sl+  poll_schedule_ gst-launch-0.10
22 1 P.G Bareges
  2 23363 23363 TS       -   0  19 47.8 Sl+  poll_schedule_ gst-launch-0.10
23 1 P.G Bareges
24 1 P.G Bareges
</pre>
25 2 P.G Bareges
nécessite de lancer le receiver avant le sender... reprise possible du flux d'émission apres l'initialisation des 2 pipelines (sender/receive)
26 2 P.G Bareges
ne marche pas sous windows.
27 1 P.G Bareges
28 2 P.G Bareges
h3. rtp 
29 2 P.G Bareges
30 2 P.G Bareges
le serveur envoie ses caps toute les 5 secondes via config-interval=5
31 2 P.G Bareges
marche sous windows \o/ :)
32 2 P.G Bareges
33 2 P.G Bareges
<pre>
34 2 P.G Bareges
35 2 P.G Bareges
sender: 
36 2 P.G Bareges
37 2 P.G Bareges
gst-launch-0.10 -v v4l2src device=/dev/video0 ! 'video/x-raw-yuv,width=640,height=480,framerate=30/1' ! theoraenc ! rtptheorapay config-interval=5 ! udpsink host=10.20.0.62 port=1234
38 2 P.G Bareges
39 2 P.G Bareges
receiver : 
40 2 P.G Bareges
41 2 P.G Bareges
gst-launch-0.10 -v udpsrc port=1234 caps="application/x-rtp" ! rtptheoradepay ! theoradec ! xvimagesink
42 2 P.G Bareges
43 2 P.G Bareges
</pre>
44 2 P.G Bareges
45 2 P.G Bareges
46 2 P.G Bareges
47 1 P.G Bareges
h2. Processing
48 1 P.G Bareges
49 1 P.G Bareges
<pre>
50 1 P.G Bareges
/**
51 1 P.G Bareges
 * Ripped from
52 1 P.G Bareges
 * Camera capture pipelines. 
53 1 P.G Bareges
 * By Andres Colubri
54 1 P.G Bareges
 * 
55 1 P.G Bareges
 * 
56 1 P.G Bareges
 */
57 1 P.G Bareges
58 1 P.G Bareges
import codeanticode.gsvideo.*;
59 1 P.G Bareges
60 1 P.G Bareges
GSPipeline pipeline;
61 1 P.G Bareges
62 1 P.G Bareges
void setup() {
63 1 P.G Bareges
  size(640, 480);
64 1 P.G Bareges
  frameRate(30);
65 1 P.G Bareges
  pipeline = new GSPipeline(this, "udpsrc port=1234 caps=\"video/x-theora, width=640, height=480, framerate=30/1, pixel-aspect-ratio=1/1\" ! theoradec ");  
66 1 P.G Bareges
  pipeline.play();
67 1 P.G Bareges
}
68 1 P.G Bareges
69 1 P.G Bareges
void draw() {
70 1 P.G Bareges
  // When the GSPipeline.available() method returns true, 
71 1 P.G Bareges
  // it means that a new frame is ready to be read.
72 1 P.G Bareges
  if (pipeline.available()) {
73 1 P.G Bareges
    pipeline.read();
74 1 P.G Bareges
    image(pipeline, 0, 0);
75 1 P.G Bareges
  }
76 1 P.G Bareges
}
77 1 P.G Bareges
78 1 P.G Bareges
79 1 P.G Bareges
</pre>
80 1 P.G Bareges
81 1 P.G Bareges
82 1 P.G Bareges
h2. Liens
83 1 P.G Bareges
84 2 P.G Bareges
85 2 P.G Bareges
86 2 P.G Bareges
*http://gsvideo.sourceforge.net/
87 2 P.G Bareges
*http://wiki.oz9aec.net/index.php/Gstreamer_cheat_sheet 
88 2 P.G Bareges
*http://lists.freedesktop.org/archives/gstreamer-devel/2011-July/032234.html