Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
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
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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