use of android.media.videoeditor.AudioTrack in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testVideoEditorAPI.
/**
* To test Video Editor API
*
* @throws Exception
*/
@LargeTest
public void testVideoEditorAPI() throws Exception {
final String videoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
final String videoItemFileName2 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp";
final String videoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
final String audioFilename1 = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
final String audioFilename2 = INPUT_FILE_PATH + "AACLC_48KHz_256Kbps_s_1_17.3gp";
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
boolean flagForException = false;
TransitionCrossfade transition2And4;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName1, renderingMode);
mediaVideoItem1.setExtractBoundaries(0, 10000);
mVideoEditor.addMediaItem(mediaVideoItem1);
final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFileName2, renderingMode);
mediaVideoItem2.setExtractBoundaries(mediaVideoItem2.getDuration() / 4, mediaVideoItem2.getDuration() / 2);
mVideoEditor.addMediaItem(mediaVideoItem2);
final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFileName3, renderingMode);
mediaVideoItem3.setExtractBoundaries(mediaVideoItem3.getDuration() / 2, mediaVideoItem3.getDuration());
mVideoEditor.addMediaItem(mediaVideoItem3);
final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", imageItemFileName1, 5000, renderingMode);
final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFileName2, 5000, renderingMode);
List<MediaItem> mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 3, mediaList.size());
mVideoEditor.insertMediaItem(mediaImageItem1, mediaVideoItem2.getId());
mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 4, mediaList.size());
assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0));
assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1));
assertEquals("Media item 4", mediaImageItem1, mediaList.get(2));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(3));
mVideoEditor.insertMediaItem(mediaImageItem2, mediaImageItem1.getId());
mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 5, mediaList.size());
assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0));
assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1));
assertEquals("Media item 4", mediaImageItem1, mediaList.get(2));
assertEquals("Media item 5", mediaImageItem2, mediaList.get(3));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
mVideoEditor.moveMediaItem(mediaVideoItem1.getId(), mediaImageItem2.getId());
mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 5, mediaList.size());
assertEquals("Media item 2", mediaVideoItem2, mediaList.get(0));
assertEquals("Media item 4", mediaImageItem1, mediaList.get(1));
assertEquals("Media item 5", mediaImageItem2, mediaList.get(2));
assertEquals("Media item 1", mediaVideoItem1, mediaList.get(3));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
assertEquals("Media Item 1", mediaVideoItem1, mVideoEditor.getMediaItem(mediaVideoItem1.getId()));
flagForException = false;
transition2And4 = null;
try {
transition2And4 = mVideoEditorHelper.createTCrossFade("transition2And4", mediaVideoItem2, mediaImageItem1, 2000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(transition2And4);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertFalse("Transition2and4 cannot be created", flagForException);
TransitionCrossfade transition1And3 = null;
flagForException = false;
try {
transition1And3 = mVideoEditorHelper.createTCrossFade("transition1And3", mediaVideoItem1, mediaVideoItem2, 5000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(transition1And3);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Transition1and3 cannot be created", flagForException);
List<Transition> transitionList = mVideoEditor.getAllTransitions();
assertEquals("Transition List", 1, transitionList.size());
assertEquals("Transition 2", transition2And4, mVideoEditor.getTransition(transition2And4.getId()));
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack", audioFilename1);
mVideoEditor.addAudioTrack(audioTrack);
List<AudioTrack> audioList = mVideoEditor.getAllAudioTracks();
assertEquals("Audio List", 1, audioList.size());
final AudioTrack audioTrack1 = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack1", audioFilename2);
flagForException = false;
try {
mVideoEditor.addAudioTrack(audioTrack1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Audio Track support is 1 ", flagForException);
flagForException = false;
try {
mVideoEditor.insertAudioTrack(audioTrack1, "audioTrack");
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Audio Track supports is 1 ", flagForException);
assertEquals("Removing AudioTrack", audioTrack, mVideoEditor.removeAudioTrack(audioTrack.getId()));
assertEquals("Removing transition", transition2And4, mVideoEditor.removeTransition(transition2And4.getId()));
assertEquals("Removing Media Item", mediaVideoItem2, mVideoEditor.removeMediaItem(mediaVideoItem2.getId()));
mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_16_9);
assertEquals("Check Aspect Ratio", MediaProperties.ASPECT_RATIO_16_9, mVideoEditor.getAspectRatio());
long storyBoardDuration = mediaVideoItem1.getTimelineDuration() + mediaVideoItem3.getTimelineDuration() + mediaImageItem1.getDuration() + mediaImageItem2.getDuration();
assertEquals("Story Board Duration", storyBoardDuration, mVideoEditor.getDuration());
}
use of android.media.videoeditor.AudioTrack in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testAudioTrackEnableDucking.
/**
* To Test the Audio Track API: Enable Ducking
*/
@LargeTest
public void testAudioTrackEnableDucking() throws Exception {
final String audioFileName = INPUT_FILE_PATH + "AACLC_48KHz_256Kbps_s_1_17.3gp";
boolean flagForException = false;
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack", audioFileName);
mVideoEditor.addAudioTrack(audioTrack);
assertFalse("Audio Ducking Disabled by default", audioTrack.isDuckingEnabled());
audioTrack.enableDucking(45, 70);
assertTrue("Audio Ducking Enabled", audioTrack.isDuckingEnabled());
assertEquals("Audio Ducking Threshold", 45, audioTrack.getDuckingThreshhold());
assertEquals("Audio Ducking Volume", 70, audioTrack.getDuckedTrackVolume());
audioTrack.enableDucking(85, 70);
assertEquals("Audio Ducking Threshold", 85, audioTrack.getDuckingThreshhold());
assertEquals("Audio Ducking Volume", 70, audioTrack.getDuckedTrackVolume());
try {
audioTrack.enableDucking(91, 70);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Enable ducking threshold > 90", flagForException);
flagForException = false;
try {
audioTrack.enableDucking(90, 101);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Enable ducking volume > 100", flagForException);
flagForException = false;
try {
audioTrack.enableDucking(91, 101);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Enable ducking volume > 100 and threshold > 91", flagForException);
flagForException = false;
try {
audioTrack.enableDucking(-1, 100);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Enable ducking threshold < 0", flagForException);
flagForException = false;
try {
audioTrack.enableDucking(1, -1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Enable ducking lowVolume < 0", flagForException);
flagForException = false;
try {
audioTrack.enableDucking(0, 50);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertFalse("Enable ducking threshold = 0", flagForException);
}
use of android.media.videoeditor.AudioTrack in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPreviewTest method testRenderPreviewFrame.
/**
* To test render Preview Frame
*/
@LargeTest
public void testRenderPreviewFrame() throws Exception {
final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
final String videoItemFileName2 = INPUT_FILE_PATH + "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
final String videoItemFileName3 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
final String audioFilename = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
OverlayData overlayData1 = new OverlayData();
previewStart = false;
previewStop = false;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(0, 10000);
mVideoEditor.addMediaItem(mediaVideoItem1);
final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFileName2, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(mediaVideoItem2.getDuration() / 4, mediaVideoItem2.getDuration() / 2);
mVideoEditor.addMediaItem(mediaVideoItem2);
final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFileName3, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(mediaVideoItem2.getDuration() / 2, mediaVideoItem2.getDuration());
mVideoEditor.addMediaItem(mediaVideoItem3);
final MediaImageItem mediaImageItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", imageItemFilename1, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER);
final MediaImageItem mediaImageItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFilename2, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER);
List<MediaItem> mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 3, mediaList.size());
mVideoEditor.insertMediaItem(mediaImageItem4, mediaVideoItem2.getId());
mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 4, mediaList.size());
assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0));
assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1));
assertEquals("Media item 4", mediaImageItem4, mediaList.get(2));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(3));
mVideoEditor.insertMediaItem(mediaImageItem5, mediaImageItem4.getId());
mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 5, mediaList.size());
assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0));
assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1));
assertEquals("Media item 4", mediaImageItem4, mediaList.get(2));
assertEquals("Media item 5", mediaImageItem5, mediaList.get(3));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
mVideoEditor.moveMediaItem(mediaVideoItem1.getId(), mediaImageItem5.getId());
mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 5, mediaList.size());
assertEquals("Media item 2", mediaVideoItem2, mediaList.get(0));
assertEquals("Media item 4", mediaImageItem4, mediaList.get(1));
assertEquals("Media item 5", mediaImageItem5, mediaList.get(2));
assertEquals("Media item 1", mediaVideoItem1, mediaList.get(3));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
final TransitionCrossfade transition2And4CrossFade = mVideoEditorHelper.createTCrossFade("transition2And4CrossFade", mediaVideoItem2, mediaImageItem4, 2000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(transition2And4CrossFade);
final TransitionCrossfade transition1And3CrossFade = mVideoEditorHelper.createTCrossFade("transition1And3CrossFade", mediaVideoItem1, mediaVideoItem3, 5000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(transition1And3CrossFade);
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "a1", audioFilename);
audioTrack.setExtractBoundaries(0, 2000);
mVideoEditor.addAudioTrack(audioTrack);
audioTrack.enableLoop();
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
public void onProgress(Object item, int action, int progress) {
}
});
final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration() / 4, overlayData1);
Thread.sleep(1000);
mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration() / 2, overlayData1);
Thread.sleep(1000);
mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration(), overlayData1);
}
use of android.media.videoeditor.AudioTrack in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPreviewTest method testPreviewWithEndAudioTrack.
/**
* To test Preview : Preview of current work from selected jump location
* till end with Audio Track
*/
@LargeTest
public void testPreviewWithEndAudioTrack() throws Exception {
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String audioFilename = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
boolean flagForException = false;
previewStart = false;
previewStop = false;
final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", imageItemFilename1, 7000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem1);
final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem.setExtractBoundaries(1000, 8000);
mVideoEditor.addMediaItem(mediaVideoItem);
final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", imageItemFilename2, 7000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem2);
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "a1", audioFilename);
mVideoEditor.addAudioTrack(audioTrack);
List<AudioTrack> audioList = mVideoEditor.getAllAudioTracks();
assertEquals("Audio Track List size", 1, audioList.size());
assertEquals("Audio Track", audioTrack, audioList.get(0));
mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_4_3);
validatePreviewProgress(10000, -1, false, mVideoEditor.getDuration());
}
use of android.media.videoeditor.AudioTrack in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorStressTest method testStressStoryBoard.
/**
* To Test Stress : Story Board creation with out preview or export
*
* @throws Exception
*/
@LargeTest
public void testStressStoryBoard() throws Exception {
final String videoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
final String videoItemFileName2 = INPUT_FILE_PATH + "MPEG4_SP_854x480_15fps_256kbps_AACLC_16khz_48kbps_s_0_26.mp4";
final String videoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
final String imageItemFileName4 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String imageItemFileName5 = INPUT_FILE_PATH + "IMG_176x144.jpg";
final String audioFilename6 = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
final String audioFilename7 = INPUT_FILE_PATH + "AACLC_44.1kHz_256kbps_s_1_17.mp4";
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final int audioVolume = 50;
final String[] loggingInfo = new String[1];
int i = 1;
writeTestCaseHeader("testStressStoryBoard");
getBeginMemory();
final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1", videoItemFileName1, renderingMode);
mediaItem1.setExtractBoundaries(0, 10000);
mVideoEditor.addMediaItem(mediaItem1);
final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor, "m2", videoItemFileName2, renderingMode);
mediaItem2.setExtractBoundaries(mediaItem2.getDuration() / 4, mediaItem2.getDuration() / 2);
mVideoEditor.addMediaItem(mediaItem2);
final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, "m3", videoItemFileName3, renderingMode);
mediaItem3.setExtractBoundaries(mediaItem3.getDuration() / 2, mediaItem3.getDuration());
mVideoEditor.addMediaItem(mediaItem3);
final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor, "m4", imageItemFileName4, 5000, renderingMode);
mVideoEditor.addMediaItem(mediaItem4);
final MediaImageItem mediaItem5 = new MediaImageItem(mVideoEditor, "m5", imageItemFileName5, 5000, renderingMode);
mVideoEditor.addMediaItem(mediaItem5);
final TransitionCrossfade tranCrossfade = new TransitionCrossfade("transCF", mediaItem2, mediaItem3, 2500, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(tranCrossfade);
final TransitionCrossfade tranCrossfade1 = new TransitionCrossfade("transCF1", mediaItem3, mediaItem4, 2500, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(tranCrossfade1);
final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor, "Audio Track1", audioFilename6);
mVideoEditor.addAudioTrack(audioTrack1);
mVideoEditor.removeAudioTrack("Audio Track1");
final AudioTrack audioTrack2 = new AudioTrack(mVideoEditor, "Audio Track2", audioFilename7);
mVideoEditor.addAudioTrack(audioTrack2);
audioTrack2.enableLoop();
getAfterMemory_updateLog(loggingInfo, false, i);
/** Remove items and check for memory leak if any */
getBeginMemory();
mVideoEditor.removeAudioTrack("Audio Track2");
mVideoEditor.removeTransition("transCF");
mVideoEditor.removeTransition("transCF1");
mVideoEditor.removeMediaItem("m5");
mVideoEditor.removeMediaItem("m4");
mVideoEditor.removeMediaItem("m3");
mVideoEditor.removeMediaItem("m2");
mVideoEditor.removeMediaItem("m1");
getAfterMemory_updateLog(loggingInfo, true, i);
}
Aggregations