Looks like you're not configuring all of the mandatory keys.
See the MediaFormat doc, and note where it says "all keys not marked optional are mandatory".
Update:
It's crashing on a failed assertion. Judging by the line number and the assert message, you're running jb-mr1 (Android 4.2, API 17); source file is here.
It's complaining about the "native window", which is another way of saying it doesn't like the surface you're passing in. Since you're configuring an encoder, you shouldn't be passing in a surface at all -- that's only for rendered output. Change mSurface
to null
.
If you want to provide input through a Surface, you need to use MediaCodec#createInputSurface()
, which isn't available until API 18.