Using ffmpeg to encode a raw video to H.264 format

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. fourcc.org 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