The ffmpeg apt package now includes support for hardware encode and decode.
sudo apt install ffmpeg
To see which hardware codecs (using one of the following APIs: v4l2m2m, VAAPI, OMX, MMAL) are available run:
ffmpeg -codecs | grep 'omx\|m2m\|vaa\|mmal'
This will list them all and the first column indicates whether they're available for encode(E)/decode(D).
So for example to use the v4l2m2m H.264 codec to encode 30secs of colour bars:
ffmpeg -f lavfi -i smptebars -t 30 -vcodec h264_v4l2m2m out.mp4
Or use the OMX based H.264 hardware encoder to encode input_file:
ffmpeg -i input_file -vcodec h264_omx out.mp4
Also if you have changed the gpu_mem setting in /boot/config.txt it needs to be greater than 16, otherwise you will get an error with any hardware codecs.
raspiyuv -o - | rpi-encode-yuv(roughly) where therpi-encode-yuvtool is from here. The frame size is hard-coded in this tool, so you need to change it at the beginning of the C file and recompile. Unfortunately I haven't managed to get a properly aligned output yet, asraspiyuvdoesn't seem to encode the frame size into its output. I get a gradually shifting picture that eventually turns to garbage. Still working on it. – Szabolcs Jun 06 '14 at 03:20