Home | History | Annotate | Download | only in performance
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 
     18 package com.android.mediaframeworktest.performance;
     19 
     20 import java.io.BufferedWriter;
     21 import java.io.File;
     22 import java.io.FileWriter;
     23 import java.io.Writer;
     24 
     25 import android.graphics.Bitmap;
     26 import android.graphics.Rect;
     27 import android.media.videoeditor.AudioTrack;
     28 import android.media.videoeditor.EffectColor;
     29 import android.media.videoeditor.EffectKenBurns;
     30 import android.media.videoeditor.MediaImageItem;
     31 import android.media.videoeditor.MediaItem;
     32 import android.media.videoeditor.MediaProperties;
     33 import android.media.videoeditor.MediaVideoItem;
     34 import android.media.videoeditor.OverlayFrame;
     35 import android.media.videoeditor.Transition;
     36 import android.media.videoeditor.TransitionCrossfade;
     37 import android.media.videoeditor.TransitionAlpha;
     38 import android.media.videoeditor.TransitionFadeBlack;
     39 import android.media.videoeditor.TransitionSliding;
     40 import android.media.videoeditor.VideoEditor;
     41 import android.os.Environment;
     42 import android.test.ActivityInstrumentationTestCase;
     43 import android.media.videoeditor.VideoEditor.MediaProcessingProgressListener;
     44 import android.os.Environment;
     45 import android.os.SystemClock;
     46 import android.test.ActivityInstrumentationTestCase;
     47 import android.media.videoeditor.VideoEditor.ExportProgressListener;
     48 
     49 import android.util.Log;
     50 
     51 import com.android.mediaframeworktest.MediaFrameworkTest;
     52 import android.test.suitebuilder.annotation.LargeTest;
     53 import com.android.mediaframeworktest.VideoEditorHelper;
     54 
     55 /**
     56  * Junit / Instrumentation - performance measurement for media player and
     57  * recorder
     58  */
     59 public class VideoEditorPerformance extends
     60     ActivityInstrumentationTestCase<MediaFrameworkTest> {
     61 
     62     private final String TAG = "VideoEditorPerformance";
     63 
     64     private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;
     65 
     66     private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;
     67 
     68     private final String VIDEOEDITOR_OUTPUT = PROJECT_LOCATION +
     69         "VideoEditorPerformance.txt";
     70 
     71     public VideoEditorPerformance() {
     72         super("com.android.mediaframeworktest", MediaFrameworkTest.class);
     73     }
     74 
     75     private final String PROJECT_CLASS_NAME =
     76         "android.media.videoeditor.VideoEditorImpl";
     77     private VideoEditor mVideoEditor;
     78     private VideoEditorHelper mVideoEditorHelper;
     79 
     80     @Override
     81     protected void setUp() throws Exception {
     82         // setup for each test case.
     83         super.setUp();
     84         mVideoEditorHelper = new VideoEditorHelper();
     85         // Create a random String which will be used as project path, where all
     86         // project related files will be stored.
     87         final String projectPath =
     88             mVideoEditorHelper.createRandomFile(PROJECT_LOCATION);
     89         mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
     90     }
     91 
     92     @Override
     93     protected void tearDown() throws Exception {
     94         mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
     95         // Clean the directory created as project path
     96         mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
     97         System.gc();
     98         super.tearDown();
     99     }
    100 
    101     private void writeTimingInfo(String testCaseName, String[] information)
    102         throws Exception {
    103         File outFile = new File(VIDEOEDITOR_OUTPUT);
    104         Writer output = new BufferedWriter(new FileWriter(outFile, true));
    105         output.write(testCaseName + "\n\t");
    106         for (int i = 0; i < information.length; i++) {
    107             output.write(information[i]);
    108         }
    109         output.write("\n\n");
    110         output.close();
    111     }
    112 
    113     private final int NUM_OF_ITERATIONS=20;
    114 
    115     private int calculateTimeTaken(long beginTime, int numIterations)
    116         throws Exception {
    117         final long duration2 = SystemClock.uptimeMillis();
    118         final long durationToCreateMediaItem = (duration2 - beginTime);
    119         final int timeTaken1 = (int)(durationToCreateMediaItem / numIterations);
    120         return (timeTaken1);
    121     }
    122 
    123     private void createVideoItems(MediaVideoItem[] mediaVideoItem,
    124         String videoItemFileName, int renderingMode, int startTime, int endTime) throws Exception {
    125         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    126             try {
    127                 mediaVideoItem[i] = new MediaVideoItem(mVideoEditor, "m" + i,
    128                     videoItemFileName, renderingMode);
    129                 mediaVideoItem[i].setExtractBoundaries(startTime, endTime);
    130             } catch (Exception e1) {
    131                 assertTrue(
    132                     "Can not create an object of Video Item with file name = "
    133                     + videoItemFileName + "------ID:m" + i + "       Issue = "
    134                     + e1.toString(), false);
    135             }
    136         }
    137     }
    138 
    139     private void addVideoItems(MediaVideoItem[] mediaVideoItem) throws Exception {
    140         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    141             try {
    142                 mVideoEditor.addMediaItem(mediaVideoItem[i]);
    143             } catch (Exception e1) {
    144                 assertTrue(
    145                     "Can not add an object of Video Item with ID:m" + i +
    146                     "    Issue = " + e1.toString(), false);
    147             }
    148         }
    149     }
    150 
    151     private void removeVideoItems(MediaVideoItem[] mediaVideoItem) throws Exception {
    152             for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    153             try {
    154             mVideoEditor.removeMediaItem(mediaVideoItem[i].getId());
    155             } catch (Exception e1) {
    156                 assertTrue(
    157                     "Can not Remove an object of Video Item with ID:m" + i +
    158                     "    Issue = " + e1.toString(), false);
    159             }
    160         }
    161     }
    162 
    163     private void createImageItems(MediaImageItem[] mIi,
    164         String imageItemFileName, int renderingMode, int duration) throws Exception {
    165         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    166             try {
    167                 mIi[i] = new MediaImageItem(mVideoEditor, "m" + i,
    168                     imageItemFileName, duration, renderingMode);
    169             } catch (Exception e1) {
    170                 assertTrue( " Cannot create Image Item", false);
    171             }
    172         }
    173     }
    174 
    175     private void addImageItems(MediaImageItem[] mIi) throws Exception {
    176         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    177             try {
    178                 mVideoEditor.addMediaItem(mIi[i]);
    179             } catch (Exception e1) {
    180                 assertTrue("Cannot add Image item", false);
    181             }
    182         }
    183     }
    184 
    185     private void removeImageItems(MediaImageItem[] mIi) throws Exception {
    186             for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    187             try {
    188             mVideoEditor.removeMediaItem(mIi[i].getId());
    189             } catch (Exception e1) {
    190                 assertTrue("Cannot remove image item", false);
    191             }
    192         }
    193     }
    194     /**
    195      * To test the performance of adding and removing the video media item
    196      *
    197      * @throws Exception
    198      */
    199     @LargeTest
    200     public void testPerformanceAddRemoveVideoItem() throws Exception {
    201         final String videoItemFileName = INPUT_FILE_PATH +
    202             "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    203         final int videoItemStartTime = 0;
    204         final int videoItemEndTime = 5000;
    205         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    206         final String[] loggingInfo = new String[3];
    207         final MediaVideoItem[] mediaVideoItem =
    208             new MediaVideoItem[NUM_OF_ITERATIONS];
    209         int timeTaken = 0;
    210         long startTime = 0;
    211 
    212         /** Time Take for creation of Media Video Item */
    213         startTime = SystemClock.uptimeMillis();
    214         createVideoItems(mediaVideoItem, videoItemFileName, renderingMode,
    215             videoItemStartTime, videoItemEndTime);
    216 
    217         timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS);
    218         loggingInfo[0] = "Time taken to Create Media Video Item :" +
    219             timeTaken;
    220 
    221         /** Time Take for Addition of Media Video Item */
    222         startTime = SystemClock.uptimeMillis();
    223         addVideoItems(mediaVideoItem);
    224         timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS);
    225         loggingInfo[1] = "\n\tTime taken to Add  Media Video Item :"
    226             + timeTaken;
    227 
    228         /** Time Take for Removal of Media Video Item */
    229         startTime = SystemClock.uptimeMillis();
    230         removeVideoItems(mediaVideoItem);
    231         timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS);
    232         loggingInfo[2] = "\n\tTime taken to remove  Media Video Item :"
    233             + timeTaken;
    234 
    235         writeTimingInfo("testPerformanceAddRemoveVideoItem (in mSec)", loggingInfo);
    236     }
    237 
    238     /**
    239      * To test the performance of adding and removing the image media item
    240      *
    241      * @throws Exception
    242      */
    243     @LargeTest
    244     public void testPerformanceAddRemoveImageItem() throws Exception {
    245         final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    246         final int imageItemDuration = 0;
    247         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    248         final String[] loggingInfo = new String[3];
    249         final MediaImageItem[] mediaImageItem =
    250             new MediaImageItem[NUM_OF_ITERATIONS];
    251         int timeTaken = 0;
    252 
    253         long beginTime = SystemClock.uptimeMillis();
    254         createImageItems(mediaImageItem, imageItemFileName, renderingMode,
    255             imageItemDuration);
    256         timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
    257         loggingInfo[0] = "Time taken to Create  Media Image Item :" +
    258             timeTaken;
    259 
    260         beginTime = SystemClock.uptimeMillis();
    261         addImageItems(mediaImageItem);
    262         timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
    263         loggingInfo[1] = "\n\tTime taken to add  Media Image Item :" +
    264             timeTaken;
    265 
    266         beginTime = SystemClock.uptimeMillis();
    267         removeImageItems(mediaImageItem);
    268         timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
    269         loggingInfo[2] = "\n\tTime taken to remove  Media Image Item :"
    270             + timeTaken;
    271 
    272         writeTimingInfo("testPerformanceAddRemoveImageItem (in mSec)",
    273             loggingInfo);
    274     }
    275 
    276     /**
    277      * To test the performance of adding and removing the transition
    278      *
    279      * @throws Exception
    280      */
    281     @LargeTest
    282     public void testPerformanceAddRemoveTransition() throws Exception {
    283         final String videoItemFileName1 = INPUT_FILE_PATH +
    284         "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    285         final int videoItemStartTime1 = 0;
    286         final int videoItemEndTime1 = 20000;
    287         final String videoItemFileName2 = INPUT_FILE_PATH
    288             + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
    289         final int videoItemStartTime2 = 0;
    290         final int videoItemEndTime2 = 20000;
    291         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    292         final int transitionDuration = 5000;
    293         final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
    294         final String[] loggingInfo = new String[3];
    295         int timeTaken = 0;
    296 
    297         final MediaVideoItem[] mediaVideoItem =
    298             new MediaVideoItem[(NUM_OF_ITERATIONS *10) + 1];
    299 
    300         for (int i = 0; i < (NUM_OF_ITERATIONS *10); i+=2) {
    301             try {
    302                 mediaVideoItem[i] = new MediaVideoItem(mVideoEditor, "m" + i,
    303                     videoItemFileName1, renderingMode);
    304                 mediaVideoItem[i+1] = new MediaVideoItem(mVideoEditor,
    305                     "m" + (i+1), videoItemFileName2, renderingMode);
    306                 mediaVideoItem[i].setExtractBoundaries(videoItemStartTime1,
    307                     videoItemEndTime1);
    308                 mediaVideoItem[i+1].setExtractBoundaries(videoItemStartTime2,
    309                     videoItemEndTime2);
    310             } catch (Exception e1) {
    311                 assertTrue("Can not create Video Object Item with file name = "
    312                     + e1.toString(), false);
    313             }
    314             mVideoEditor.addMediaItem(mediaVideoItem[i]);
    315             mVideoEditor.addMediaItem(mediaVideoItem[i+1]);
    316         }
    317         mediaVideoItem[(NUM_OF_ITERATIONS *10)] = new MediaVideoItem(mVideoEditor,
    318             "m" + (NUM_OF_ITERATIONS *10), videoItemFileName1, renderingMode);
    319         mediaVideoItem[(NUM_OF_ITERATIONS *10)].setExtractBoundaries(
    320             videoItemStartTime1, videoItemEndTime1);
    321         mVideoEditor.addMediaItem(mediaVideoItem[(NUM_OF_ITERATIONS *10)]);
    322         final TransitionCrossfade tranCrossfade[] =
    323             new TransitionCrossfade[(NUM_OF_ITERATIONS *10)];
    324 
    325         long beginTime = SystemClock.uptimeMillis();
    326         for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) {
    327             tranCrossfade[i] = new TransitionCrossfade("transition" + i,
    328                 mediaVideoItem[i], mediaVideoItem[i+1], transitionDuration,
    329                 transitionBehavior);
    330         }
    331         timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
    332         loggingInfo[0] = "Time taken to Create CrossFade Transition :" +
    333             timeTaken;
    334 
    335         beginTime = SystemClock.uptimeMillis();
    336         for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) {
    337             mVideoEditor.addTransition(tranCrossfade[i]);
    338         }
    339         timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
    340         loggingInfo[1] = "\n\tTime taken to add CrossFade Transition :" +
    341             timeTaken;
    342 
    343         beginTime = SystemClock.uptimeMillis();
    344         for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) {
    345             assertEquals("Removing Transitions", tranCrossfade[i], mVideoEditor
    346                 .removeTransition(tranCrossfade[i].getId()));
    347         }
    348         timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
    349         loggingInfo[2] = "\n\tTime taken to remove CrossFade Transition :" +
    350             timeTaken;
    351 
    352         writeTimingInfo("testPerformanceAddRemoveTransition (in mSec)", loggingInfo);
    353     }
    354 
    355     /**
    356      * To test performance of Export
    357      *
    358      * @throws Exception
    359      */
    360     @LargeTest
    361     public void testPerformanceExport() throws Exception {
    362         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    363         final int outHeight = MediaProperties.HEIGHT_480;
    364         final int outBitrate = MediaProperties.BITRATE_256K;
    365         final int outVcodec = MediaProperties.VCODEC_H264;
    366         final String[] loggingInfo = new String[1];
    367         final String outFilename = mVideoEditorHelper
    368             .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
    369         final String videoItemFileName1 = INPUT_FILE_PATH +
    370             "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4";
    371         final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    372         final String videoItemFileName2 = INPUT_FILE_PATH +
    373             "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_32kbps_m_1_17.3gp";
    374         final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
    375         final String videoItemFileName3 = INPUT_FILE_PATH +
    376             "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
    377         final String overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    378         final String audioTrackFilename = INPUT_FILE_PATH +
    379             "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
    380         final String maskFilename = INPUT_FILE_PATH +
    381             "TransitionSpiral_QVGA.jpg";
    382 
    383         final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor,
    384             "m1", videoItemFileName1, renderingMode);
    385         mediaItem1.setExtractBoundaries(0, 20000);
    386         mVideoEditor.addMediaItem(mediaItem1);
    387 
    388         final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor,
    389             "m2", imageItemFileName1, 10000, renderingMode);
    390         mVideoEditor.addMediaItem(mediaItem2);
    391 
    392         final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor,
    393             "m3", videoItemFileName2, renderingMode);
    394         mediaItem3.setExtractBoundaries(0, 20000);
    395         mVideoEditor.addMediaItem(mediaItem3);
    396 
    397         final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor,
    398             "m4", imageItemFileName2, 10000, renderingMode);
    399         mVideoEditor.addMediaItem(mediaItem4);
    400 
    401         final MediaVideoItem mediaItem5 = new MediaVideoItem(mVideoEditor,
    402             "m5", videoItemFileName3, renderingMode);
    403         mediaItem5.setExtractBoundaries(0, 20000);
    404         mVideoEditor.addMediaItem(mediaItem5);
    405         /**
    406          * 7.Add TransitionAlpha, Apply this  Transition as Begin for Media Item 1
    407          *  with duration = 2 sec behavior = BEHAVIOR_LINEAR, mask file name =
    408          * TransitionSpiral_QVGA.jpg , blending percent = 50%, invert = true;
    409          * */
    410         final TransitionAlpha transition1 =
    411             mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1,
    412                 2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
    413         mVideoEditor.addTransition(transition1);
    414 
    415         /**
    416          * 8.Add Transition Sliding between MediaItem 2 and 3 ,
    417          *  Sliding Direction  = DIRECTION_RIGHT_OUT_LEFT_IN,
    418          *  behavior  = BEHAVIOR_MIDDLE_FAST and duration = 4sec
    419          * */
    420         final TransitionSliding transition2And3 =
    421             mVideoEditorHelper.createTSliding("transition2", mediaItem2,
    422                 mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST,
    423                 TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
    424         mVideoEditor.addTransition(transition2And3);
    425 
    426         /**
    427          * 9.Add Transition Crossfade between  Media Item 3 and 4,
    428          *  behavior = BEHAVIOR_MIDDLE_SLOW, duration = 3.5 sec
    429          * */
    430         final TransitionCrossfade transition3And4 =
    431             mVideoEditorHelper.createTCrossFade("transition3", mediaItem3,
    432                 mediaItem4, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
    433         mVideoEditor.addTransition(transition3And4);
    434 
    435         /**
    436          * 10.Add Transition Fadeblack between  Media Item 4 and 5,
    437          *  behavior = BEHAVIOR_SPEED_DOWN, duration = 3.5 sec
    438          * */
    439         final TransitionFadeBlack transition4And5 =
    440             mVideoEditorHelper.createTFadeBlack("transition4", mediaItem4,
    441                 mediaItem5, 3500, Transition.BEHAVIOR_SPEED_DOWN);
    442         mVideoEditor.addTransition(transition4And5);
    443 
    444         /**
    445          * 11.Add Effect 1 type="TYPE_SEPIA" to the MediaItem 1,
    446          *  start time=1sec and duration =4secs
    447          * */
    448         final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(
    449             mediaItem1, "effect1", 1000, 4000, EffectColor.TYPE_SEPIA, 0);
    450         mediaItem1.addEffect(effectColor1);
    451 
    452         /**
    453          * 12.Add Overlay 1  to the MediaItem 3: Frame Overlay with start time = 1 sec
    454          * duration = 4 sec with item  = IMG_640x480_Overlay1.png
    455          * */
    456         final Bitmap mBitmap =  mVideoEditorHelper.getBitmap(overlayFile, 640,
    457             480);
    458         final OverlayFrame overlayFrame =
    459             mVideoEditorHelper.createOverlay(mediaItem3, "overlay",
    460                 mBitmap, 1000, 4000);
    461         mediaItem3.addOverlay(overlayFrame);
    462         /**
    463          * 13.Add Effect 2 type="TYPE_NEGATIVE" to the MediaItem 2,
    464          *  start time=8sec and duration =2secs
    465          * */
    466         final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem(
    467             mediaItem2, "effect2", 8000, 2000, EffectColor.TYPE_NEGATIVE, 0);
    468         mediaItem2.addEffect(effectColor2);
    469         /**
    470          * 14.Add Effect 3 type="TYPE_COLOR" to the MediaItem 3, color param = "PINK",
    471          *  start time=5 sec and duration =3secs
    472          * */
    473         final EffectColor effectColor3 = mVideoEditorHelper.createEffectItem(
    474             mediaItem3, "effect3", 5000, 3000, EffectColor.TYPE_COLOR,
    475             EffectColor.PINK);
    476         mediaItem3.addEffect(effectColor3);
    477         /**
    478          * 15.Add Effect 4 type="TYPE_FIFTIES" to the MediaItem 4,
    479          *  start time=2 sec and duration =1secs
    480         * */
    481         final EffectColor effectColor4 = mVideoEditorHelper.createEffectItem(
    482             mediaItem4, "effect4", 2000, 1000, EffectColor.TYPE_FIFTIES, 0);
    483         mediaItem4.addEffect(effectColor4);
    484         /**
    485          * 16.Add KenBurnsEffect for MediaItem 4 with
    486          *  duration = 3 sec and startTime = 4 sec
    487          *  StartRect
    488          *  left = org_height/3  ;  top = org_width/3
    489          *  bottom = org_width/2  ;  right = org_height/2
    490          *  EndRect
    491          *  left = 0  ;  top = 0
    492          *  bottom =  org_height;  right =  org_width
    493          * */
    494 
    495         final Rect startRect = new Rect((mediaItem4.getHeight() / 3),
    496             (mediaItem4.getWidth() / 3), (mediaItem4.getHeight() / 2),
    497             (mediaItem4.getWidth() / 2));
    498         final Rect endRect = new Rect(0, 0, mediaItem4.getWidth(),
    499             mediaItem4.getHeight());
    500         final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(
    501             mediaItem4, "KBOnM2", startRect, endRect,4000 , 3000);
    502         mediaItem4.addEffect(kbEffectOnMediaItem);
    503 
    504         /** 17.Add Audio Track,Set extract boundaries o to 10 sec.
    505          * */
    506         final AudioTrack audioTrack = mVideoEditorHelper.createAudio(
    507             mVideoEditor, "audioTrack", audioTrackFilename);
    508         mVideoEditor.addAudioTrack(audioTrack);
    509         /** 18.Enable Looping for Audio Track.
    510          * */
    511         audioTrack.enableLoop();
    512         int timeTaken = 0;
    513         final long beginTime = SystemClock.uptimeMillis();
    514             try {
    515                 mVideoEditor.export(outFilename, outHeight, outBitrate,
    516                     new ExportProgressListener() {
    517                         public void onProgress(VideoEditor ve,
    518                             String outFileName, int progress) {
    519                         }
    520                     });
    521             } catch (Exception e) {
    522                 assertTrue("Error in Export" + e.toString(), false);
    523             }
    524         mVideoEditorHelper.checkDeleteExistingFile(outFilename);
    525 
    526         timeTaken = calculateTimeTaken(beginTime, 1);
    527         loggingInfo[0] = "Time taken to do ONE export of storyboard duration "
    528             + mVideoEditor.getDuration() + " is :" + timeTaken;
    529 
    530         writeTimingInfo("testPerformanceExport (in mSec)", loggingInfo);
    531         mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
    532     }
    533 
    534 
    535     /**
    536      * To test the performance of thumbnail extraction
    537      *
    538      * @throws Exception
    539      */
    540     @LargeTest
    541     public void testPerformanceThumbnailVideoItem() throws Exception {
    542         final String videoItemFileName = INPUT_FILE_PATH
    543             + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
    544         final int videoItemStartTime = 0;
    545         final int videoItemEndTime = 20000;
    546         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    547         final String[] loggingInfo = new String[1];
    548 
    549         final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
    550             "m1", videoItemFileName, renderingMode);
    551         mediaVideoItem.setExtractBoundaries(videoItemStartTime,
    552             videoItemEndTime);
    553 
    554         int timeTaken = 0;
    555         long beginTime = SystemClock.uptimeMillis();
    556         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    557             mediaVideoItem.getThumbnail(mediaVideoItem.getWidth() / 2,
    558                 mediaVideoItem.getHeight() / 2, i);
    559         }
    560         timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
    561         loggingInfo[0] = "Duration taken to get Video Thumbnails :" +
    562             timeTaken;
    563 
    564         writeTimingInfo("testPerformanceThumbnailVideoItem (in mSec)", loggingInfo);
    565     }
    566 
    567     /**
    568      * To test the performance of adding and removing the overlay to media item
    569      *
    570      * @throws Exception
    571      */
    572     @LargeTest
    573     public void testPerformanceOverlayVideoItem() throws Exception {
    574         final String videoItemFileName1 = INPUT_FILE_PATH +
    575             "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
    576         final int videoItemStartTime1 = 0;
    577         final int videoItemEndTime1 = 10000;
    578         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    579         final String overlayFilename = INPUT_FILE_PATH
    580             + "IMG_640x480_Overlay1.png";
    581         final int overlayStartTime = 1000;
    582         final int overlayDuration = 5000;
    583 
    584         final String[] loggingInfo = new String[2];
    585         MediaVideoItem mediaVideoItem = null;
    586 
    587         try {
    588             mediaVideoItem = new MediaVideoItem(mVideoEditor, "m0",
    589                 videoItemFileName1, renderingMode);
    590             mediaVideoItem.setExtractBoundaries(videoItemStartTime1,
    591                 videoItemEndTime1);
    592         } catch (Exception e1) {
    593             assertTrue("Can not create Video Item with file name = "
    594                 + e1.toString(), false);
    595         }
    596         final OverlayFrame overlayFrame[] = new OverlayFrame[NUM_OF_ITERATIONS];
    597         final Bitmap mBitmap =  mVideoEditorHelper.getBitmap(overlayFilename,
    598             640, 480);
    599         int timeTaken = 0;
    600         long beginTime = SystemClock.uptimeMillis();
    601         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    602             overlayFrame[i] = new OverlayFrame(mediaVideoItem, "overlay" + i,
    603             mBitmap, overlayStartTime, overlayDuration);
    604             mediaVideoItem.addOverlay(overlayFrame[i]);
    605         }
    606         timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
    607         loggingInfo[0] = "Time taken to add & create Overlay :" + timeTaken;
    608 
    609         beginTime = SystemClock.uptimeMillis();
    610         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    611             assertEquals("Removing Overlays", overlayFrame[i],
    612                 mediaVideoItem.removeOverlay((overlayFrame[i].getId())));
    613         }
    614         timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
    615         loggingInfo[1] = "\n\tTime taken to remove  Overlay :" +
    616             timeTaken;
    617 
    618         writeTimingInfo("testPerformanceOverlayVideoItem (in mSec)", loggingInfo);
    619     }
    620 
    621     /**
    622      * To test the performance of get properties of a Video media item
    623      *
    624      * @throws Exception
    625      */
    626     @LargeTest
    627     public void testPerformanceVideoItemProperties() throws Exception {
    628         final String videoItemFileName1 = INPUT_FILE_PATH +
    629             "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    630         final int videoItemStartTime1 = 0;
    631         final int videoItemEndTime1 = 10100;
    632         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    633         final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
    634         final int fileType = MediaProperties.FILE_MP4;
    635         final int videoCodecType = MediaProperties.VCODEC_H264;
    636         final int duration = 77366;
    637         final int videoBitrate = 3169971;
    638         final int fps = 30;
    639         final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
    640         final int videoLevel = MediaProperties.H264Level.H264Level13;
    641         final int width = 1080;
    642         final int height = MediaProperties.HEIGHT_720;
    643         int timeTaken = 0;
    644         final String[] loggingInfo = new String[1];
    645         final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
    646             "m0", videoItemFileName1, renderingMode);
    647         mediaVideoItem.setExtractBoundaries(videoItemStartTime1,
    648             videoItemEndTime1);
    649         long beginTime = SystemClock.uptimeMillis();
    650         for (int i = 0; i < (NUM_OF_ITERATIONS*10); i++) {
    651             try {
    652                 assertEquals("Aspect Ratio Mismatch",
    653                     aspectRatio, mediaVideoItem.getAspectRatio());
    654                 assertEquals("File Type Mismatch",
    655                     fileType, mediaVideoItem.getFileType());
    656                 assertEquals("VideoCodec Mismatch",
    657                     videoCodecType, mediaVideoItem.getVideoType());
    658                 assertEquals("duration Mismatch",
    659                     duration, mediaVideoItem.getDuration());
    660                 assertEquals("Video Profile ",
    661                     videoProfile, mediaVideoItem.getVideoProfile());
    662                 assertEquals("Video Level ",
    663                     videoLevel, mediaVideoItem.getVideoLevel());
    664                 assertEquals("Video height ",
    665                     height, mediaVideoItem.getHeight());
    666                 assertEquals("Video width ",
    667                     width, mediaVideoItem.getWidth());
    668             } catch (Exception e1) {
    669                 assertTrue("Can not create Video Item with file name = "
    670                     + e1.toString(), false);
    671             }
    672         }
    673         timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS*10));
    674         loggingInfo[0] = "Time taken to get Media Properties :"
    675             + timeTaken;
    676         writeTimingInfo("testPerformanceVideoItemProperties:", loggingInfo);
    677     }
    678 
    679     /**
    680      * To test the performance of generatePreview : with Transitions
    681      *
    682      * @throws Exception
    683      */
    684     @LargeTest
    685     public void testPerformanceGeneratePreviewWithTransitions()
    686         throws Exception {
    687         final String videoItemFileName = INPUT_FILE_PATH +
    688             "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    689         final String imageItemFileName = INPUT_FILE_PATH +
    690             "IMG_1600x1200.jpg";
    691         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    692         final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
    693         long averageTime = 0;
    694         final String[] loggingInfo = new String[1];
    695 
    696         final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
    697             "mediaItem1", videoItemFileName, renderingMode);
    698         mediaVideoItem.setExtractBoundaries(0, 10000);
    699         mVideoEditor.addMediaItem(mediaVideoItem);
    700 
    701         final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor,
    702             "mediaItem2", imageItemFileName, 10000, renderingMode);
    703         mVideoEditor.addMediaItem(mediaImageItem);
    704 
    705         final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
    706             "transitionCrossFade", mediaVideoItem, mediaImageItem,
    707             5000, transitionBehavior);
    708         mVideoEditor.addTransition(transitionCrossFade);
    709 
    710         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    711             final long duration1 = SystemClock.uptimeMillis();
    712             mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
    713                 public void onProgress(Object item, int action, int progress) {
    714                 }
    715             });
    716             final long duration2 = SystemClock.uptimeMillis();
    717             mVideoEditor.removeTransition(transitionCrossFade.getId());
    718             mVideoEditor.addTransition(transitionCrossFade);
    719             averageTime += (duration2 - duration1);
    720         }
    721         final long durationToAddObjects = averageTime;
    722         final float timeTaken = (float)durationToAddObjects *
    723             1.0f/(float)NUM_OF_ITERATIONS;
    724         loggingInfo[0] = "Time taken to Generate Preview with transition :"
    725             + timeTaken;
    726         writeTimingInfo("testPerformanceGeneratePreviewWithTransitions:",
    727             loggingInfo);
    728     }
    729 
    730     /**
    731      * To test the performance of generatePreview : with KenBurn
    732      *
    733      * @throws Exception
    734      */
    735     @LargeTest
    736     public void testPerformanceWithKenBurn() throws Exception {
    737         final String videoItemFileName = INPUT_FILE_PATH +
    738             "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    739         final String imageItemFileName = INPUT_FILE_PATH +
    740             "IMG_1600x1200.jpg";
    741         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    742         long averageTime = 0;
    743         final String[] loggingInfo = new String[1];
    744         final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
    745             "mediaItem1", videoItemFileName, renderingMode);
    746         mediaVideoItem.setExtractBoundaries(0, 10000);
    747         mVideoEditor.addMediaItem(mediaVideoItem);
    748 
    749         final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor,
    750             "mediaItem2", imageItemFileName, 10000, renderingMode);
    751         mVideoEditor.addMediaItem(mediaImageItem);
    752 
    753         final Rect startRect = new Rect((mediaImageItem.getHeight() / 3),
    754             (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2),
    755             (mediaImageItem.getWidth() / 2));
    756         final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(),
    757             mediaImageItem.getHeight());
    758         final EffectKenBurns kbEffectOnMediaItem =
    759             new EffectKenBurns(mediaImageItem, "KBOnM2", startRect, endRect,
    760                 500, 3000);
    761         mediaImageItem.addEffect(kbEffectOnMediaItem);
    762 
    763         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    764             final long duration1 = SystemClock.uptimeMillis();
    765             mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
    766                 public void onProgress(Object item, int action, int progress) {
    767                 }
    768             });
    769             final long duration2 = SystemClock.uptimeMillis();
    770             mediaImageItem.removeEffect(kbEffectOnMediaItem.getId());
    771             mediaImageItem.addEffect(kbEffectOnMediaItem);
    772             averageTime += duration2 - duration1;
    773         }
    774 
    775         final long durationToAddObjects = (averageTime);
    776         final float timeTaken = (float)durationToAddObjects *
    777             1.0f/(float)NUM_OF_ITERATIONS;
    778         loggingInfo[0] = "Time taken to Generate KenBurn Effect :"
    779             + timeTaken;
    780         writeTimingInfo("testPerformanceWithKenBurn", loggingInfo);
    781     }
    782 
    783     /**
    784      * To test the performance of generatePreview : with Transitions and
    785      * Effect,Overlapping scenario
    786      *
    787      * @throws Exception
    788      */
    789     @LargeTest
    790     public void testPerformanceEffectOverlappingTransition() throws Exception {
    791         final String videoItemFileName1 = INPUT_FILE_PATH +
    792             "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    793         final String videoItemFileName2 = INPUT_FILE_PATH
    794             + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
    795         final int videoStartTime1 = 0;
    796         final int videoEndTime1 = 10000;
    797         final int videoStartTime2 = 0;
    798         final int videoEndTime2 = 10000;
    799         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    800         final int transitionDuration = 5000;
    801         final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
    802         final int effectItemStartTime = 5000;
    803         final int effectItemDurationTime = 5000;
    804         final int effectType = EffectColor.TYPE_COLOR;
    805         final int effectColorType = EffectColor.GREEN;
    806         long averageDuration = 0;
    807 
    808         final String[] loggingInfo = new String[1];
    809         final MediaVideoItem mediaVideoItem1 = new MediaVideoItem(mVideoEditor,
    810             "mediaItem1", videoItemFileName1, renderingMode);
    811         mediaVideoItem1.setExtractBoundaries(videoStartTime1, videoEndTime1);
    812         mVideoEditor.addMediaItem(mediaVideoItem1);
    813 
    814         final MediaVideoItem mediaVideoItem2 = new MediaVideoItem(mVideoEditor,
    815             "mediaItem2", videoItemFileName2, renderingMode);
    816         mediaVideoItem2.setExtractBoundaries(videoStartTime2, videoEndTime2);
    817         mVideoEditor.addMediaItem(mediaVideoItem2);
    818 
    819         final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
    820             "transitionCrossFade", mediaVideoItem1, mediaVideoItem2,
    821             transitionDuration, transitionBehavior);
    822         mVideoEditor.addTransition(transitionCrossFade);
    823 
    824         final EffectColor effectColor = new EffectColor(mediaVideoItem1,
    825             "effect", effectItemStartTime, effectItemDurationTime, effectType,
    826              effectColorType);
    827         mediaVideoItem1.addEffect(effectColor);
    828 
    829         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    830             final long duration1 = SystemClock.uptimeMillis();
    831             mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
    832                 public void onProgress(Object item, int action, int progress) {
    833                 }
    834             });
    835             final long duration2 = SystemClock.uptimeMillis();
    836             mVideoEditor.removeTransition(transitionCrossFade.getId());
    837             mVideoEditor.addTransition(transitionCrossFade);
    838             averageDuration += (duration2 - duration1);
    839         }
    840         SystemClock.uptimeMillis();
    841         final long durationToAddObjects = (averageDuration);
    842         final float timeTaken = (float)durationToAddObjects *
    843             1.0f/(float)NUM_OF_ITERATIONS;
    844         loggingInfo[0] =
    845             "Time taken to testPerformanceEffectOverlappingTransition :"
    846             + timeTaken;
    847         writeTimingInfo("testPerformanceEffectOverlappingTransition:",
    848             loggingInfo);
    849     }
    850 
    851     /**
    852      * To test creation of story board with Transition and Two Effects, Effect
    853      * overlapping transitions
    854      *
    855      * @throws Exception
    856      */
    857     @LargeTest
    858     public void testPerformanceTransitionWithEffectOverlapping() throws Exception {
    859         final String videoItemFileName1 = INPUT_FILE_PATH +
    860             "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    861         final String videoItemFileName2 = INPUT_FILE_PATH
    862             + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
    863         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    864         final int transitionDuration = 5000;
    865         final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
    866         final int effectItemStartTime1 = 5000;
    867         final int effectItemDurationTime1 = 5000;
    868         final int effectType1 = EffectColor.TYPE_COLOR;
    869         final int effectColorType1 = EffectColor.GREEN;
    870         final int effectItemStartTime2 = 5000;
    871         final int effectItemDurationTime2 = 5000;
    872         final int effectType2 = EffectColor.TYPE_COLOR;
    873         final int effectColorType2 = EffectColor.GREEN;
    874         int averageTime = 0;
    875         final String[] loggingInfo = new String[1];
    876 
    877         final MediaVideoItem mediaVideoItem1 = new MediaVideoItem(mVideoEditor,
    878             "mediaItem1", videoItemFileName1, renderingMode);
    879         mVideoEditor.addMediaItem(mediaVideoItem1);
    880 
    881         final MediaVideoItem mediaVideoItem2 = new MediaVideoItem(mVideoEditor,
    882             "mediaItem2", videoItemFileName2, renderingMode);
    883         mVideoEditor.addMediaItem(mediaVideoItem2);
    884 
    885         final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
    886             "transitionCrossFade", mediaVideoItem1, mediaVideoItem2,
    887             transitionDuration, transitionBehavior);
    888         mVideoEditor.addTransition(transitionCrossFade);
    889 
    890         final EffectColor effectColor1 = new EffectColor(mediaVideoItem1,
    891             "effect1", effectItemStartTime1, effectItemDurationTime1,
    892             effectType1, effectColorType1);
    893         mediaVideoItem1.addEffect(effectColor1);
    894 
    895         final EffectColor effectColor2 = new EffectColor(mediaVideoItem2,
    896             "effect2", effectItemStartTime2, effectItemDurationTime2,
    897             effectType2, effectColorType2);
    898         mediaVideoItem2.addEffect(effectColor2);
    899 
    900         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    901             final long duration1 = SystemClock.uptimeMillis();
    902             mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
    903                 public void onProgress(Object item, int action, int progress) {
    904                 }
    905             });
    906             final long duration2 = SystemClock.uptimeMillis();
    907             mVideoEditor.removeTransition(transitionCrossFade.getId());
    908             mVideoEditor.addTransition(transitionCrossFade);
    909             averageTime += duration2 - duration1;
    910         }
    911         final long durationToAddObjects = (averageTime);
    912         final float timeTaken = (float)durationToAddObjects *
    913             1.0f/(float)NUM_OF_ITERATIONS;
    914         loggingInfo[0] = "Time taken to TransitionWithEffectOverlapping :"
    915             + timeTaken;
    916         writeTimingInfo("testPerformanceTransitionWithEffectOverlapping",
    917             loggingInfo);
    918     }
    919 
    920     /**
    921      *To test ThumbnailList for H264
    922      */
    923     @LargeTest
    924     public void testThumbnailH264NonIFrame() throws Exception {
    925         final String videoItemFilename = INPUT_FILE_PATH +
    926             "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    927         final int outWidth = 1080;
    928         final int outHeight = 720;
    929         final int atTime = 2400;
    930         long durationToAddObjects = 0;
    931         int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    932         final String[] loggingInfo = new String[1];
    933         final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
    934             "m1", videoItemFilename, renderingMode);
    935         assertNotNull("MediaVideoItem", mediaVideoItem);
    936 
    937         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    938             final long duration1 = SystemClock.uptimeMillis();
    939             mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i);
    940             final long duration2 = SystemClock.uptimeMillis();
    941             durationToAddObjects += (duration2 - duration1);
    942         }
    943         final float timeTaken = (float)durationToAddObjects *
    944             1.0f/(float)NUM_OF_ITERATIONS;
    945         loggingInfo[0] = "Time taken for Thumbnail generation :"
    946             + timeTaken;
    947         writeTimingInfo("testThumbnailH264NonIFrame", loggingInfo);
    948     }
    949 
    950     /**
    951      *To test ThumbnailList for H264
    952      */
    953     @LargeTest
    954     public void testThumbnailH264AnIFrame() throws Exception {
    955         final String videoItemFilename = INPUT_FILE_PATH +
    956             "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    957         final int outWidth = 1080;
    958         final int outHeight = 720;
    959         final int atTime = 3000;
    960         int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    961         final String[] loggingInfo = new String[1];
    962         long durationToAddObjects = 0;
    963 
    964         final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
    965             "m1", videoItemFilename, renderingMode);
    966         assertNotNull("MediaVideoItem", mediaVideoItem);
    967 
    968         for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    969             final long duration1 = SystemClock.uptimeMillis();
    970             mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i);
    971             final long duration2 = SystemClock.uptimeMillis();
    972             durationToAddObjects += (duration2 - duration1);
    973         }
    974         final float timeTaken = (float)durationToAddObjects *
    975             1.0f/(float)NUM_OF_ITERATIONS;
    976         loggingInfo[0] = "Time taken Thumbnail generation :"
    977             + timeTaken;
    978         writeTimingInfo("testThumbnailH264AnIFrame", loggingInfo);
    979     }
    980 
    981     /**
    982      * To test the performance : With an audio track
    983      *
    984      * @throws Exception
    985      */
    986     @LargeTest
    987     public void testPerformanceWithAudioTrack() throws Exception {
    988         final String videoItemFileName1 = INPUT_FILE_PATH +
    989             "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    990         final String audioFilename1 = INPUT_FILE_PATH +
    991             "AACLC_44.1kHz_256kbps_s_1_17.mp4";
    992         final String audioFilename2 = INPUT_FILE_PATH +
    993             "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
    994         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    995         final int audioVolume = 50;
    996         final String[] loggingInfo = new String[2];
    997         int timeTaken = 0;
    998 
    999         final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
   1000             "mediaItem1", videoItemFileName1, renderingMode);
   1001         mVideoEditor.addMediaItem(mediaVideoItem);
   1002 
   1003         final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor,
   1004             "Audio Track1", audioFilename1);
   1005         audioTrack1.disableDucking();
   1006         audioTrack1.setVolume(audioVolume);
   1007         mVideoEditor.addAudioTrack(audioTrack1);
   1008 
   1009         long beginTime = SystemClock.uptimeMillis();
   1010         mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
   1011             public void onProgress(Object item, int action, int progress) {
   1012             }
   1013         });
   1014         timeTaken = calculateTimeTaken(beginTime, 1);
   1015         loggingInfo[0] = "Time taken for 1st Audio Track (AACLC) :"
   1016             + timeTaken;
   1017 
   1018         final AudioTrack audioTrack2 = new AudioTrack(mVideoEditor,
   1019             "Audio Track2", audioFilename2);
   1020         audioTrack2.enableLoop();
   1021 
   1022         beginTime = SystemClock.uptimeMillis();
   1023         mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
   1024             public void onProgress(Object item, int action, int progress) {
   1025             }
   1026         });
   1027         timeTaken = calculateTimeTaken(beginTime, 1);
   1028         loggingInfo[1] = "\n\tTime taken for 2nd Audio Track(AMRNB) :"
   1029             + timeTaken;
   1030 
   1031         writeTimingInfo("testPerformanceWithAudioTrack", loggingInfo);
   1032     }
   1033 
   1034     /**
   1035      * To test the performance of adding and removing the
   1036      * image media item with 640 x 480
   1037      *
   1038      * @throws Exception
   1039      */
   1040     @LargeTest
   1041     public void testPerformanceAddRemoveImageItem640x480() throws Exception {
   1042         final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
   1043         final int imageItemDuration = 0;
   1044         final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
   1045         final String[] loggingInfo = new String[3];
   1046 
   1047         int timeTaken = 0;
   1048 
   1049         final MediaImageItem[] mediaImageItem =
   1050             new MediaImageItem[NUM_OF_ITERATIONS];
   1051         long beginTime = SystemClock.uptimeMillis();
   1052         createImageItems(mediaImageItem, imageItemFileName, renderingMode,
   1053             imageItemDuration);
   1054         timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
   1055         loggingInfo[0] = "Time taken to Create  Media Image Item (640x480) :"
   1056             + timeTaken;
   1057 
   1058         beginTime = SystemClock.uptimeMillis();
   1059         addImageItems(mediaImageItem);
   1060         timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
   1061         loggingInfo[1] = "\n\tTime taken to add  Media Image Item (640x480) :"
   1062             + timeTaken;
   1063 
   1064         beginTime = SystemClock.uptimeMillis();
   1065         removeImageItems(mediaImageItem);
   1066         timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
   1067         loggingInfo[2] = "\n\tTime taken to remove  Media Image Item (640x480) :"
   1068             + timeTaken;
   1069         writeTimingInfo("testPerformanceAddRemoveImageItem640x480 (in mSec)", loggingInfo);
   1070     }
   1071 
   1072 
   1073 }
   1074