I am trying to stream video from android camera through local unix socket and write file from stream to sdcard. Everything works fine, except file is not playable with any p
First of all, it's not very clear what you are trying to do.
Do you want just to save a video programmatically to a playable file? If so, you just need to use file descriptor instead of unix socket. This API of MediaRecord was designed to work with a file (not unix socket), precisely for the reason of random access. So, my first advise would be to use file descriptor and you will get correct file at the end of recording.
You can get examples here: How can I capture a video recording on Android?
In the case, if you are trying to write an application which streams video from device, you will need to parse the stream in a realime, divide it by frames and send frames separately. And the most complex part is parsing the stream (some video codecs, as example H263 can be parsed and other can't be, especially if the data is interleaved with the audio).
I believe one of these two projects implements such functionality: http://sipdroid.org/ http://code.google.com/p/imsdroid/