It is possible to compile a video encoder to javascript using emscripten. For example, here is an emscripten-compiled version of google's VP9 libvpx library:
https://bitbucket.org/desmaj/libvpx.js/overview
Unfortunately it is incredibly slow - on the order of one tenth of the speed of the native library. I believe this is due to the fact that there is a lot of memory access going on, and that is incredibly slow in emscripten (see https://bugzilla.mozilla.org/show_bug.cgi?id=771106). Also, encoding generally relies on GPU or SIMD parallelism, which isn't currently available in javascript.
I think video encoding is just not feasible in javascript at present. The best solution would be for W3C to add a video encoding/decoding API to HTML5, perhaps as part of WebRTC/getUserMedia.
Also, see this blog post which describes the situation:
https://brendaneich.com/2013/05/today-i-saw-the-future/