This has more-or-less been posted on many forums, but not with the flipping. gstreamer comes with a nice element for it, videoflip, worked fine on my desktop but didn't like to link on the phone, after some head scratching I found that it needed a colorspace conversion both before and after for some reason.
#!/bin/sh
ENC=dsphdh264enc
W=800
H=480
R=5
gst-launch-0.10 -e -t -v -m ximagesrc ! videoscale ! videorate ! \
video/x-raw-rgb,framerate=${R}/1,width=${W},height=${H} ! ffmpegcolorspace ! \
videoflip method=clockwise ! ffmpegcolorspace ! ${ENC} ! \
avimux ! filesink location=desktop.avi