Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

On a Ubuntu 10.04, I am trying to encode a raw video (YUV format) to a H.264 encoded video using below ffmpeg commands:

ffmpeg -i input.mp4 output.h264

but I get an error saying

Unsupported codec for output stream #0.0

Then when I try this option:

ffmpeg -i input.mp4 -formats h264 output.h264

it still does not encode.

Now I understood that ffmpeg uses libx264 for encoding to H.264 format. Now I have the package x264 - fast H.264 encoder installed on this Ubuntu.

My questions:

  1. Is there any relation between this libx264 which ffmpeg needs and x264 program?
  2. How do I install libx264 and make ffmpeg use this to allow me to encode a video to H.264 format?
share|improve this question
What about your previous question, wasn't that solved? ffmpeg usage to encode a video to H264 codec format – slhck Aug 12 '11 at 13:25
@slhck - Thanks but, When I used:- ffmpeg -s 352x240 -i 352x240_420.yuv -vcodec libx264 out.mp4. It gave error - "Unknown encoder 'libx264'". Any further pointers. Is libx264 same as x264 library or something other. – goldenmean Aug 12 '11 at 15:44
Regarding compiling ffmpeg and x264 on Linux, see here: – slhck Sep 3 '13 at 15:43
up vote 5 down vote accepted

First of all, those commands you use look syntactically incorrect. In order to have ffmpeg use x264, you need to supply the -c:v libx264 argument.

Now, if you have a raw YUV file, you need to tell ffmpeg which pixel format, which size, etc. is used:

ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1920x1080 -r 25 -i input.yuv \
-c:v libx264 output.mp4

Change these according to your YUV file's specifications. Have a look at ffmpeg -pix_fmts for a list of supported pixel formats. is also a good resource on that.

If you just want the raw H.264 bitstream in a .264 file:

ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1920x1080 -r 25 -i input.yuv \
-c:v libx264 -f rawvideo output.264
share|improve this answer

ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1920x1080 -r 23.976 -i raw_i420_1920_1080 -vcodec libx264 -f rawvideo output.264

-vcodec tells it which codec to use. man ffmpeg will help you learn more.

share|improve this answer

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.