use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorHelper method validateExport.
/**
*This Method validates the Exported Movie,as per the specified params
* during Export
*/
public void validateExport(VideoEditor videoEditor, String fileName, int export_height, int startTime, long endTime, int vCodec, int aCodec) {
File tempFile = new File(fileName);
assertEquals("Exported FileName", tempFile.exists(), true);
final MediaVideoItem mvi = createMediaItem(videoEditor, "m1", fileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
Log.i(TAG, "VideoCodec for file = " + fileName + "\tExpected Video Codec = " + vCodec + "\tActual Video Codec = " + mvi.getVideoType());
assertEquals("Export: Video Codec Mismatch for file = " + fileName + "\t<expected> " + vCodec + "\t<actual> " + mvi.getVideoType(), vCodec, mvi.getVideoType());
Log.i(TAG, "Height for file = " + fileName + "\tExpected Height = " + export_height + "\tActual VideoHeight = " + mvi.getHeight());
assertEquals("Export height Mismatch for file " + fileName + "\t<expected> " + export_height + "\t<actual> " + mvi.getHeight(), export_height, mvi.getHeight());
if (startTime == 0) {
if (endTime != 0) {
Log.i(TAG, "TimeLine Expected = " + (startTime + endTime) + "\t VideoTime= " + mvi.getTimelineDuration());
assertTrue("Timeline Duration Mismatch for file " + fileName + "<expected> " + (startTime + endTime) + "\t<actual> " + mvi.getTimelineDuration(), checkRange((startTime + endTime), mvi.getTimelineDuration(), 10));
}
} else {
Log.i(TAG, "TimeLine Expected = " + (endTime - startTime) + "\t VideoTime= " + mvi.getTimelineDuration());
assertTrue("Timeline Duration Mismatch for file " + fileName + "<expected> " + (endTime - startTime) + "\t<actual> " + mvi.getTimelineDuration(), checkRange((endTime - startTime), (int) mvi.getTimelineDuration(), 10));
}
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testEffectSetgetDuration.
/**
* To test Effect Color : Set duration and Get Duration
*/
@LargeTest
public void testEffectSetgetDuration() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH + "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4";
final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
boolean flagForException = false;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
mVideoEditor.addMediaItem(mediaVideoItem1);
final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", 1000, 2000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaVideoItem1.addEffect(effectColor1);
effectColor1.setDuration(5000);
assertEquals("Updated Effect Duration", 5000, effectColor1.getDuration());
try {
effectColor1.setDuration(mediaVideoItem1.getDuration() + 1000);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Effect Color duration > mediaVideoItemDuration", flagForException);
assertEquals("Effect Duration", 5000, effectColor1.getDuration());
flagForException = false;
try {
effectColor1.setDuration(-1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Effect Color duration = -1", flagForException);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testTransitionFadeBlack.
/**
* To test Transition : Fade To Black with all behavior
* SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST
*/
@LargeTest
public void testTransitionFadeBlack() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
final String videoItemFilename2 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_128kbps_1_35.3gp";
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String videoItemFilename3 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_192kbps_1_5.mp4";
final String videoItemFilename4 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4";
final String videoItemFilename5 = INPUT_FILE_PATH + "H263_profile0_176x144_10fps_96kbps_0_25.3gp";
boolean flagForException = false;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(0, 15000);
mVideoEditor.addMediaItem(mediaVideoItem1);
final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem2.setExtractBoundaries(0, 15000);
mVideoEditor.addMediaItem(mediaVideoItem2);
final TransitionFadeBlack transition1And2 = mVideoEditorHelper.createTFadeBlack("transition1And2", mediaVideoItem1, mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP);
mVideoEditor.addTransition(transition1And2);
assertTrue("Transition ID", transition1And2.getId().equals("transition1And2"));
assertEquals("Transtion After Media item", mediaVideoItem1, transition1And2.getAfterMediaItem());
assertEquals("Transtion Before Media item", mediaVideoItem2, transition1And2.getBeforeMediaItem());
assertEquals("Transtion Duration", 3000, transition1And2.getDuration());
assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_UP, transition1And2.getBehavior());
final MediaImageItem mediaImageItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem3);
final TransitionFadeBlack transition2And3 = mVideoEditorHelper.createTFadeBlack("transition2And3", mediaVideoItem2, mediaImageItem3, 1000, Transition.BEHAVIOR_SPEED_DOWN);
mVideoEditor.addTransition(transition2And3);
assertTrue("Transition ID", transition2And3.getId().equals("transition2And3"));
assertEquals("Transtion After Media item", mediaVideoItem2, transition2And3.getAfterMediaItem());
assertEquals("Transtion Before Media item", mediaImageItem3, transition2And3.getBeforeMediaItem());
assertEquals("Transtion Duration", 1000, transition2And3.getDuration());
assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_DOWN, transition2And3.getBehavior());
final MediaVideoItem mediaVideoItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem4.setExtractBoundaries(0, 20000);
mVideoEditor.addMediaItem(mediaVideoItem4);
final TransitionFadeBlack transition3And4 = mVideoEditorHelper.createTFadeBlack("transition3And4", mediaImageItem3, mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR);
mVideoEditor.addTransition(transition3And4);
assertTrue("Transition ID", transition3And4.getId().equals("transition3And4"));
assertEquals("Transtion After Media item", mediaImageItem3, transition3And4.getAfterMediaItem());
assertEquals("Transtion Before Media item", mediaVideoItem4, transition3And4.getBeforeMediaItem());
assertEquals("Transtion Duration", 5000, transition3And4.getDuration());
assertEquals("Transtion Behavior", Transition.BEHAVIOR_LINEAR, transition3And4.getBehavior());
final MediaVideoItem mediaVideoItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem5);
final TransitionFadeBlack transition4And5 = mVideoEditorHelper.createTFadeBlack("transition4And5", mediaVideoItem4, mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(transition4And5);
assertTrue("Transition ID", transition4And5.getId().equals("transition4And5"));
assertEquals("Transtion After Media item", mediaVideoItem4, transition4And5.getAfterMediaItem());
assertEquals("Transtion Before Media item", mediaVideoItem5, transition4And5.getBeforeMediaItem());
assertEquals("Transtion Duration", 8000, transition4And5.getDuration());
assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_FAST, transition4And5.getBehavior());
final MediaVideoItem mediaVideoItem6 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem6.setExtractBoundaries(0, 20000);
mVideoEditor.addMediaItem(mediaVideoItem6);
final TransitionFadeBlack transition5And6 = mVideoEditorHelper.createTFadeBlack("transition5And6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW);
mVideoEditor.addTransition(transition5And6);
assertTrue("Transition ID", transition5And6.getId().equals("transition5And6"));
assertEquals("Transtion After Media item", mediaVideoItem5, transition5And6.getAfterMediaItem());
assertEquals("Transtion Before Media item", mediaVideoItem6, transition5And6.getBeforeMediaItem());
assertEquals("Transtion Duration", 2000, transition5And6.getDuration());
assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_SLOW, transition5And6.getBehavior());
flagForException = false;
try {
mVideoEditorHelper.createTFadeBlack("transitiond6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_SPEED_UP - 1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Transition FadeBlack with Invalid behavior", flagForException);
flagForException = false;
try {
mVideoEditorHelper.createTFadeBlack("transitiond6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Transition FadeBlack with Invalid behavior", flagForException);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testMediaVideoItemGetWaveformData.
/**
* To Test the Media Video API : GetWaveFormData and
* extractAudioWaveFormData
*/
@LargeTest
public void testMediaVideoItemGetWaveformData() 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;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
mVideoEditor.addMediaItem(mediaVideoItem1);
assertNull("WaveForm data", mediaVideoItem1.getWaveformData());
final int[] progressWaveform = new int[105];
mediaVideoItem1.extractAudioWaveform(new ExtractAudioWaveformProgressListener() {
int i = 0;
public void onProgress(int progress) {
Log.i("WaveformData", "progress=" + progress);
progressWaveform[i++] = progress;
}
});
assertTrue("Progress of WaveForm data", mVideoEditorHelper.checkProgressCBValues(progressWaveform));
assertNotNull("WaveForm data", mediaVideoItem1.getWaveformData());
assertTrue("WaveForm Frame Duration", (mediaVideoItem1.getWaveformData().getFrameDuration() > 0 ? true : false));
assertTrue("WaveForm Frame Count", (mediaVideoItem1.getWaveformData().getFramesCount() > 0 ? true : false));
assertTrue("WaveForm Gain", (mediaVideoItem1.getWaveformData().getFrameGains().length > 0 ? true : false));
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testMediaVideoItemRenderingModes.
/**
* To test creation of Media Video Item with Set and Get rendering Mode
*/
@LargeTest
public void testMediaVideoItemRenderingModes() 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.setRenderingMode(MediaItem.RENDERING_MODE_CROPPING);
assertEquals("MediaVideo Item rendering Mode", MediaItem.RENDERING_MODE_CROPPING, mediaVideoItem1.getRenderingMode());
try {
mediaVideoItem1.setRenderingMode(MediaItem.RENDERING_MODE_CROPPING + 911);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Media Item Invalid rendering Mode", flagForException);
flagForException = false;
try {
mediaVideoItem1.setRenderingMode(MediaItem.RENDERING_MODE_BLACK_BORDER - 11);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Media Item Invalid rendering Mode", flagForException);
assertEquals("MediaVideo Item rendering Mode", MediaItem.RENDERING_MODE_CROPPING, mediaVideoItem1.getRenderingMode());
mediaVideoItem1.setRenderingMode(MediaItem.RENDERING_MODE_STRETCH);
assertEquals("MediaVideo Item rendering Mode", MediaItem.RENDERING_MODE_STRETCH, mediaVideoItem1.getRenderingMode());
}
Aggregations