Hanbrake is a free and open source program for encoding videos to and from a variety of popular formats.
Handbrake can be used to read and encode DVDs to mp4 or mkv files. It can also take video files that have libavformat and libavcodec support. It supports encoding in both ffmpeg and H.264 codecs.
Hanbrake can be installed on Ubuntu through PPA. The PPA page is here.
For more features and information, see this.