If you have gstreamer, here is a pipeline to do it and to view your output. This one replaces all black in video hi.mp4 with the content from the other video. Play around with the values to get what you need. Will work if your text or background (one of them) has uniform color and within a range.
gst-launch filesrc location=hi.mp4 ! decodebin2 ! ffmpegcolorspace ! alpha alpha=1 method=3 target-r=0 target-g=0 target-b=0 white-sensitivity=0 black-sensitivity=128 ! videomixer name=vm ! ffmpegcolorspace ! sdlvideosink filesrc location=hi2.mp4 ! decodebin2 ! ffmpegcolorspace ! alpha alpha=1 ! vm.
You can then replace the sdlvideo sink with an encoder x264enc and pass through your audio from one of the videos to create your container.
If you don't know what gstreamer is or aren't inclined to use it then ffmpeg with frei0r will do the trick as lordneckbeard mentioned. I just felt this is quicker. :)
How to get to this pipeline?
sudo apt-get install gstreamer-0.10 base, good bad and ugly and libav/ffmpeg plugins and gstreamer-tools packages - Look at gstreamer.net if you want to build from source.
The command line above will work and display the file. Replace sdlvideo sink with something like:
x264enc bitrate= ! flvmux ! filesink location=filename.flv
If you have never used gstreamer before you will have to do a little bit of reading up on what a pipeline is and how to run one. Plenty of tutorials available. If you are not inclined to use gstreamer then perhaps the other tools pointed out in other answers will help. However I suggest you use gstreamer because then you can also do other manipulations with it if you need any in the future.