It seems that the removal of start code emulation prevention bytes is not required for MediaCodec, and moreover if done, it creates random decoding errors at the other end (even if the other end is not a MediaCodec implementation). H26x stream to nalus and nalus to stream refactoring to remove a copy to a temporary buffer.