summaryrefslogtreecommitdiffstats
path: root/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java
blob: 4481d0004156e594c7919ef72b9af55cea47f15f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package com.android.mediaframeworktest.performance;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.Writer;

import android.graphics.Bitmap;
import android.graphics.Rect;
import android.media.videoeditor.AudioTrack;
import android.media.videoeditor.EffectColor;
import android.media.videoeditor.EffectKenBurns;
import android.media.videoeditor.MediaImageItem;
import android.media.videoeditor.MediaItem;
import android.media.videoeditor.MediaProperties;
import android.media.videoeditor.MediaVideoItem;
import android.media.videoeditor.OverlayFrame;
import android.media.videoeditor.Transition;
import android.media.videoeditor.TransitionCrossfade;
import android.media.videoeditor.TransitionAlpha;
import android.media.videoeditor.TransitionFadeBlack;
import android.media.videoeditor.TransitionSliding;
import android.media.videoeditor.VideoEditor;
import android.os.Environment;
import android.test.ActivityInstrumentationTestCase;
import android.media.videoeditor.VideoEditor.MediaProcessingProgressListener;
import android.os.Environment;
import android.os.SystemClock;
import android.test.ActivityInstrumentationTestCase;
import android.media.videoeditor.VideoEditor.ExportProgressListener;

import android.util.Log;

import com.android.mediaframeworktest.MediaFrameworkTest;
import android.test.suitebuilder.annotation.LargeTest;
import com.android.mediaframeworktest.VideoEditorHelper;

/**
 * Junit / Instrumentation - performance measurement for media player and
 * recorder
 */
public class VideoEditorPerformance extends
    ActivityInstrumentationTestCase<MediaFrameworkTest> {

    private final String TAG = "VideoEditorPerformance";

    private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;

    private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;

    private final String VIDEOEDITOR_OUTPUT = PROJECT_LOCATION +
        "VideoEditorPerformance.txt";

    public VideoEditorPerformance() {
        super("com.android.mediaframeworktest", MediaFrameworkTest.class);
    }

    private final String PROJECT_CLASS_NAME =
        "android.media.videoeditor.VideoEditorImpl";
    private VideoEditor mVideoEditor;
    private VideoEditorHelper mVideoEditorHelper;

    @Override
    protected void setUp() throws Exception {
        // setup for each test case.
        super.setUp();
        mVideoEditorHelper = new VideoEditorHelper();
        // Create a random String which will be used as project path, where all
        // project related files will be stored.
        final String projectPath =
            mVideoEditorHelper.createRandomFile(PROJECT_LOCATION);
        mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
    }

    @Override
    protected void tearDown() throws Exception {
        mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
        // Clean the directory created as project path
        mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
        System.gc();
        super.tearDown();
    }

    private void writeTimingInfo(String testCaseName, String[] information)
        throws Exception {
        File outFile = new File(VIDEOEDITOR_OUTPUT);
        Writer output = new BufferedWriter(new FileWriter(outFile, true));
        output.write(testCaseName + "\n\t");
        for (int i = 0; i < information.length; i++) {
            output.write(information[i]);
        }
        output.write("\n\n");
        output.close();
    }

    private final int NUM_OF_ITERATIONS=20;

    private float calculateTimeTaken(long beginTime, int numIterations)
        throws Exception {
        final long duration2 = SystemClock.uptimeMillis();
        final long durationToCreateMediaItem = (duration2 - beginTime);
        final float timeTaken1 = (float)durationToCreateMediaItem *
            1.0f/(float)numIterations;
        return (timeTaken1);
    }

    private void createVideoItems(MediaVideoItem[] mediaVideoItem,
        String videoItemFileName, int renderingMode, int startTime, int endTime) throws Exception {
        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            try {
                mediaVideoItem[i] = new MediaVideoItem(mVideoEditor, "m" + i,
                    videoItemFileName, renderingMode);
                mediaVideoItem[i].setExtractBoundaries(startTime, endTime);
            } catch (Exception e1) {
                assertTrue(
                    "Can not create an object of Video Item with file name = "
                    + videoItemFileName + "------ID:m" + i + "       Issue = "
                    + e1.toString(), false);
            }
        }
    }

    private void addVideoItems(MediaVideoItem[] mediaVideoItem) throws Exception {
        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            try {
                mVideoEditor.addMediaItem(mediaVideoItem[i]);
            } catch (Exception e1) {
                assertTrue(
                    "Can not add an object of Video Item with ID:m" + i +
                    "    Issue = " + e1.toString(), false);
            }
        }
    }

    private void removeVideoItems(MediaVideoItem[] mediaVideoItem) throws Exception {
            for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            try {
            mVideoEditor.removeMediaItem(mediaVideoItem[i].getId());
            } catch (Exception e1) {
                assertTrue(
                    "Can not Remove an object of Video Item with ID:m" + i +
                    "    Issue = " + e1.toString(), false);
            }
        }
    }

    private void createImageItems(MediaImageItem[] mIi,
        String imageItemFileName, int renderingMode, int duration) throws Exception {
        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            try {
                mIi[i] = new MediaImageItem(mVideoEditor, "m" + i,
                    imageItemFileName, duration, renderingMode);
            } catch (Exception e1) {
                assertTrue( " Cannot create Image Item", false);
            }
        }
    }

    private void addImageItems(MediaImageItem[] mIi) throws Exception {
        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            try {
                mVideoEditor.addMediaItem(mIi[i]);
            } catch (Exception e1) {
                assertTrue("Cannot add Image item", false);
            }
        }
    }

    private void removeImageItems(MediaImageItem[] mIi) throws Exception {
            for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            try {
            mVideoEditor.removeMediaItem(mIi[i].getId());
            } catch (Exception e1) {
                assertTrue("Cannot remove image item", false);
            }
        }
    }
    /**
     * To test the performance of adding and removing the video media item
     *
     * @throws Exception
     */
    // TODO : remove PRF_001
    @LargeTest
    public void testPerformanceAddRemoveVideoItem() throws Exception {
        final String videoItemFileName = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final int videoItemStartTime = 0;
        final int videoItemEndTime = 5000;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final String[] loggingInfo = new String[3];
        final MediaVideoItem[] mediaVideoItem =
            new MediaVideoItem[NUM_OF_ITERATIONS];
        float timeTaken = 0.0f;
        long startTime = 0;

        /** Time Take for creation of Media Video Item */
        startTime = SystemClock.uptimeMillis();
        createVideoItems(mediaVideoItem, videoItemFileName, renderingMode,
            videoItemStartTime, videoItemEndTime);

        timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS);
        loggingInfo[0] = "Time taken to Create Media Video Item\t" +
            timeTaken;

        /** Time Take for Addition of Media Video Item */
        startTime = SystemClock.uptimeMillis();
        addVideoItems(mediaVideoItem);
        timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS);
        loggingInfo[1] = "\n\tTime taken to Add  Media Video Item\t"
            + timeTaken;

        /** Time Take for Removal of Media Video Item */
        startTime = SystemClock.uptimeMillis();
        removeVideoItems(mediaVideoItem);
        timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS);
        loggingInfo[2] = "\n\tTime taken to remove  Media Video Item\t"
            + timeTaken;

        writeTimingInfo("testPerformanceAddRemoveVideoItem (in mSec)", loggingInfo);
    }

    /**
     * To test the performance of adding and removing the image media item
     *
     * @throws Exception
     */
    // TODO : remove PRF_002
    @LargeTest
    public void testPerformanceAddRemoveImageItem() throws Exception {
        final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
        final int imageItemDuration = 0;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final String[] loggingInfo = new String[3];
        final MediaImageItem[] mediaImageItem =
            new MediaImageItem[NUM_OF_ITERATIONS];
        float timeTaken = 0.0f;

        long beginTime = SystemClock.uptimeMillis();
        createImageItems(mediaImageItem, imageItemFileName, renderingMode,
            imageItemDuration);
        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
        loggingInfo[0] = "Time taken to Create  Media Image Item\t" +
            timeTaken;

        beginTime = SystemClock.uptimeMillis();
        addImageItems(mediaImageItem);
        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
        loggingInfo[1] = "\n\tTime taken to add  Media Image Item\t" +
            timeTaken;

        beginTime = SystemClock.uptimeMillis();
        removeImageItems(mediaImageItem);
        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
        loggingInfo[2] = "\n\tTime taken to remove  Media Image Item\t"
            + timeTaken;

        writeTimingInfo("testPerformanceAddRemoveImageItem (in mSec)",
            loggingInfo);
    }

    /**
     * To test the performance of adding and removing the transition
     *
     * @throws Exception
     */
    // TODO : remove PRF_003
    @LargeTest
    public void testPerformanceAddRemoveTransition() throws Exception {
        final String videoItemFileName1 = INPUT_FILE_PATH +
        "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final int videoItemStartTime1 = 0;
        final int videoItemEndTime1 = 20000;
        final String videoItemFileName2 = INPUT_FILE_PATH
            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
        final int videoItemStartTime2 = 0;
        final int videoItemEndTime2 = 20000;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final int transitionDuration = 5000;
        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
        final String[] loggingInfo = new String[3];
        float timeTaken = 0.0f;

        final MediaVideoItem[] mediaVideoItem =
            new MediaVideoItem[(NUM_OF_ITERATIONS *10) + 1];

        for (int i = 0; i < (NUM_OF_ITERATIONS *10); i+=2) {
            try {
                mediaVideoItem[i] = new MediaVideoItem(mVideoEditor, "m" + i,
                    videoItemFileName1, renderingMode);
                mediaVideoItem[i+1] = new MediaVideoItem(mVideoEditor,
                    "m" + (i+1), videoItemFileName2, renderingMode);
                mediaVideoItem[i].setExtractBoundaries(videoItemStartTime1,
                    videoItemEndTime1);
                mediaVideoItem[i+1].setExtractBoundaries(videoItemStartTime2,
                    videoItemEndTime2);
            } catch (Exception e1) {
                assertTrue("Can not create Video Object Item with file name = "
                    + e1.toString(), false);
            }
            mVideoEditor.addMediaItem(mediaVideoItem[i]);
            mVideoEditor.addMediaItem(mediaVideoItem[i+1]);
        }
        mediaVideoItem[(NUM_OF_ITERATIONS *10)] = new MediaVideoItem(mVideoEditor,
            "m" + (NUM_OF_ITERATIONS *10), videoItemFileName1, renderingMode);
        mediaVideoItem[(NUM_OF_ITERATIONS *10)].setExtractBoundaries(
            videoItemStartTime1, videoItemEndTime1);
        mVideoEditor.addMediaItem(mediaVideoItem[(NUM_OF_ITERATIONS *10)]);
        final TransitionCrossfade tranCrossfade[] =
            new TransitionCrossfade[(NUM_OF_ITERATIONS *10)];

        long beginTime = SystemClock.uptimeMillis();
        for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) {
            tranCrossfade[i] = new TransitionCrossfade("transition" + i,
                mediaVideoItem[i], mediaVideoItem[i+1], transitionDuration,
                transitionBehavior);
        }
        timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
        loggingInfo[0] = "Time taken to Create CrossFade Transition\t" +
            timeTaken;

        beginTime = SystemClock.uptimeMillis();
        for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) {
            mVideoEditor.addTransition(tranCrossfade[i]);
        }
        timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
        loggingInfo[1] = "\n\tTime taken to add CrossFade Transition\t" +
            timeTaken;

        beginTime = SystemClock.uptimeMillis();
        for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) {
            assertEquals("Removing Transitions", tranCrossfade[i], mVideoEditor
                .removeTransition(tranCrossfade[i].getId()));
        }
        timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
        loggingInfo[2] = "\n\tTime taken to remove CrossFade Transition\t" +
            timeTaken;

        writeTimingInfo("testPerformanceAddRemoveTransition (in mSec)", loggingInfo);
    }

    /**
     * To test performance of Export
     *
     * @throws Exception
     */
    // TODO : remove PRF_004
    @LargeTest
    public void testPerformanceExport() throws Exception {
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final int outHeight = MediaProperties.HEIGHT_480;
        final int outBitrate = MediaProperties.BITRATE_256K;
        final int outVcodec = MediaProperties.VCODEC_H264BP;
        final String[] loggingInfo = new String[1];
        final String outFilename = mVideoEditorHelper
            .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
        final String videoItemFileName1 = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4";
        final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
        final String videoItemFileName2 = INPUT_FILE_PATH +
            "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_32kbps_m_1_17.3gp";
        final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
        final String videoItemFileName3 = INPUT_FILE_PATH +
            "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
        final String overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
        final String audioTrackFilename = INPUT_FILE_PATH +
            "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
        final String maskFilename = INPUT_FILE_PATH +
            "TransitionSpiral_QVGA.jpg";

        final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor,
            "m1", videoItemFileName1, renderingMode);
        mediaItem1.setExtractBoundaries(0, 20000);
        mVideoEditor.addMediaItem(mediaItem1);

        final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor,
            "m2", imageItemFileName1, 10000, renderingMode);
        mVideoEditor.addMediaItem(mediaItem2);

        final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor,
            "m3", videoItemFileName2, renderingMode);
        mediaItem3.setExtractBoundaries(0, 20000);
        mVideoEditor.addMediaItem(mediaItem3);

        final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor,
            "m4", imageItemFileName2, 10000, renderingMode);
        mVideoEditor.addMediaItem(mediaItem4);

        final MediaVideoItem mediaItem5 = new MediaVideoItem(mVideoEditor,
            "m5", videoItemFileName3, renderingMode);
        mediaItem5.setExtractBoundaries(0, 20000);
        mVideoEditor.addMediaItem(mediaItem5);
        /**
         * 7.Add TransitionAlpha, Apply this  Transition as Begin for Media Item 1
         *  with duration = 2 sec behavior = BEHAVIOR_LINEAR, mask file name =
         * TransitionSpiral_QVGA.jpg , blending percent = 50%, invert = true;
         * */
        final TransitionAlpha transition1 =
            mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1,
                2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
        mVideoEditor.addTransition(transition1);

        /**
         * 8.Add Transition Sliding between MediaItem 2 and 3 ,
         *  Sliding Direction  = DIRECTION_RIGHT_OUT_LEFT_IN,
         *  behavior  = BEHAVIOR_MIDDLE_FAST and duration = 4sec
         * */
        final TransitionSliding transition2And3 =
            mVideoEditorHelper.createTSliding("transition2", mediaItem2,
                mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST,
                TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
        mVideoEditor.addTransition(transition2And3);

        /**
         * 9.Add Transition Crossfade between  Media Item 3 and 4,
         *  behavior = BEHAVIOR_MIDDLE_SLOW, duration = 3.5 sec
         * */
        final TransitionCrossfade transition3And4 =
            mVideoEditorHelper.createTCrossFade("transition3", mediaItem3,
                mediaItem4, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
        mVideoEditor.addTransition(transition3And4);

        /**
         * 10.Add Transition Fadeblack between  Media Item 4 and 5,
         *  behavior = BEHAVIOR_SPEED_DOWN, duration = 3.5 sec
         * */
        final TransitionFadeBlack transition4And5 =
            mVideoEditorHelper.createTFadeBlack("transition4", mediaItem4,
                mediaItem5, 3500, Transition.BEHAVIOR_SPEED_DOWN);
        mVideoEditor.addTransition(transition4And5);

        /**
         * 11.Add Effect 1 type="TYPE_SEPIA" to the MediaItem 1,
         *  start time=1sec and duration =4secs
         * */
        final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(
            mediaItem1, "effect1", 1000, 4000, EffectColor.TYPE_SEPIA, 0);
        mediaItem1.addEffect(effectColor1);

        /**
         * 12.Add Overlay 1  to the MediaItem 3: Frame Overlay with start time = 1 sec
         * duration = 4 sec with item  = IMG_640x480_Overlay1.png
         * */
        final Bitmap mBitmap =  mVideoEditorHelper.getBitmap(overlayFile, 640,
            480);
        final OverlayFrame overlayFrame =
            mVideoEditorHelper.createOverlay(mediaItem3, "overlay",
                mBitmap, 1000, 4000);
        mediaItem3.addOverlay(overlayFrame);
        /**
         * 13.Add Effect 2 type="TYPE_NEGATIVE" to the MediaItem 2,
         *  start time=8sec and duration =2secs
         * */
        final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem(
            mediaItem2, "effect2", 8000, 2000, EffectColor.TYPE_NEGATIVE, 0);
        mediaItem2.addEffect(effectColor2);
        /**
         * 14.Add Effect 3 type="TYPE_COLOR" to the MediaItem 3, color param = "PINK",
         *  start time=5 sec and duration =3secs
         * */
        final EffectColor effectColor3 = mVideoEditorHelper.createEffectItem(
            mediaItem3, "effect3", 5000, 3000, EffectColor.TYPE_COLOR,
            EffectColor.PINK);
        mediaItem3.addEffect(effectColor3);
        /**
         * 15.Add Effect 4 type="TYPE_FIFTIES" to the MediaItem 4,
         *  start time=2 sec and duration =1secs
        * */
        final EffectColor effectColor4 = mVideoEditorHelper.createEffectItem(
            mediaItem4, "effect4", 2000, 1000, EffectColor.TYPE_FIFTIES, 0);
        mediaItem4.addEffect(effectColor4);
        /**
         * 16.Add KenBurnsEffect for MediaItem 4 with
         *  duration = 3 sec and startTime = 4 sec
         *  StartRect
         *  left = org_height/3  ;  top = org_width/3
         *  bottom = org_width/2  ;  right = org_height/2
         *  EndRect
         *  left = 0  ;  top = 0
         *  bottom =  org_height;  right =  org_width
         * */

        final Rect startRect = new Rect((mediaItem4.getHeight() / 3),
            (mediaItem4.getWidth() / 3), (mediaItem4.getHeight() / 2),
            (mediaItem4.getWidth() / 2));
        final Rect endRect = new Rect(0, 0, mediaItem4.getWidth(),
            mediaItem4.getHeight());
        final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(
            mediaItem4, "KBOnM2", startRect, endRect,4000 , 3000);
        mediaItem4.addEffect(kbEffectOnMediaItem);

        /** 17.Add Audio Track,Set extract boundaries o to 10 sec.
         * */
        final AudioTrack audioTrack = mVideoEditorHelper.createAudio(
            mVideoEditor, "audioTrack", audioTrackFilename);
        mVideoEditor.addAudioTrack(audioTrack);
        /** 18.Enable Looping for Audio Track.
         * */
        audioTrack.enableLoop();
        float timeTaken = 0.0f;
        final long beginTime = SystemClock.uptimeMillis();
            try {
                mVideoEditor.export(outFilename, outHeight, outBitrate,
                    new ExportProgressListener() {
                        public void onProgress(VideoEditor ve,
                            String outFileName, int progress) {
                        }
                    });
            } catch (Exception e) {
                assertTrue("Error in Export" + e.toString(), false);
            }
        mVideoEditorHelper.checkDeleteExistingFile(outFilename);

        timeTaken = calculateTimeTaken(beginTime, 1);
        loggingInfo[0] = "Time taken to do ONE export of storyboard duration\t"
            + mVideoEditor.getDuration() + "   is   :\t" + timeTaken;

        writeTimingInfo("testPerformanceExport (in mSec)", loggingInfo);
        mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
    }


    /**
     * To test the performance of thumbnail extraction
     *
     * @throws Exception
     */
    // TODO : remove PRF_005
    @LargeTest
    public void testPerformanceThumbnailVideoItem() throws Exception {
        final String videoItemFileName = INPUT_FILE_PATH
            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
        final int videoItemStartTime = 0;
        final int videoItemEndTime = 20000;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final String[] loggingInfo = new String[1];

        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
            "m1", videoItemFileName, renderingMode);
        mediaVideoItem.setExtractBoundaries(videoItemStartTime,
            videoItemEndTime);

        float timeTaken = 0.0f;
        long beginTime = SystemClock.uptimeMillis();
        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            mediaVideoItem.getThumbnail(mediaVideoItem.getWidth() / 2,
                mediaVideoItem.getHeight() / 2, i);
        }
        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
        loggingInfo[0] = "Duration taken to get Video Thumbnails\t" +
            timeTaken;

        writeTimingInfo("testPerformanceThumbnailVideoItem (in mSec)", loggingInfo);
    }

    /**
     * To test the performance of adding and removing the overlay to media item
     *
     * @throws Exception
     */
    // TODO : remove PRF_006
    @LargeTest
    public void testPerformanceOverlayVideoItem() throws Exception {
        final String videoItemFileName1 = INPUT_FILE_PATH +
            "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
        final int videoItemStartTime1 = 0;
        final int videoItemEndTime1 = 10000;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final String overlayFilename = INPUT_FILE_PATH
            + "IMG_640x480_Overlay1.png";
        final int overlayStartTime = 1000;
        final int overlayDuration = 5000;

        final String[] loggingInfo = new String[2];
        MediaVideoItem mediaVideoItem = null;

        try {
            mediaVideoItem = new MediaVideoItem(mVideoEditor, "m0",
                videoItemFileName1, renderingMode);
            mediaVideoItem.setExtractBoundaries(videoItemStartTime1,
                videoItemEndTime1);
        } catch (Exception e1) {
            assertTrue("Can not create Video Item with file name = "
                + e1.toString(), false);
        }
        final OverlayFrame overlayFrame[] = new OverlayFrame[NUM_OF_ITERATIONS];
        final Bitmap mBitmap =  mVideoEditorHelper.getBitmap(overlayFilename,
            640, 480);
        float timeTaken = 0.0f;
        long beginTime = SystemClock.uptimeMillis();
        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            overlayFrame[i] = new OverlayFrame(mediaVideoItem, "overlay" + i,
            mBitmap, overlayStartTime, overlayDuration);
            mediaVideoItem.addOverlay(overlayFrame[i]);
        }
        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
        loggingInfo[0] = "Time taken to add & create Overlay\t" + timeTaken;

        beginTime = SystemClock.uptimeMillis();
        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            assertEquals("Removing Overlays", overlayFrame[i],
                mediaVideoItem.removeOverlay((overlayFrame[i].getId())));
        }
        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
        loggingInfo[1] = "\n\tTime taken to remove  Overlay\t" +
            timeTaken;

        writeTimingInfo("testPerformanceOverlayVideoItem (in mSec)", loggingInfo);
    }

    /**
     * To test the performance of get properties of a Video media item
     *
     * @throws Exception
     */
    // TODO : remove PRF_007
    @LargeTest
    public void testPerformanceVideoItemProperties() throws Exception {
        final String videoItemFileName1 = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final int videoItemStartTime1 = 0;
        final int videoItemEndTime1 = 10100;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
        final int fileType = MediaProperties.FILE_MP4;
        final int videoCodecType = MediaProperties.VCODEC_H264BP;
        final int duration = 77366;
        final int videoBitrate = 3169971;
        final int fps = 30;
        final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
        final int width = 1080;
        final int height = MediaProperties.HEIGHT_720;
        float timeTaken = 0.0f;
        final String[] loggingInfo = new String[1];
        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
            "m0", videoItemFileName1, renderingMode);
        mediaVideoItem.setExtractBoundaries(videoItemStartTime1,
            videoItemEndTime1);
        long beginTime = SystemClock.uptimeMillis();
        for (int i = 0; i < (NUM_OF_ITERATIONS*10); i++) {
            try {
                assertEquals("Aspect Ratio Mismatch",
                    aspectRatio, mediaVideoItem.getAspectRatio());
                assertEquals("File Type Mismatch",
                    fileType, mediaVideoItem.getFileType());
                assertEquals("VideoCodec Mismatch",
                    videoCodecType, mediaVideoItem.getVideoType());
                assertEquals("duration Mismatch",
                    duration, mediaVideoItem.getDuration());
                assertEquals("Video Profile ",
                    videoProfile, mediaVideoItem.getVideoProfile());
                assertEquals("Video height ",
                    height, mediaVideoItem.getHeight());
                assertEquals("Video width ",
                    width, mediaVideoItem.getWidth());
            } catch (Exception e1) {
                assertTrue("Can not create Video Item with file name = "
                    + e1.toString(), false);
            }
        }
        timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS*10));
        loggingInfo[0] = "Time taken to get Media Properties\t"
            + timeTaken;
        writeTimingInfo("testPerformanceVideoItemProperties:", loggingInfo);
    }

    /**
     * To test the performance of generatePreview : with Transitions
     *
     * @throws Exception
     */
    // TODO : remove PRF_008
    @LargeTest
    public void testPerformanceGeneratePreviewWithTransitions()
        throws Exception {
        final String videoItemFileName = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final String imageItemFileName = INPUT_FILE_PATH +
            "IMG_1600x1200.jpg";
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
        long averageTime = 0;
        final String[] loggingInfo = new String[1];

        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
            "mediaItem1", videoItemFileName, renderingMode);
        mediaVideoItem.setExtractBoundaries(0, 10000);
        mVideoEditor.addMediaItem(mediaVideoItem);

        final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor,
            "mediaItem2", imageItemFileName, 10000, renderingMode);
        mVideoEditor.addMediaItem(mediaImageItem);

        final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
            "transitionCrossFade", mediaVideoItem, mediaImageItem,
            5000, transitionBehavior);
        mVideoEditor.addTransition(transitionCrossFade);

        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            final long duration1 = SystemClock.uptimeMillis();
            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
                public void onProgress(Object item, int action, int progress) {
                }
            });
            final long duration2 = SystemClock.uptimeMillis();
            mVideoEditor.removeTransition(transitionCrossFade.getId());
            mVideoEditor.addTransition(transitionCrossFade);
            averageTime += (duration2 - duration1);
        }
        final long durationToAddObjects = averageTime;
        final float timeTaken = (float)durationToAddObjects *
            1.0f/(float)NUM_OF_ITERATIONS;
        loggingInfo[0] = "Time taken to Generate Preview with transition\t"
            + timeTaken;
        writeTimingInfo("testPerformanceGeneratePreviewWithTransitions:",
            loggingInfo);
    }

    /**
     * To test the performance of generatePreview : with KenBurn
     *
     * @throws Exception
     */
    // TODO : remove PRF_009
    @LargeTest
    public void testPerformanceWithKenBurn() throws Exception {
        final String videoItemFileName = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final String imageItemFileName = INPUT_FILE_PATH +
            "IMG_1600x1200.jpg";
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        long averageTime = 0;
        final String[] loggingInfo = new String[1];
        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
            "mediaItem1", videoItemFileName, renderingMode);
        mediaVideoItem.setExtractBoundaries(0, 10000);
        mVideoEditor.addMediaItem(mediaVideoItem);

        final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor,
            "mediaItem2", imageItemFileName, 10000, renderingMode);
        mVideoEditor.addMediaItem(mediaImageItem);

        final Rect startRect = new Rect((mediaImageItem.getHeight() / 3),
            (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2),
            (mediaImageItem.getWidth() / 2));
        final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(),
            mediaImageItem.getHeight());
        final EffectKenBurns kbEffectOnMediaItem =
            new EffectKenBurns(mediaImageItem, "KBOnM2", startRect, endRect,
                500, 3000);
        mediaImageItem.addEffect(kbEffectOnMediaItem);

        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            final long duration1 = SystemClock.uptimeMillis();
            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
                public void onProgress(Object item, int action, int progress) {
                }
            });
            final long duration2 = SystemClock.uptimeMillis();
            mediaImageItem.removeEffect(kbEffectOnMediaItem.getId());
            mediaImageItem.addEffect(kbEffectOnMediaItem);
            averageTime += duration2 - duration1;
        }

        final long durationToAddObjects = (averageTime);
        final float timeTaken = (float)durationToAddObjects *
            1.0f/(float)NUM_OF_ITERATIONS;
        loggingInfo[0] = "Time taken to Generate KenBurn Effect \t"
            + timeTaken;
        writeTimingInfo("testPerformanceWithKenBurn", loggingInfo);
    }

    /**
     * To test the performance of generatePreview : with Transitions and
     * Effect,Overlapping scenario
     *
     * @throws Exception
     */
    // TODO : remove PRF_010
    @LargeTest
    public void testPerformanceEffectOverlappingTransition() throws Exception {
        final String videoItemFileName1 = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final String videoItemFileName2 = INPUT_FILE_PATH
            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
        final int videoStartTime1 = 0;
        final int videoEndTime1 = 10000;
        final int videoStartTime2 = 0;
        final int videoEndTime2 = 10000;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final int transitionDuration = 5000;
        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
        final int effectItemStartTime = 5000;
        final int effectItemDurationTime = 5000;
        final int effectType = EffectColor.TYPE_COLOR;
        final int effectColorType = EffectColor.GREEN;
        long averageDuration = 0;

        final String[] loggingInfo = new String[1];
        final MediaVideoItem mediaVideoItem1 = new MediaVideoItem(mVideoEditor,
            "mediaItem1", videoItemFileName1, renderingMode);
        mediaVideoItem1.setExtractBoundaries(videoStartTime1, videoEndTime1);
        mVideoEditor.addMediaItem(mediaVideoItem1);

        final MediaVideoItem mediaVideoItem2 = new MediaVideoItem(mVideoEditor,
            "mediaItem2", videoItemFileName2, renderingMode);
        mediaVideoItem2.setExtractBoundaries(videoStartTime2, videoEndTime2);
        mVideoEditor.addMediaItem(mediaVideoItem2);

        final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
            "transitionCrossFade", mediaVideoItem1, mediaVideoItem2,
            transitionDuration, transitionBehavior);
        mVideoEditor.addTransition(transitionCrossFade);

        final EffectColor effectColor = new EffectColor(mediaVideoItem1,
            "effect", effectItemStartTime, effectItemDurationTime, effectType,
             effectColorType);
        mediaVideoItem1.addEffect(effectColor);

        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            final long duration1 = SystemClock.uptimeMillis();
            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
                public void onProgress(Object item, int action, int progress) {
                }
            });
            final long duration2 = SystemClock.uptimeMillis();
            mVideoEditor.removeTransition(transitionCrossFade.getId());
            mVideoEditor.addTransition(transitionCrossFade);
            averageDuration += (duration2 - duration1);
        }
        SystemClock.uptimeMillis();
        final long durationToAddObjects = (averageDuration);
        final float timeTaken = (float)durationToAddObjects *
            1.0f/(float)NUM_OF_ITERATIONS;
        loggingInfo[0] =
            "Time taken to testPerformanceEffectOverlappingTransition\t"
            + timeTaken;
        writeTimingInfo("testPerformanceEffectOverlappingTransition:",
            loggingInfo);
    }

    /**
     * To test creation of story board with Transition and Two Effects, Effect
     * overlapping transitions
     *
     * @throws Exception
     */
    // TODO : remove PRF_011
    @LargeTest
    public void testPerformanceTransitionWithEffectOverlapping() throws Exception {
        final String videoItemFileName1 = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final String videoItemFileName2 = INPUT_FILE_PATH
            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final int transitionDuration = 5000;
        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
        final int effectItemStartTime1 = 5000;
        final int effectItemDurationTime1 = 5000;
        final int effectType1 = EffectColor.TYPE_COLOR;
        final int effectColorType1 = EffectColor.GREEN;
        final int effectItemStartTime2 = 5000;
        final int effectItemDurationTime2 = 5000;
        final int effectType2 = EffectColor.TYPE_COLOR;
        final int effectColorType2 = EffectColor.GREEN;
        int averageTime = 0;
        final String[] loggingInfo = new String[1];

        final MediaVideoItem mediaVideoItem1 = new MediaVideoItem(mVideoEditor,
            "mediaItem1", videoItemFileName1, renderingMode);
        mVideoEditor.addMediaItem(mediaVideoItem1);

        final MediaVideoItem mediaVideoItem2 = new MediaVideoItem(mVideoEditor,
            "mediaItem2", videoItemFileName2, renderingMode);
        mVideoEditor.addMediaItem(mediaVideoItem2);

        final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
            "transitionCrossFade", mediaVideoItem1, mediaVideoItem2,
            transitionDuration, transitionBehavior);
        mVideoEditor.addTransition(transitionCrossFade);

        final EffectColor effectColor1 = new EffectColor(mediaVideoItem1,
            "effect1", effectItemStartTime1, effectItemDurationTime1,
            effectType1, effectColorType1);
        mediaVideoItem1.addEffect(effectColor1);

        final EffectColor effectColor2 = new EffectColor(mediaVideoItem2,
            "effect2", effectItemStartTime2, effectItemDurationTime2,
            effectType2, effectColorType2);
        mediaVideoItem2.addEffect(effectColor2);

        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            final long duration1 = SystemClock.uptimeMillis();
            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
                public void onProgress(Object item, int action, int progress) {
                }
            });
            final long duration2 = SystemClock.uptimeMillis();
            mVideoEditor.removeTransition(transitionCrossFade.getId());
            mVideoEditor.addTransition(transitionCrossFade);
            averageTime += duration2 - duration1;
        }
        final long durationToAddObjects = (averageTime);
        final float timeTaken = (float)durationToAddObjects *
            1.0f/(float)NUM_OF_ITERATIONS;
        loggingInfo[0] = "Time taken to TransitionWithEffectOverlapping\t"
            + timeTaken;
        writeTimingInfo("testPerformanceTransitionWithEffectOverlapping",
            loggingInfo);
    }

    /**
     *To test ThumbnailList for H264
     */
    // TODO : TC_PRF_12
    @LargeTest
    public void testThumbnailH264NonIFrame() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final int outWidth = 1080;
        final int outHeight = 720;
        final int atTime = 2400;
        long durationToAddObjects = 0;
        int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final String[] loggingInfo = new String[1];
        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
            "m1", videoItemFilename, renderingMode);
        assertNotNull("MediaVideoItem", mediaVideoItem);

        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            final long duration1 = SystemClock.uptimeMillis();
            mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i);
            final long duration2 = SystemClock.uptimeMillis();
            durationToAddObjects += (duration2 - duration1);
        }
        final float timeTaken = (float)durationToAddObjects *
            1.0f/(float)NUM_OF_ITERATIONS;
        loggingInfo[0] = "Time taken for Thumbnail generation \t"
            + timeTaken;
        writeTimingInfo("testThumbnailH264NonIFrame", loggingInfo);
    }

    /**
     *To test ThumbnailList for H264
     */
    // TODO : TC_PRF_13
    @LargeTest
    public void testThumbnailH264AnIFrame() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final int outWidth = 1080;
        final int outHeight = 720;
        final int atTime = 3000;
        int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final String[] loggingInfo = new String[1];
        long durationToAddObjects = 0;

        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
            "m1", videoItemFilename, renderingMode);
        assertNotNull("MediaVideoItem", mediaVideoItem);

        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
            final long duration1 = SystemClock.uptimeMillis();
            mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i);
            final long duration2 = SystemClock.uptimeMillis();
            durationToAddObjects += (duration2 - duration1);
        }
        final float timeTaken = (float)durationToAddObjects *
            1.0f/(float)NUM_OF_ITERATIONS;
        loggingInfo[0] = "Time taken Thumbnail generation \t"
            + timeTaken;
        writeTimingInfo("testThumbnailH264AnIFrame", loggingInfo);
    }

    /**
     * To test the performance : With an audio track
     *
     * @throws Exception
     */
    // TODO : remove PRF_014
    @LargeTest
    public void testPerformanceWithAudioTrack() throws Exception {
        final String videoItemFileName1 = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final String audioFilename1 = INPUT_FILE_PATH +
            "AACLC_44.1kHz_256kbps_s_1_17.mp4";
        final String audioFilename2 = INPUT_FILE_PATH +
            "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final int audioVolume = 50;
        final String[] loggingInfo = new String[2];
        float timeTaken = 0.0f;

        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
            "mediaItem1", videoItemFileName1, renderingMode);
        mVideoEditor.addMediaItem(mediaVideoItem);

        final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor,
            "Audio Track1", audioFilename1);
        audioTrack1.disableDucking();
        audioTrack1.setVolume(audioVolume);
        mVideoEditor.addAudioTrack(audioTrack1);

        long beginTime = SystemClock.uptimeMillis();
        mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
            public void onProgress(Object item, int action, int progress) {
            }
        });
        timeTaken = calculateTimeTaken(beginTime, 1);
        loggingInfo[0] = "Time taken for 1st Audio Track (AACLC)\t"
            + timeTaken;

        final AudioTrack audioTrack2 = new AudioTrack(mVideoEditor,
            "Audio Track2", audioFilename2);
        audioTrack2.enableLoop();

        beginTime = SystemClock.uptimeMillis();
        mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
            public void onProgress(Object item, int action, int progress) {
            }
        });
        timeTaken = calculateTimeTaken(beginTime, 1);
        loggingInfo[1] = "\n\tTime taken for 2nd Audio Track(AMRNB)\t"
            + timeTaken;

        writeTimingInfo("testPerformanceWithAudioTrack", loggingInfo);
    }

    /**
     * To test the performance of adding and removing the
     * image media item with 640 x 480
     *
     * @throws Exception
     */
    // TODO : remove PRF_015
    @LargeTest
    public void testPerformanceAddRemoveImageItem640x480() throws Exception {
        final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
        final int imageItemDuration = 0;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final String[] loggingInfo = new String[3];

        float timeTaken = 0.0f;

        final MediaImageItem[] mediaImageItem =
            new MediaImageItem[NUM_OF_ITERATIONS];
        long beginTime = SystemClock.uptimeMillis();
        createImageItems(mediaImageItem, imageItemFileName, renderingMode,
            imageItemDuration);
        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
        loggingInfo[0] = "Time taken to Create  Media Image Item (640x480)\t"
            + timeTaken;

        beginTime = SystemClock.uptimeMillis();
        addImageItems(mediaImageItem);
        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
        loggingInfo[1] = "\n\tTime taken to add  Media Image Item (640x480)\t"
            + timeTaken;

        beginTime = SystemClock.uptimeMillis();
        removeImageItems(mediaImageItem);
        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
        loggingInfo[2] = "\n\tTime taken to remove  Media Image Item (640x480)\t"
            + timeTaken;
        writeTimingInfo("testPerformanceAddRemoveImageItem640x480 (in mSec)", loggingInfo);
    }


}