I want to compress a locally saved video file to a smaller size in order to upload it to the server.
Since I used MediaCodec, I found some tips for compressing the video. Here are the steps I followed
1). Extracted media using MediaExrtactor and decoded. 2). Creates an encoder with the desired file format 3). Create a multiplexer to save the file to local storage. (not complete)
Question: But I do not know how to encode an already decoded stream and save the stream to local storage using MediaMuxer.
public class CompressMedia { private static final String SAMPLE = Environment .getExternalStorageDirectory() + "/DCIM/Camera/20140506_174959.mp4"; private static final String OUTPUT_PATH = Environment .getExternalStorageDirectory() + "/DCIM/Camera/20140506_174959_REC.mp4"; private MediaExtractor extractor; private MediaCodec decoder; private MediaCodec encoder; String mime; private static final String MIME_TYPE = "video/avc"; public void extractMediaFile() {
Here are the links I wrote Android MediaCodec: reduce the size of the mp4 video and
Compress video on Android using the new MediaCodec library
source share