I have a web-cam which I want to use to stream h264 video. Now I'm streaming mjpg video with mjpg-streamer. And now I'd like to stream h264. I've found that it could be done with gstreamer, but I'm totally new to it. Also after reading some blogs/articles/etc it seems to me that there were some issues with h264 and gstreamer. Is it still true?

May be there are some other methods to do this besides gstreamer?

Any info would be helpful. Thanks in advance.


I will explain how to stream h264 using gstreamer.

First, you need Linux kernel 3.2 or later to have "H264 pixel format" supported in the v4l2 drivers.

Use v4l2-ctl to check that you have proper H.264 support for the camera:

# v4l2-ctl --list-formats
# v4l2-ctl --list-formats-ext

Next, you will need video4linux libraries and utilities. These include:

libv4l and libv4l-dev
qv4l2 (may be part of v4l-utils)

Setting up the frame rate:

# v4l2-ctl --set-fmt-video=width=800,height=448,pixelformat=1
# v4l2-ctl --set-parm=30

Gstreamer has a v4l2src input element, it does not yet support the video/x-264 format.

But, we can capture H.264 stream and send to a file or even standard out, by simply piping it to the standard input of a gstreamer pipeline using a file source:

#  ./capture -c 100000 -o | gst-launch -v -e filesrc location=/dev/fd/0 ! h264parse ! decodebin2 ! xvimagesink sync=false

The encoded video stream can be sent over the network using Gstreamer:

#  gst-launch -v udpsrc port=4000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! \
          rtph264depay ! ffdec_h264 ! xvimagesink sync=false

 # ./capture -c 10000 -o | gst-launch -v -e filesrc location=/dev/fd/0 ! h264parse ! rtph264pay ! udpsink  host=host_IP port=4000

I hope you will find this useful.

  • Hello, Mansab. I've checked source of v4l2src, there is "video/x-h264" format. Is that it or not? – Val Dec 4 '12 at 11:03
  • 1
    Also Mansab, I think you should give a link to a source: oz9aec.net/index.php/gstreamer/… – Val Dec 4 '12 at 12:15
  • I don't think video/x-h264 is supported, in the pipeline. Must be that is what, you are asking about the issues with gstreamer. – Mansab Uppal Dec 4 '12 at 21:29
  • 2
    Where does ./capture come from? – rsaxvc Dec 26 '19 at 3:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.