use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testVideoContentHD.
/**
* To test Video Editor API with 1080 P
*
* @throws Exception
*/
@LargeTest
public void testVideoContentHD() throws Exception {
final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1920x1080_30fps_1200Kbps_1_10.mp4";
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaVideoItem mediaVideoItem1;
// 1080p resolution is supported on some devices
// but not on other devices.
// So this test case is not generic and
// hence we always assert true
boolean flagForException = true;
try {
mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName1, renderingMode);
} catch (IllegalArgumentException e) {
}
assertTrue("VideoContent 1920x1080", flagForException);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testMediaVideoItemAudioFeatures.
/**
* To Test the Media Video API : Set Audio Volume, Get Audio Volume and Mute
*/
@LargeTest
public void testMediaVideoItemAudioFeatures() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
boolean flagForException = false;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
mVideoEditor.addMediaItem(mediaVideoItem1);
mediaVideoItem1.setVolume(77);
assertEquals("Updated Volume is 77", 77, mediaVideoItem1.getVolume());
mediaVideoItem1.setMute(true);
assertTrue("Audio must be Muted", mediaVideoItem1.isMuted());
mediaVideoItem1.setVolume(78);
assertEquals("Updated Volume is 78", 78, mediaVideoItem1.getVolume());
assertTrue("Audio must be Muted", mediaVideoItem1.isMuted());
try {
mediaVideoItem1.setVolume(1000);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Invalid Set Volume", flagForException);
mediaVideoItem1.setMute(false);
assertFalse("Audio must be Un-Muted", mediaVideoItem1.isMuted());
mediaVideoItem1.setVolume(0);
assertFalse("Audio must be Un-Muted", mediaVideoItem1.isMuted());
flagForException = false;
try {
mediaVideoItem1.setVolume(-1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Invalid Set Volume", flagForException);
mediaVideoItem1.setVolume(100);
assertEquals("MediaItem Volume", 100, mediaVideoItem1.getVolume());
try {
mediaVideoItem1.setVolume(101);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Invalid Set Volume", flagForException);
assertEquals("MediaItem Volume", 100, mediaVideoItem1.getVolume());
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testFrameOverlaySetAndGet.
/**
* To test Frame Overlay for Media Video Item : Set duration and Get
* Duration
*/
@LargeTest
public void testFrameOverlaySetAndGet() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4";
final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
boolean flagForException = false;
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, 480);
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem1);
final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId1", mBitmap, 5000, 5000);
mediaVideoItem1.addOverlay(overlayFrame1);
overlayFrame1.setDuration(5000);
assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration());
try {
overlayFrame1.setDuration(mediaVideoItem1.getDuration() + 10000);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Overlay Duration > MediaVideo Item Duration", flagForException);
assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration());
flagForException = false;
try {
overlayFrame1.setDuration(-1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Overlay Duration = -1", flagForException);
}
use of android.media.videoeditor.MediaVideoItem 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.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testMediaVideoItemExtractBoundaries.
/**
* To test creation of Media Video Item with Set Extract Boundaries With Get
* the Begin and End Time.
*/
@LargeTest
public void testMediaVideoItemExtractBoundaries() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
boolean flagForException = false;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
mVideoEditor.addMediaItem(mediaVideoItem1);
mediaVideoItem1.setExtractBoundaries(1000, 11000);
assertEquals("Media Item Duration = StoryBoard Duration", mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration());
try {
mediaVideoItem1.setExtractBoundaries(0, 100000000);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Set Extract with Invalid Values endTime > FileDuration", flagForException);
flagForException = false;
try {
mediaVideoItem1.setExtractBoundaries(100000000, 11000);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Set Extract with Invalid Values startTime > endTime", flagForException);
flagForException = false;
try {
mediaVideoItem1.setExtractBoundaries(0, 0);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Set Extract with Invalid Values startTime = endTime", flagForException);
mediaVideoItem1.setExtractBoundaries(1000, 10000);
assertTrue("Media Item Duration is still the same", (mediaVideoItem1.getTimelineDuration() == (mediaVideoItem1.getBoundaryEndTime() - mediaVideoItem1.getBoundaryBeginTime())) ? true : false);
mediaVideoItem1.setExtractBoundaries(1, mediaVideoItem1.getDuration() - 1);
assertEquals("Media Item Start Time", 1, mediaVideoItem1.getBoundaryBeginTime());
assertEquals("Media Item End Time", (mediaVideoItem1.getDuration() - 1), mediaVideoItem1.getBoundaryEndTime());
mediaVideoItem1.setExtractBoundaries(1, mediaVideoItem1.getDuration());
assertEquals("Media Item Duration = StoryBoard Duration", mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration());
mediaVideoItem1.setExtractBoundaries(0, mediaVideoItem1.getDuration() / 2);
assertEquals("Media Item Duration = StoryBoard Duration", mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration());
mediaVideoItem1.setExtractBoundaries(0, -1);
assertEquals("Media Item Duration = StoryBoard Duration", mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration());
}
Aggregations