public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] [OT} GStreamer: How to view AND record a stream coming from an USB Webcam
@ 2014-06-15 17:54 meino.cramer
  2014-06-15 18:04 ` Canek Peláez Valdés
  2014-06-16  3:32 ` [gentoo-user] " James
  0 siblings, 2 replies; 8+ messages in thread
From: meino.cramer @ 2014-06-15 17:54 UTC (permalink / raw
  To: Gentoo

Hi,

After unsuccessfully trying vlc with a Logitech C920 HD Pro Webcam 
(over 2 seconds delay between audio and video). I played around
with gstreamer and from bits and pieces from the web I build
this line:

    gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! \
    h264parse ! muxout. alsasrc device="hw:3,0" ! queue ! audioconvert ! lamemp3enc ! \ 
    muxout. matroskamux name=muxout streamable=true ! filesink location=c920.mp4

which records a Full HD video with audio to my harddisc. The delay is
minimal and the sync between audio and video is good.

But there is one disadvantage:
I cannot see what I am recording and I cannot watch the webcams stream
before I fire up the script because otherwise the device would be "already
in use" (I dont like scripts, which simply kill other applications when
called).

Any ideas or hints how to manage that?

Thank you very much in advance for any help!
Best regards,
mcc








^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] [OT} GStreamer: How to view AND record a stream coming from an USB Webcam
  2014-06-15 17:54 [gentoo-user] [OT} GStreamer: How to view AND record a stream coming from an USB Webcam meino.cramer
@ 2014-06-15 18:04 ` Canek Peláez Valdés
  2014-06-16  1:02   ` Canek Peláez Valdés
  2014-06-16  3:32 ` [gentoo-user] " James
  1 sibling, 1 reply; 8+ messages in thread
From: Canek Peláez Valdés @ 2014-06-15 18:04 UTC (permalink / raw
  To: gentoo-user

On Sun, Jun 15, 2014 at 12:54 PM,  <meino.cramer@gmx.de> wrote:
> Hi,
>
> After unsuccessfully trying vlc with a Logitech C920 HD Pro Webcam
> (over 2 seconds delay between audio and video). I played around
> with gstreamer and from bits and pieces from the web I build
> this line:
>
>     gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! \
>     h264parse ! muxout. alsasrc device="hw:3,0" ! queue ! audioconvert ! lamemp3enc ! \
>     muxout. matroskamux name=muxout streamable=true ! filesink location=c920.mp4
>
> which records a Full HD video with audio to my harddisc. The delay is
> minimal and the sync between audio and video is good.
>
> But there is one disadvantage:
> I cannot see what I am recording and I cannot watch the webcams stream
> before I fire up the script because otherwise the device would be "already
> in use" (I dont like scripts, which simply kill other applications when
> called).
>
> Any ideas or hints how to manage that?

Use the tee element. I'm in a hurry, so I cannot test a pipeline right
now, but I will try later. Meanwhile, just try to put a queue element
after each path of the tee.

gst-inspect-1.0 tee

Regards.
-- 
Canek Peláez Valdés
Profesor de asignatura, Facultad de Ciencias
Universidad Nacional Autónoma de México


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] [OT} GStreamer: How to view AND record a stream coming from an USB Webcam
  2014-06-15 18:04 ` Canek Peláez Valdés
@ 2014-06-16  1:02   ` Canek Peláez Valdés
  2014-06-16 18:27     ` meino.cramer
  0 siblings, 1 reply; 8+ messages in thread
From: Canek Peláez Valdés @ 2014-06-16  1:02 UTC (permalink / raw
  To: gentoo-user

On Sun, Jun 15, 2014 at 1:04 PM, Canek Peláez Valdés <caneko@gmail.com> wrote:
> On Sun, Jun 15, 2014 at 12:54 PM,  <meino.cramer@gmx.de> wrote:
>> Hi,
>>
>> After unsuccessfully trying vlc with a Logitech C920 HD Pro Webcam
>> (over 2 seconds delay between audio and video). I played around
>> with gstreamer and from bits and pieces from the web I build
>> this line:
>>
>>     gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! \
>>     h264parse ! muxout. alsasrc device="hw:3,0" ! queue ! audioconvert ! lamemp3enc ! \
>>     muxout. matroskamux name=muxout streamable=true ! filesink location=c920.mp4
>>
>> which records a Full HD video with audio to my harddisc. The delay is
>> minimal and the sync between audio and video is good.
>>
>> But there is one disadvantage:
>> I cannot see what I am recording and I cannot watch the webcams stream
>> before I fire up the script because otherwise the device would be "already
>> in use" (I dont like scripts, which simply kill other applications when
>> called).
>>
>> Any ideas or hints how to manage that?
>
> Use the tee element. I'm in a hurry, so I cannot test a pipeline right
> now, but I will try later. Meanwhile, just try to put a queue element
> after each path of the tee.
>
> gst-inspect-1.0 tee

OK, it took me a bit of an effort, but this is my pipeline:

gst-launch-1.0 v4l2src norm=NTSC device=/dev/video1 ! queue !
deinterlace mode=1 ! videorate !
video/x-raw,format=YV12,width=720,height=480,framerate=30000/1001 !
tee name=t t. ! queue ! videoconvert ! mpeg2enc ! avimux ! filesink
location=file.avi t. ! queue ! videoconvert ! autovideosink

My hardware is much more limited (analog RGB), so resolution and
famerate are accordingly lower. This captures to an AVI file encoded
to MPEG2 the video signal, and at the same time it opens a window to
show the stream.

It should not be that much of a problem to modify it to your needs;
just notice that I didn't capture audio.

Regards.
-- 
Canek Peláez Valdés
Profesor de asignatura, Facultad de Ciencias
Universidad Nacional Autónoma de México


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [gentoo-user] Re: [OT} GStreamer: How to view AND record a stream coming from an USB Webcam
  2014-06-15 17:54 [gentoo-user] [OT} GStreamer: How to view AND record a stream coming from an USB Webcam meino.cramer
  2014-06-15 18:04 ` Canek Peláez Valdés
@ 2014-06-16  3:32 ` James
  2014-06-16 18:21   ` meino.cramer
  1 sibling, 1 reply; 8+ messages in thread
From: James @ 2014-06-16  3:32 UTC (permalink / raw
  To: gentoo-user

 <meino.cramer <at> gmx.de> writes:


> After unsuccessfully trying vlc with a Logitech C920 HD Pro Webcam 
> (over 2 seconds delay between audio and video). 


Have you tried  : media-video/ffmpeg ?

This wiki is full of good information. Many video packages use
ffmpeg as part of their core solution... Pay attention to the myriad
of flags you can set and the order of your syntax (manual) strings.


http://trac.ffmpeg.org/wiki

Here are some ideas:

https://wiki.archlinux.org/index.php/FFmpeg

You *may* be able to use the copy command of ffmpeg to spit and view
the h.264 (x.264) stream in real time.  Google for some more syntax
snippets.

Also there is zoneminder a video surveillance application. I do not
know if they ever added x.264 support....


HTH,
James







^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] Re: [OT} GStreamer: How to view AND record a stream coming from an USB Webcam
  2014-06-16  3:32 ` [gentoo-user] " James
@ 2014-06-16 18:21   ` meino.cramer
  2014-06-16 22:24     ` James
  0 siblings, 1 reply; 8+ messages in thread
From: meino.cramer @ 2014-06-16 18:21 UTC (permalink / raw
  To: gentoo-user

James <wireless@tampabay.rr.com> [14-06-16 05:36]:
>  <meino.cramer <at> gmx.de> writes:
> 
> 
> > After unsuccessfully trying vlc with a Logitech C920 HD Pro Webcam 
> > (over 2 seconds delay between audio and video). 
> 
> 
> Have you tried  : media-video/ffmpeg ?
> 
> This wiki is full of good information. Many video packages use
> ffmpeg as part of their core solution... Pay attention to the myriad
> of flags you can set and the order of your syntax (manual) strings.
> 
> 
> http://trac.ffmpeg.org/wiki
> 
> Here are some ideas:
> 
> https://wiki.archlinux.org/index.php/FFmpeg
> 
> You *may* be able to use the copy command of ffmpeg to spit and view
> the h.264 (x.264) stream in real time.  Google for some more syntax
> snippets.
> 
> Also there is zoneminder a video surveillance application. I do not
> know if they ever added x.264 support....
> 
> 
> HTH,
> James
> 

Hi James,

thanks for your resply 8)

Zoneminder needs to intercept the video stream to analyse it --
that means, that it need to decode the stream, analyse it and 
to encode it again.
Furthermore it needs a webserver...
A little to much load for my CPU and a little too much effort...

FFmpeg crashes and breaks (similiar reports on the web...) when
trying to watch video streams from the c920...

Currently the best results I get with gstreamer...but then I
cannot control the uvc parameters....


Sigh...things are crossing the border between "interesting" to
"complex"...

Best regards,
mcc





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] [OT} GStreamer: How to view AND record a stream coming from an USB Webcam
  2014-06-16  1:02   ` Canek Peláez Valdés
@ 2014-06-16 18:27     ` meino.cramer
  2014-06-16 19:34       ` Canek Peláez Valdés
  0 siblings, 1 reply; 8+ messages in thread
From: meino.cramer @ 2014-06-16 18:27 UTC (permalink / raw
  To: gentoo-user

Canek Peláez Valdés <caneko@gmail.com> [14-06-16 04:33]:
> On Sun, Jun 15, 2014 at 1:04 PM, Canek Peláez Valdés <caneko@gmail.com> wrote:
> > On Sun, Jun 15, 2014 at 12:54 PM,  <meino.cramer@gmx.de> wrote:
> >> Hi,
> >>
> >> After unsuccessfully trying vlc with a Logitech C920 HD Pro Webcam
> >> (over 2 seconds delay between audio and video). I played around
> >> with gstreamer and from bits and pieces from the web I build
> >> this line:
> >>
> >>     gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! \
> >>     h264parse ! muxout. alsasrc device="hw:3,0" ! queue ! audioconvert ! lamemp3enc ! \
> >>     muxout. matroskamux name=muxout streamable=true ! filesink location=c920.mp4
> >>
> >> which records a Full HD video with audio to my harddisc. The delay is
> >> minimal and the sync between audio and video is good.
> >>
> >> But there is one disadvantage:
> >> I cannot see what I am recording and I cannot watch the webcams stream
> >> before I fire up the script because otherwise the device would be "already
> >> in use" (I dont like scripts, which simply kill other applications when
> >> called).
> >>
> >> Any ideas or hints how to manage that?
> >
> > Use the tee element. I'm in a hurry, so I cannot test a pipeline right
> > now, but I will try later. Meanwhile, just try to put a queue element
> > after each path of the tee.
> >
> > gst-inspect-1.0 tee
> 
> OK, it took me a bit of an effort, but this is my pipeline:
> 
> gst-launch-1.0 v4l2src norm=NTSC device=/dev/video1 ! queue !
> deinterlace mode=1 ! videorate !
> video/x-raw,format=YV12,width=720,height=480,framerate=30000/1001 !
> tee name=t t. ! queue ! videoconvert ! mpeg2enc ! avimux ! filesink
> location=file.avi t. ! queue ! videoconvert ! autovideosink
> 
> My hardware is much more limited (analog RGB), so resolution and
> famerate are accordingly lower. This captures to an AVI file encoded
> to MPEG2 the video signal, and at the same time it opens a window to
> show the stream.
> 
> It should not be that much of a problem to modify it to your needs;
> just notice that I didn't capture audio.
> 
> Regards.
> -- 
> Canek Peláez Valdés
> Profesor de asignatura, Facultad de Ciencias
> Universidad Nacional Autónoma de México
> 

Hi Canek,

Thanks a lot for your effort!!! 8)

Is there any documentation out there about this "How to build 
a pipeline with gst-launch", which you would recommend to read?

I will see how I can map your example to my code I have already, which 
handles audio and video...

Best regards,
mcc









^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] [OT} GStreamer: How to view AND record a stream coming from an USB Webcam
  2014-06-16 18:27     ` meino.cramer
@ 2014-06-16 19:34       ` Canek Peláez Valdés
  0 siblings, 0 replies; 8+ messages in thread
From: Canek Peláez Valdés @ 2014-06-16 19:34 UTC (permalink / raw
  To: gentoo-user

On Mon, Jun 16, 2014 at 1:27 PM,  <meino.cramer@gmx.de> wrote:
> Canek Peláez Valdés <caneko@gmail.com> [14-06-16 04:33]:
>> On Sun, Jun 15, 2014 at 1:04 PM, Canek Peláez Valdés <caneko@gmail.com> wrote:
>> > On Sun, Jun 15, 2014 at 12:54 PM,  <meino.cramer@gmx.de> wrote:
>> >> Hi,
>> >>
>> >> After unsuccessfully trying vlc with a Logitech C920 HD Pro Webcam
>> >> (over 2 seconds delay between audio and video). I played around
>> >> with gstreamer and from bits and pieces from the web I build
>> >> this line:
>> >>
>> >>     gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! \
>> >>     h264parse ! muxout. alsasrc device="hw:3,0" ! queue ! audioconvert ! lamemp3enc ! \
>> >>     muxout. matroskamux name=muxout streamable=true ! filesink location=c920.mp4
>> >>
>> >> which records a Full HD video with audio to my harddisc. The delay is
>> >> minimal and the sync between audio and video is good.
>> >>
>> >> But there is one disadvantage:
>> >> I cannot see what I am recording and I cannot watch the webcams stream
>> >> before I fire up the script because otherwise the device would be "already
>> >> in use" (I dont like scripts, which simply kill other applications when
>> >> called).
>> >>
>> >> Any ideas or hints how to manage that?
>> >
>> > Use the tee element. I'm in a hurry, so I cannot test a pipeline right
>> > now, but I will try later. Meanwhile, just try to put a queue element
>> > after each path of the tee.
>> >
>> > gst-inspect-1.0 tee
>>
>> OK, it took me a bit of an effort, but this is my pipeline:
>>
>> gst-launch-1.0 v4l2src norm=NTSC device=/dev/video1 ! queue !
>> deinterlace mode=1 ! videorate !
>> video/x-raw,format=YV12,width=720,height=480,framerate=30000/1001 !
>> tee name=t t. ! queue ! videoconvert ! mpeg2enc ! avimux ! filesink
>> location=file.avi t. ! queue ! videoconvert ! autovideosink
>>
>> My hardware is much more limited (analog RGB), so resolution and
>> famerate are accordingly lower. This captures to an AVI file encoded
>> to MPEG2 the video signal, and at the same time it opens a window to
>> show the stream.
>>
>> It should not be that much of a problem to modify it to your needs;
>> just notice that I didn't capture audio.
>>
>> Regards.
>> --
>> Canek Peláez Valdés
>> Profesor de asignatura, Facultad de Ciencias
>> Universidad Nacional Autónoma de México
>>
>
> Hi Canek,
>
> Thanks a lot for your effort!!! 8)

No problem; I have a little MP3 encoder that I use to handle my music
collection (along with other utilities) [1], and I was trying to do
some video analysis for another project I have, so I had the GStreamer
notions kinda fresh.

> Is there any documentation out there about this "How to build
> a pipeline with gst-launch", which you would recommend to read?

GStreamer is a programmer's framework, and really gst-launch-1.0 is
just a test tool; however, GStreamer is so flexible and powerful, that
a lot of stuff can be done using the launcher and without a single
line of code written.

Having said that, IMNSHO the only way to really understand the
GStreamer pipelines is to read the developer's documentation[2];
specially when you need to use pads, although using the queue element
can solve that problem many times.

> I will see how I can map your example to my code I have already, which
> handles audio and video...

Good luck.

[1] https://github.com/canek-pelaez/mlm/blob/master/src/mlm-encoder.vala#L467
[2] http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/index.html
-- 
Canek Peláez Valdés
Profesor de asignatura, Facultad de Ciencias
Universidad Nacional Autónoma de México


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [gentoo-user] Re: [OT} GStreamer: How to view AND record a stream coming from an USB Webcam
  2014-06-16 18:21   ` meino.cramer
@ 2014-06-16 22:24     ` James
  0 siblings, 0 replies; 8+ messages in thread
From: James @ 2014-06-16 22:24 UTC (permalink / raw
  To: gentoo-user

 <meino.cramer <at> gmx.de> writes:

OK, one last trick, that will work with a coax camera.
A coax output camera, can be connected to either
a h.264 encoder/mux (standard industry equipment)
or to a pci card that has external coax inputs. 
You can then put a coax splitter (a mechanical tee)
and run the camera output to 2 differnet computers.
One encodes and records (writes to) the HD, then
other for viewing. Hokey, but we used it to test
the encoding delays of various video surveillance boxes.
Camera's that output h.264 direclty, usually use
a custom encoder that will differ from vendor to vendor.
Vendors do this because each algo, code_block and patent
is managed my the MPLA and vendors engineer what to put
inside of a video camera that outputs h.264 by playing
"what if" with a myriad of offerings directly or indirectly
from software vendors.   

It you can, a video camera with coax outputs is best and you 
can run your own h.264 encoding on a workstation  or a 
stand alone video encoding board.

Probably too much work for your needs, methinks.......

I have threatened to pick up the zoneminder code and fork
it, as have others, but I just dont have the time for that.
It's a large effort to say the least.
A google summer of code genius could/should do that, because
support for h.264 and V8 (media-libs/libvpx) would be very, very
keen, imho added to ZM. V8 is superior to h.264 and is
not patent encumbered.

sorry I'm not more help,
James











^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-16 22:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-15 17:54 [gentoo-user] [OT} GStreamer: How to view AND record a stream coming from an USB Webcam meino.cramer
2014-06-15 18:04 ` Canek Peláez Valdés
2014-06-16  1:02   ` Canek Peláez Valdés
2014-06-16 18:27     ` meino.cramer
2014-06-16 19:34       ` Canek Peláez Valdés
2014-06-16  3:32 ` [gentoo-user] " James
2014-06-16 18:21   ` meino.cramer
2014-06-16 22:24     ` James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox