I am using the following pipeline currently:
gst-launch-1.0 -e ximagesrc xid=$ID ! video/x-raw,framerate=24/1 ! queue ! videoconvert ! \
videorate ! queue ! x264enc key-int-max=12 cabac=1 bframes=2 ! 'video/x-h264,profile=high' ! \
queue ! mp4mux name=mux reserved-bytes-per-sec=100 reserved-max-duration=20184000000000 reserved-moov-update-period=100000000 ! \
queue ! filesink location=video.mp4 pulsesrc device=$DEV ! queue ! audioconvert ! \
audioresample ! 'audio/x-raw, rate=48000' ! queue ! lamemp3enc bitrate=320 ! queue ! mux.
Then I record audio based on the audio track and mux them together with mencoder :-/
mencoder -ovc copy -oac mp3lame video.mp4 -audiofile audio.wav -o cut.mp4 -endpos 27:13
I haven't figured out how to encode AAC (which is preferred by Youtube) and it's no longer a priority for me.
videoconvert ! x264enc ! mp4mux ! filesink location=video-h264-1280x720.mp4
but it does not produce a file that is playable by mplayer or vlc :(