5

I'm quite a newbie on using gstreamer. I want to stream video and audio from my C920 webcam to another PC but I keep getting wrong in combining things..

I can now stream h264 video from my C920 to another PC using:

gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-h264,width=1280,height=720,framerate=30/1 ! h264parse ! rtph264pay pt=127 config-interval=4 ! udpsink host=172.19.3.103

And view it with:

gst-launch-1.0 udpsrc port=1234 ! application/x-rtp, payload=127 ! rtph264depay ! avdec_h264 ! xvimagesink sync=false

I can also get the audio from the C920 and record it to a file together with a test-image:

gst-launch videotestsrc ! videorate ! video/x-raw-yuv,framerate=5/1 ! queue ! theoraenc ! queue ! mux. pulsesrc device="alsa_input.usb-046d_HD_Pro_Webcam_C920_F1894590-02-C920.analog-stereo" ! audio/x-raw-int,rate=48000,channels=2,depth=16 ! queue ! audioconvert ! queue ! vorbisenc ! queue ! mux. oggmux name=mux ! filesink location=stream.ogv

But I' trying to get something like this (below) to work.. This one is not working, presumably it's even a very bad combi I made!

gst-launch v4l2src device=/dev/video1 ! video/x-h264,width=1280,height=720,framerate=30/1 ! queue ! mux. pulsesrc device="alsa_input.usb-046d_HD_Pro_Webcam_C920_F1894590-02-C920.analog-stereo" ! audio/x-raw-int,rate=48000,channels=2,depth=16 ! queue ! audioconvert ! queue ! x264enc ! queue ! udpsink host=127.0.0.1 port=1234

skipx
  • 53
  • 1
  • 1
  • 5

1 Answers1

1

You should encode your video before linking it against the mux. Also, I do not see you declaring the type of muxer you are using and you do not put the audio in the mux.

I am not sure it is even possible to send audio AND video over the same rtp stream in this manner in gstreamer. I know that the rtsp server implementation in gstreamer allows audio and video together but even in it I am not sure if it is still two streams just being abstracted away from implementation.

You may want to just use to separate streams and pass them through to a gstrtpbin element.

Benjamin Trent
  • 7,378
  • 3
  • 31
  • 41
  • 1
    I got the following command kind off working: `gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-h264,width=1280,height=720,framerate=30/1 ! h264parse ! muxout. pulsesrc device="alsa_input.pci-0000_00_1b.0.analog-stereo" ! queue ! audioconvert ! voaacenc bitrate=65536 ! aacparse ! muxout. mpegtsmux name=muxout ! queue ! tcpserversink host=192.168.2.13 port=5000'` I mean, it does mux the video and audio and does play over the network. But after several hours audio drops away and is not retrievable until I reboot (I guess something with memory?). – skipx May 12 '14 at 19:55
  • Also the image stutters every second.. How Should I do the encoding? Do you maybe have an example or link with example? Thanks! – skipx May 12 '14 at 19:56
  • @skipx You should probably put an `x264enc` between your caps filter and `h264parse` so that you are actually encoding it. Do have to reboot the streamer or the receiver? It could possibly be a memory issue. You should allow it to drop packets or set a lateness `max-lateness` on your receiver's sink to ignore packets that are too late instead of ever increasing your buffer. – Benjamin Trent May 12 '14 at 20:13
  • Do you mean to place `h264parse` like `video/x-h264,width=1280,height=720,framerate=30/1 ! x264enc ! h264parse` ? Because if I do I get "could not link v4l2src0 to x264enc0" And about rebooting, uhm, the computer.. For now I used `cvlc tcp://172.19.3.106:5000' as client – skipx May 12 '14 at 20:35
  • @skipx I just saw that the camera is auto encoding it to H264. Sorry about that, ignore what I said about x264enc... Your receiver is probably not allowing any buffers to be dropped if they cannot be decoded and displayed in time and continually using more memory. – Benjamin Trent May 12 '14 at 20:55
  • On the server side I now get `Dropped 17110720 samples. This is most likely because downstream can't keep up and is consuming samples too slowly. WARNING: from element /GstPipeline:pipeline0/GstPulseSrc:pulsesrc0: Can't record audio fast enough`. CPU is not obverloaded at all. Next time I start gstreamer and VLC the audio will still be away.. I have to restart the whole computer to get started fresh again. Is it that buffers build up anyway? Are they the same as 'buffers' when I check in the commandline tool 'top'? Plus: should I use gstreamer instead of VLC as client? – skipx May 12 '14 at 21:57
  • Restarting the whole computer does not really make sense, if you kill VLC and Gstreamer than that should get rid of all allocated memory. The buffers are internal to the programs and would not show up as anything in `top` other than memory allocated by said program. I am not sure if tcpserversink has the property `sync` or `async` but try to set both of those properties to `false` if it has it. VLC should work just fine but there may be some codec discrepancies. – Benjamin Trent May 12 '14 at 22:04
  • Setting 'sync=false' at tcpserversync is possible. I will try if it keeps running now! The only last thing keeps happening is that about every second the video-image stops for like 100millisecs. Presumebly this happens when muxing, but I will start an new question for that. Thanks for your help an patience! – skipx May 12 '14 at 22:17
  • Ai, the sync=flase didn't do it. Will look into it tomorrow again :P Now its quite late here.. – skipx May 12 '14 at 22:35