Gentoo Archives: gentoo-user

From: "Canek Peláez Valdés" <caneko@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT} GStreamer: How to view AND record a stream coming from an USB Webcam
Date: Mon, 16 Jun 2014 19:34:27
Message-Id: CADPrc82Ci==WjT5zaQ3YRy7aciC6eThnU_S5KNYANNknz2TzCA@mail.gmail.com
In Reply to: Re: [gentoo-user] [OT} GStreamer: How to view AND record a stream coming from an USB Webcam by meino.cramer@gmx.de
1 On Mon, Jun 16, 2014 at 1:27 PM, <meino.cramer@×××.de> wrote:
2 > Canek Peláez Valdés <caneko@×××××.com> [14-06-16 04:33]:
3 >> On Sun, Jun 15, 2014 at 1:04 PM, Canek Peláez Valdés <caneko@×××××.com> wrote:
4 >> > On Sun, Jun 15, 2014 at 12:54 PM, <meino.cramer@×××.de> wrote:
5 >> >> Hi,
6 >> >>
7 >> >> After unsuccessfully trying vlc with a Logitech C920 HD Pro Webcam
8 >> >> (over 2 seconds delay between audio and video). I played around
9 >> >> with gstreamer and from bits and pieces from the web I build
10 >> >> this line:
11 >> >>
12 >> >> gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! \
13 >> >> h264parse ! muxout. alsasrc device="hw:3,0" ! queue ! audioconvert ! lamemp3enc ! \
14 >> >> muxout. matroskamux name=muxout streamable=true ! filesink location=c920.mp4
15 >> >>
16 >> >> which records a Full HD video with audio to my harddisc. The delay is
17 >> >> minimal and the sync between audio and video is good.
18 >> >>
19 >> >> But there is one disadvantage:
20 >> >> I cannot see what I am recording and I cannot watch the webcams stream
21 >> >> before I fire up the script because otherwise the device would be "already
22 >> >> in use" (I dont like scripts, which simply kill other applications when
23 >> >> called).
24 >> >>
25 >> >> Any ideas or hints how to manage that?
26 >> >
27 >> > Use the tee element. I'm in a hurry, so I cannot test a pipeline right
28 >> > now, but I will try later. Meanwhile, just try to put a queue element
29 >> > after each path of the tee.
30 >> >
31 >> > gst-inspect-1.0 tee
32 >>
33 >> OK, it took me a bit of an effort, but this is my pipeline:
34 >>
35 >> gst-launch-1.0 v4l2src norm=NTSC device=/dev/video1 ! queue !
36 >> deinterlace mode=1 ! videorate !
37 >> video/x-raw,format=YV12,width=720,height=480,framerate=30000/1001 !
38 >> tee name=t t. ! queue ! videoconvert ! mpeg2enc ! avimux ! filesink
39 >> location=file.avi t. ! queue ! videoconvert ! autovideosink
40 >>
41 >> My hardware is much more limited (analog RGB), so resolution and
42 >> famerate are accordingly lower. This captures to an AVI file encoded
43 >> to MPEG2 the video signal, and at the same time it opens a window to
44 >> show the stream.
45 >>
46 >> It should not be that much of a problem to modify it to your needs;
47 >> just notice that I didn't capture audio.
48 >>
49 >> Regards.
50 >> --
51 >> Canek Peláez Valdés
52 >> Profesor de asignatura, Facultad de Ciencias
53 >> Universidad Nacional Autónoma de México
54 >>
55 >
56 > Hi Canek,
57 >
58 > Thanks a lot for your effort!!! 8)
59
60 No problem; I have a little MP3 encoder that I use to handle my music
61 collection (along with other utilities) [1], and I was trying to do
62 some video analysis for another project I have, so I had the GStreamer
63 notions kinda fresh.
64
65 > Is there any documentation out there about this "How to build
66 > a pipeline with gst-launch", which you would recommend to read?
67
68 GStreamer is a programmer's framework, and really gst-launch-1.0 is
69 just a test tool; however, GStreamer is so flexible and powerful, that
70 a lot of stuff can be done using the launcher and without a single
71 line of code written.
72
73 Having said that, IMNSHO the only way to really understand the
74 GStreamer pipelines is to read the developer's documentation[2];
75 specially when you need to use pads, although using the queue element
76 can solve that problem many times.
77
78 > I will see how I can map your example to my code I have already, which
79 > handles audio and video...
80
81 Good luck.
82
83 [1] https://github.com/canek-pelaez/mlm/blob/master/src/mlm-encoder.vala#L467
84 [2] http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/index.html
85 --
86 Canek Peláez Valdés
87 Profesor de asignatura, Facultad de Ciencias
88 Universidad Nacional Autónoma de México