I spent two days to test the program as one of my friend want to save frames in video file.
I find that opencv work on video things by FFMPEG library.So before you install opencv ,you mush check if you have install ffmpeg and libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev.
After that ,you can recompile the opencv :
sudo make install
If when you do ./configure ,you can see "ffmpeg yes", then it said opencv can work on ffmpeg..
When I do recompile the source code of opencv , I find something interesting.
Afger configure,I find opencv can find ffmpeg..but it still can not read and write video files.
but after I change something in highgui's source code and do recompile again, it's working..
I think maybe that's because if you dont change anything in the source code .It does not refresh the library...
More information about opencv and Ubuntu