Streaming USB Webcam over Network

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Streaming USB Webcam over Network

Jump to solution
114,230 Views
philippeballeyd
Contributor IV

Hi

I'm currently streaming a USB Webcam from the IMX6Q SabreBoard to my computer over the network with this command:

gst-launch-0.10 v4l2src device=/dev/video0 ! 'video/x-raw-yuv,framerate=(fraction)30/1' ! ffmpegcolorspace ! vpuenc codec=12 ! multipartmux ! tcpserversink host=192.168.20.26 port=5000

This is working fine. When i use VLC, i can see the stream when typing the address tcp://192.168.20.43:5000

But i'd like to use the x264 codec. As i understood it, i just have to change the vpuenc codec=6 but this isn't working. I do receive a stream, but VLC tells me that the codec is undefined and that it can't decode it.

I'm pretty new with the use of streams so i'm kind of walking blindly. Is my gst-launch command correct for x264?

And moreover, how do i broadcast the stream instead of sending it directly to someone?

Best regards.

Ce message a été modifié par : Philippe Balleydier

Labels (2)
Tags (2)
0 Kudos
1 Solution
8,562 Views
BrilliantovKiri
Senior Contributor I

Pipeline for UDP-stream:

gst-launch  udpsrc port=5000 caps=\"application/x-rtp, media=(string)video, clock-rate=(int)90000, payload=(int)96, encoding-name=(string)H264" ! rtph264depay ! ffdec_h264 ! xvimagesink

In attache ful script (server and client pipeline), tested on iMX53.

View solution in original post

0 Kudos
17 Replies
8,563 Views
philippeballeyd
Contributor IV

I managed to make it works thanks to kirill but i'm having issues with the Height and width of the stream

I use these 2 commands:

Server: gst-launch-0.10 v4l2src device=/dev/video0 ! 'video/x-raw-yuv,framerate=(fraction)30/1' ! ffmpegcolorspace ! vpuenc codec=6 ! rtph264pay ! udpsink host=192.168.20.26 port=5000

Client: gst-launch udpsrc port=5000 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, payload=(int)96, encoding-name=(string)H264" ! rtph264depay ! ffdec_h264 ! xvimagesink

The problem is, when i try to set the height and width of the stream, the pipeline won't create. I use this command for the server:

gst-launch-0.10 v4l2src device=/dev/video0 ! 'video/x-raw-yuv,height=720,width=1280,framerate=(fraction)30/1' ! ffmpegcolorspace ! vpuenc codec=6 ! rtph264pay ! udpsink host=192.168.20.26 port=5000$

(just added height=720,width=1280)

and the client console returns me:

ERROR: Pipeline doesn't want to pause.

ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Could not negotiate format

Why can't i choose the height and width of the stream?

0 Kudos
8,563 Views
shanmugamsundar
Contributor IV

Try adding like this

capture-width=640 capture-height=480 capture-mode=0

capture-width=1280 capture-height=720 capture-mode=4

Thanks

shan

0 Kudos
8,563 Views
philippeballeyd
Contributor IV

I tried like this:

gst-launch v4l2src capture-height=720 capture-width=1280 capture-mode=4 device=/dev/video0 ! 'video/x-raw-yuv,framerate=(fraction)30/1' ! ffmpegcolorspace ! vpuenc codec=6 ! rtph264pay ! udpsink host=192.168.20.26 port=5000

And it says:

WARNING: erroneous pipeline: no property "capture-height" in element "v4l2src0"

Those capture-height and width elements only exist on the module called mfw_v4lsrc but i'm using v4l2src.

0 Kudos
8,563 Views
shanmugamsundar
Contributor IV

v4l2src will have the property width and height, you can check that with  gst-inspect v4l2src this command will display the properties of v4l2src


Try these commands

gst-launch v4l2src device=/dev/video0 ! video/x-raw-yuv,width=1280,height=720,format='(fourcc)'UYVY ! ffmpegcolorspace ! vpuenc codec=6 ! rtph264pay ! udpsink host=192.168.20.26 port=5000

gst-launch-0.10 -v v4l2src device=/dev/video0 ! 'video/x-raw-yuv,width=640,height=480' ! ffmpegcolorspace ! x264enc ! rtph264pay ! udpsink host=192.168.20.26 port=5000

0 Kudos
8,563 Views
philippeballeyd
Contributor IV

I've tried multiple times the first line before. But i always get the same error:

ERROR: Pipeline doesn't want to pause.

ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Could not negotiate format

For the second one, it's working, but i have big lag issues (at least a 10 seconds delay and not continuous at all)

I've observed this phenomenom multiple times with the x264enc module (i think it is not hardware optimized)

EDIT:

ok i've figured out the issue.

I usually use this command (a working one):

gst-launch v4l2src device=/dev/video0 ! 'video/x-raw-yuv,framerate=(fraction)30/1' ! ffmpegcolorspace ! vpuenc codec=6 ! rtph264pay ! udpsink host=192.168.20.30 port=5000

If i use the height and width parameters, they have to be quite low (like 320x240 or 640x480). If i try to set them too high (like 800x600, 1280x720), i have to reduce the framerate from 30 to 10, or i get the "Could not negotiate format" error.

Aren't we able to stream 720p30?

0 Kudos
8,563 Views
shanmugamsundar
Contributor IV

which USB camera are you using, have you check the driver settings for your camera whether it is having 720p resolution at 30fps

I tested it with ov5640 5mp camera in i.MX6q sabrelite board for that i have a 720p settings for 30fps and 15fps

0 Kudos
8,563 Views
philippeballeyd
Contributor IV

I tried 2 differents USB camera and i get the exact same issue on both:

  • Microsoft Lifecam HD-3000
  • Logitech C525

To me, they are both able to record 720p @30fps.

0 Kudos
8,563 Views
philippeballeyd
Contributor IV

After verification, the width/height/framerate problem comes from the camera, they are both unable to provide 720p @30 fps...

Thanks everyone for your help!

0 Kudos
8,560 Views
shanmugamsundar
Contributor IV

Hello Philippe,

Try commands in the attached  documents, these documents is specifically created for all the imx6 boards. In your case it is USB web cam for that you need to choose the appropriate video codecs. To find the available codecs give the command   gst-inspect

GStreamer UDP Streaming

GStreamer RTP Streaming

Thanks

shan

0 Kudos
8,560 Views
philippeballeyd
Contributor IV

Those 2 are concerning the h263 standard. But i need to use H264, Is that a big deal or do i just have to change the names?

0 Kudos
8,560 Views
Yuri
NXP Employee
NXP Employee

   Please try the following :

$ gst-launch-0.10 v4l2src device=/dev/video0 ! 'video/x-raw-yuv,framerate=(fraction)30/1' ! ffmpegcolorspace ! vpuenc codec=6 ! rtph264pay  ! tcpserversink host=192.168.20.43 port=5000

For host VLC (sdp file) :

v=0

o=IN IP4 192.168.20.43

c=IN IP4 192.168.20.43

s=iMX6 GStreamer H264

m=video 5000 RTP/AVP 96

a=rtpmap:96 H264/90000

a=fmp:96 media=video; clock-rate=90000; encoding-name=H264


Have a great day,
Yuri

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
8,560 Views
philippeballeyd
Contributor IV

Thanks for your answer.

Do i copy/paste what you've written in a .SDP file and open it with VLC?

for the 'o' and 'c' parameters in de SDP file, Is it the IP of the receiving computer? (i've tried both anyway)

Because for now, it is not working. I do see a stream coming to the receiving computer on wireshark but it seems like VLC is unable to see it.

When i open the .SDP file with VLC and i go to "Statistics", the throughput received is 0Kb/s but codecs are recognized.

When i open a network stream with VLC (without using a .SDP file) with the address tcp://ip.of.sender:5000, i do get a throughput but nothing but a black screen (well, not a black screen, the VLC logo) (and plugin are not recognized)

Can the issue come from de Webcam?

I'm using a Microsoft Lifecam HD-3000 that worked well for mjpg streaming. Moreover, it is said that it is a UVC device. So i guess it should work properly.

Any ideas?

0 Kudos
8,560 Views
Yuri
NXP Employee
NXP Employee

  Looks like the LVC does not understand raw data (no headers) of the VPU.
~Yuri.

0 Kudos
8,560 Views
philippeballeyd
Contributor IV

I'm also interested in the corresponding gst-launch command on the receiver side, if you have any ideas.

Regards

0 Kudos
8,563 Views
BrilliantovKiri
Senior Contributor I

Pipeline for UDP-stream:

gst-launch  udpsrc port=5000 caps=\"application/x-rtp, media=(string)video, clock-rate=(int)90000, payload=(int)96, encoding-name=(string)H264" ! rtph264depay ! ffdec_h264 ! xvimagesink

In attache ful script (server and client pipeline), tested on iMX53.

0 Kudos
8,563 Views
philippeballeyd
Contributor IV

I'm missing the mfw_vpuencoder plugin. I found on the net that i need to add gst-fsl-plugin in the local.conf files and rebake. But the plugin is still missing? What packages do i need to include to make it work?

0 Kudos
8,563 Views
BrilliantovKiri
Senior Contributor I

Hello!

Because I work with iMX53 I use packages for this platform.

You should modify pipeline for your platform iMX6, I think this is not very hard.

>

>

>

0 Kudos