Convert AVCHD/HDTV (MTS-M2TS) videos to AVI format

MTS or M2TS formats are MPEG Transport Stream used for blu-ray and for digital cameras. I've used a Sony camera to record a video and the result was a file with extension .MTS. After many tests I've found some tools to convert MTS format to another. First software is "xproc": this extract audio and video tracks from MTS with 2 output files (one .MPA and one .MPV). Second software is "ldecod" that convert MPV file to YUV. After this you can use "ffmpeg" for example to join audio and video(YUV) in AVI format.
Software downloads:

xProc - Extract audio and video from MTS or M2TS file
ldecod - Convert MPV file to YUV format ffmpeg - Get latest version of ffmpeg

Example: Convert MTS to AVI MTS to MPA and MPV

xport -nh samplevideo.m2ts 1 1 1

MPV to YUV

ldecod -i bits0001.mpv -o samplevideo.yuv

join to AVI

mv bits0001.mpa samplevideo.ac3
ffmpeg -r 29.97 -s 1440x1080 -i samplevideo.yuv -i samplevideo.ac3 -acodec copy -vcodec mpeg4 -aspect 16:9 -b 15000k samplevideo.avi