diff --git a/libraries/test_data/src/test/assets/media/bitmap/transformer_sequence_effect_test/export_withBt601AndBt709MediaItems_0.png b/libraries/test_data/src/test/assets/media/bitmap/transformer_sequence_effect_test/export_withBt601AndBt709MediaItems_0.png new file mode 100644 index 0000000000..6320b16c8e Binary files /dev/null and b/libraries/test_data/src/test/assets/media/bitmap/transformer_sequence_effect_test/export_withBt601AndBt709MediaItems_0.png differ diff --git a/libraries/test_data/src/test/assets/media/bitmap/transformer_sequence_effect_test/export_withBt601AndBt709MediaItems_1.png b/libraries/test_data/src/test/assets/media/bitmap/transformer_sequence_effect_test/export_withBt601AndBt709MediaItems_1.png new file mode 100644 index 0000000000..64f093aeb1 Binary files /dev/null and b/libraries/test_data/src/test/assets/media/bitmap/transformer_sequence_effect_test/export_withBt601AndBt709MediaItems_1.png differ diff --git a/libraries/test_data/src/test/assets/media/mp4/bt601.mov b/libraries/test_data/src/test/assets/media/mp4/bt601.mov new file mode 100644 index 0000000000..9605a0dfc7 Binary files /dev/null and b/libraries/test_data/src/test/assets/media/mp4/bt601.mov differ diff --git a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/AndroidTestUtil.java b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/AndroidTestUtil.java index 19447a8ed5..0448a34fe4 100644 --- a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/AndroidTestUtil.java +++ b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/AndroidTestUtil.java @@ -88,6 +88,22 @@ public final class AndroidTestUtil { // ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames sample.mp4 public static final int MP4_ASSET_FRAME_COUNT = 30; + public static final String BT601_ASSET_URI_STRING = "asset:///media/mp4/bt601.mov"; + public static final Format BT601_ASSET_FORMAT = + new Format.Builder() + .setSampleMimeType(VIDEO_H264) + .setWidth(640) + .setHeight(428) + .setFrameRate(29.97f) + .setColorInfo( + new ColorInfo.Builder() + .setColorSpace(C.COLOR_SPACE_BT601) + .setColorRange(C.COLOR_RANGE_LIMITED) + .setColorTransfer(C.COLOR_TRANSFER_SDR) + .build()) + .setCodecs("avc1.4D001E") + .build(); + public static final String MP4_PORTRAIT_ASSET_URI_STRING = "asset:///media/mp4/sample_portrait.mp4"; public static final Format MP4_PORTRAIT_ASSET_FORMAT = diff --git a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerSequenceEffectTest.java b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerSequenceEffectTest.java index 04af39f6e1..67306a2af3 100644 --- a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerSequenceEffectTest.java +++ b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerSequenceEffectTest.java @@ -20,6 +20,8 @@ package androidx.media3.transformer; import static androidx.media3.common.util.Assertions.checkNotNull; import static androidx.media3.common.util.Util.SDK_INT; import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; +import static androidx.media3.transformer.AndroidTestUtil.BT601_ASSET_FORMAT; +import static androidx.media3.transformer.AndroidTestUtil.BT601_ASSET_URI_STRING; import static androidx.media3.transformer.AndroidTestUtil.JPG_ASSET_URI_STRING; import static androidx.media3.transformer.AndroidTestUtil.JPG_PORTRAIT_ASSET_URI_STRING; import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_FORMAT; @@ -221,6 +223,39 @@ public final class TransformerSequenceEffectTest { extractBitmapsFromVideo(context, checkNotNull(result.filePath)), testId); } + @Test + public void export_withBt601AndBt709MediaItems() throws Exception { + String testId = "export_withBt601AndBt709MediaItems"; + if (AndroidTestUtil.skipAndLogIfFormatsUnsupported( + context, + testId, + /* inputFormat= */ MP4_ASSET_FORMAT, + /* outputFormat= */ MP4_ASSET_FORMAT)) { + return; + } + if (AndroidTestUtil.skipAndLogIfFormatsUnsupported( + context, testId, /* inputFormat= */ BT601_ASSET_FORMAT, /* outputFormat= */ null)) { + return; + } + Composition composition = + createComposition( + Presentation.createForHeight(EXPORT_HEIGHT), + clippedVideo( + BT601_ASSET_URI_STRING, + ImmutableList.of(RgbFilter.createInvertedFilter()), + SINGLE_30_FPS_VIDEO_FRAME_THRESHOLD_MS), + clippedVideo(MP4_ASSET_URI_STRING, NO_EFFECT, SINGLE_30_FPS_VIDEO_FRAME_THRESHOLD_MS)); + + ExportTestResult result = + new TransformerAndroidTestRunner.Builder(context, new Transformer.Builder(context).build()) + .build() + .run(testId, composition); + + assertThat(result.filePath).isNotNull(); + assertBitmapsMatchExpectedAndSave( + extractBitmapsFromVideo(context, checkNotNull(result.filePath)), testId); + } + private static OverlayEffect createOverlayEffect() throws IOException { return new OverlayEffect( ImmutableList.of(