In my Android app, I want to compress mp4 video by changing its resolution, bitrate. I don't want to use FFmpeg (because I don't want to use NDK), so I decided to use MediaCodec API.
Here are my logical steps:
Extract video file with MediaExtractor, then decode data.
Create new encoder with my new resolution, bitrate and encode data.
Using MediaMuxer to create a new mp4 file.
My problem is: I don't know how to setup the connection between output of decoder and input of encoder. I can decode the video to a Surface or encode a new video from a surface. But I don't understand how to connect them.
Can anybody give me a clear explanation what I have to do?
解决方案
I have used this to see how to manipulate video in android: https://github.com/hoolrory/AndroidVideoSamples , check the VideoResampler.java in the CommonVideoLibrary .