Initially I wasn't getting caps at all because I didn't use ffmpegcolorspace.
Now I am getting caps but at the end it is giving the same errro.
root@wandboard-dual:/home/video_test# gst-launch v4l2src ! ffmpegcolorspace ! x2
64enc ! matroskamux ! filesink location=outputh264.mp4 sync=false -v
Setting pipeline to PAUSED ...
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw-yuv, f
ormat=(fourcc)YUY2, width=(int)640, height=(int)480, interlaced=(boolean)false,
pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, mpegversion=(int)1,
systemstream=(boolean)false
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstFFMpegCsp:ffmpegcsp0.GstPad:src: caps = video/x-raw-yu
v, mpegversion=(int)1, systemstream=(boolean)false, width=(int)640, height=(int)
480, framerate=(fraction)30/1, format=(fourcc)I420, interlaced=(boolean)false, p
ixel-aspect-ratio=(fraction)1/1
/GstPipeline:pipeline0/GstFFMpegCsp:ffmpegcsp0.GstPad:sink: caps = video/x-raw-y
uv, format=(fourcc)YUY2, width=(int)640, height=(int)480, interlaced=(boolean)fa
lse, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, mpegversion=(in
t)1, systemstream=(boolean)false
/GstPipeline:pipeline0/GstX264Enc:x264enc0.GstPad:src: caps = video/x-h264, widt
h=(int)640, height=(int)480, framerate=(fraction)30/1, pixel-aspect-ratio=(fract
ion)1/1, codec_data=(buffer)0164001effe100186764001eacd940a03db01100000300017735
94000f162d9601000568ebecb22c, stream-format=(string)avc, alignment=(string)au, l
evel=(string)3, profile=(string)high
/GstPipeline:pipeline0/GstX264Enc:x264enc0.GstPad:sink: caps = video/x-raw-yuv,
mpegversion=(int)1, systemstream=(boolean)false, width=(int)640, height=(int)480
, framerate=(fraction)30/1, format=(fourcc)I420, interlaced=(boolean)false, pixe
l-aspect-ratio=(fraction)1/1
Caught SIGSEGV accessing address 0x915
#0 0x4046abf4 in ?? ()
#1 0x4046abe4 in ?? ()
#2 0x4046abe4 in ?? ()
Spinning. Please run 'gdb gst-launch 1732' to continue debugging, Ctrl-C to qui
t, or Ctrl-\ to dump core.