protected void setTranscodeParameters(MediaComposer mediaComposer) throws IOException { mediaComposer.addSourceFile(mediaUri1); mediaComposer.setTargetFile(dstMediaPath); configureVideoEncoder(mediaComposer, videoWidthOut, videoHeightOut); configureAudioEncoder(mediaComposer); }
protected void transcode() throws Exception { factory = new AndroidMediaObjectFactory(getApplicationContext()); mediaComposer = new MediaComposer(factory, progressListener); setTranscodeParameters(mediaComposer); mediaComposer.start(); }
@Override protected void onDestroy() { if (mediaComposer != null) { mediaComposer.stop(); isStopped = true; } super.onDestroy(); }
protected void configureAudioEncoder(MediaComposer mediaComposer) { AudioFormatAndroid audioFormat = new AudioFormatAndroid(audioMimeType, audioSampleRate, audioChannelCount); audioFormat.setAudioBitrateInBytes(audioBitRate); audioFormat.setAudioProfile(MediaCodecInfo.CodecProfileLevel.AACObjectLC); mediaComposer.setTargetAudioFormat(audioFormat); }
protected void configureVideoEncoder(MediaComposer mediaComposer, int width, int height) { VideoFormatAndroid videoFormat = new VideoFormatAndroid(videoMimeType, width, height); videoFormat.setVideoBitRateInKBytes(videoBitRateInKBytes); videoFormat.setVideoFrameRate(videoFrameRate); videoFormat.setVideoIFrameInterval(videoIFrameInterval); mediaComposer.setTargetVideoFormat(videoFormat); }
public void stopTranscode() { mediaComposer.stop(); }