Refact the code

encode from mediacodec