mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add parameterized dump tests for single item exports.
PiperOrigin-RevId: 563075771
This commit is contained in:
parent
45e15d48c4
commit
ef45c0fe5d
5 changed files with 1407 additions and 55 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,73 @@
|
||||||
|
format 0:
|
||||||
|
averageBitrate = 131072
|
||||||
|
sampleMimeType = audio/mp4a-latm
|
||||||
|
channelCount = 1
|
||||||
|
sampleRate = 44100
|
||||||
|
pcmEncoding = 2
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = -385202820
|
||||||
|
size = 8820
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 0
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = -361135248
|
||||||
|
size = 8820
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 100000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = -1518413431
|
||||||
|
size = 8820
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 200000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = -1956112362
|
||||||
|
size = 8820
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 300000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = 1209498603
|
||||||
|
size = 8820
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 400000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = 1880717174
|
||||||
|
size = 8820
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 500000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = -615889148
|
||||||
|
size = 8820
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 600000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = -2069551664
|
||||||
|
size = 8820
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 700000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = 427443063
|
||||||
|
size = 8820
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 800000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = 1770175633
|
||||||
|
size = 8820
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 900000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = 1038969069
|
||||||
|
size = 1604
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 1000000
|
||||||
|
released = true
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
format 0:
|
||||||
|
averageBitrate = 131072
|
||||||
|
sampleMimeType = audio/mp4a-latm
|
||||||
|
channelCount = 2
|
||||||
|
sampleRate = 48000
|
||||||
|
pcmEncoding = 2
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = -278103001
|
||||||
|
size = 19200
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 0
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = 1522105084
|
||||||
|
size = 19200
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 100000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = 932319027
|
||||||
|
size = 19200
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 200000
|
||||||
|
sample:
|
||||||
|
trackIndex = 0
|
||||||
|
dataHashCode = 325000240
|
||||||
|
size = 9336
|
||||||
|
isKeyFrame = true
|
||||||
|
presentationTimeUs = 300000
|
||||||
|
released = true
|
||||||
|
|
@ -123,61 +123,6 @@ public final class MediaItemExportTest {
|
||||||
removeEncodersAndDecoders();
|
removeEncodersAndDecoders();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void start_videoOnlyPassthrough_completesSuccessfully() throws Exception {
|
|
||||||
Transformer transformer =
|
|
||||||
createTransformerBuilder(muxerFactory, /* enableFallback= */ false).build();
|
|
||||||
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY);
|
|
||||||
|
|
||||||
transformer.start(mediaItem, outputDir.newFile().getPath());
|
|
||||||
TransformerTestRunner.runLooper(transformer);
|
|
||||||
|
|
||||||
DumpFileAsserts.assertOutput(
|
|
||||||
context, muxerFactory.getCreatedMuxer(), getDumpFileName(FILE_VIDEO_ONLY));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void start_audioOnlyPassthrough_completesSuccessfully() throws Exception {
|
|
||||||
Transformer transformer =
|
|
||||||
createTransformerBuilder(muxerFactory, /* enableFallback= */ false).build();
|
|
||||||
// No decoders or encoders for AMR NB.
|
|
||||||
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_AMR_NB);
|
|
||||||
|
|
||||||
transformer.start(mediaItem, outputDir.newFile().getPath());
|
|
||||||
TransformerTestRunner.runLooper(transformer);
|
|
||||||
|
|
||||||
DumpFileAsserts.assertOutput(
|
|
||||||
context, muxerFactory.getCreatedMuxer(), getDumpFileName(FILE_AUDIO_AMR_NB));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void start_audioOnlyTranscoding_completesSuccessfully() throws Exception {
|
|
||||||
Transformer transformer =
|
|
||||||
createTransformerBuilder(muxerFactory, /* enableFallback= */ false)
|
|
||||||
.setAudioMimeType(MimeTypes.AUDIO_AAC) // supported by encoder and muxer
|
|
||||||
.build();
|
|
||||||
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_RAW);
|
|
||||||
|
|
||||||
transformer.start(mediaItem, outputDir.newFile().getPath());
|
|
||||||
TransformerTestRunner.runLooper(transformer);
|
|
||||||
|
|
||||||
DumpFileAsserts.assertOutput(
|
|
||||||
context, muxerFactory.getCreatedMuxer(), getDumpFileName(FILE_AUDIO_RAW));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void start_audioAndVideoPassthrough_completesSuccessfully() throws Exception {
|
|
||||||
Transformer transformer =
|
|
||||||
createTransformerBuilder(muxerFactory, /* enableFallback= */ false).build();
|
|
||||||
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
|
|
||||||
|
|
||||||
transformer.start(mediaItem, outputDir.newFile().getPath());
|
|
||||||
TransformerTestRunner.runLooper(transformer);
|
|
||||||
|
|
||||||
DumpFileAsserts.assertOutput(
|
|
||||||
context, muxerFactory.getCreatedMuxer(), getDumpFileName(FILE_AUDIO_VIDEO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void start_audioAndVideoPassthrough_withClippingStartAtKeyFrame_completesSuccessfully()
|
public void start_audioAndVideoPassthrough_withClippingStartAtKeyFrame_completesSuccessfully()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 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 androidx.media3.transformer;
|
||||||
|
|
||||||
|
import static androidx.media3.transformer.TestUtil.ASSET_URI_PREFIX;
|
||||||
|
import static androidx.media3.transformer.TestUtil.FILE_AUDIO_AMR_NB;
|
||||||
|
import static androidx.media3.transformer.TestUtil.FILE_AUDIO_RAW;
|
||||||
|
import static androidx.media3.transformer.TestUtil.FILE_AUDIO_RAW_STEREO_48000KHZ;
|
||||||
|
import static androidx.media3.transformer.TestUtil.FILE_AUDIO_RAW_VIDEO;
|
||||||
|
import static androidx.media3.transformer.TestUtil.FILE_AUDIO_VIDEO;
|
||||||
|
import static androidx.media3.transformer.TestUtil.FILE_VIDEO_ONLY;
|
||||||
|
import static androidx.media3.transformer.TestUtil.addAudioDecoders;
|
||||||
|
import static androidx.media3.transformer.TestUtil.addAudioEncoders;
|
||||||
|
import static androidx.media3.transformer.TestUtil.createTransformerBuilder;
|
||||||
|
import static androidx.media3.transformer.TestUtil.getDumpFileName;
|
||||||
|
import static androidx.media3.transformer.TestUtil.removeEncodersAndDecoders;
|
||||||
|
|
||||||
|
import androidx.media3.common.MediaItem;
|
||||||
|
import androidx.media3.common.MimeTypes;
|
||||||
|
import androidx.media3.test.utils.DumpFileAsserts;
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.ParameterizedRobolectricTestRunner;
|
||||||
|
import org.robolectric.ParameterizedRobolectricTestRunner.Parameter;
|
||||||
|
import org.robolectric.ParameterizedRobolectricTestRunner.Parameters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parameterized end-to-end test for exporting a single {@link MediaItem} or {@link EditedMediaItem}
|
||||||
|
* and asserting on the dump (golden) files.
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li>Video can not be transcoded, due to OpenGL not being supported with Robolectric.
|
||||||
|
* <li>Non RAW audio can not be trancoded, because AudioGraph requires decoded data but
|
||||||
|
* Robolectric decoders do not decode.
|
||||||
|
* <li>RAW audio will always be transcoded, because the muxer does not support RAW audio as input.
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
@RunWith(ParameterizedRobolectricTestRunner.class)
|
||||||
|
public final class ParameterizedItemExportTest {
|
||||||
|
|
||||||
|
@Parameters(name = "{0}")
|
||||||
|
public static ImmutableList<String> params() {
|
||||||
|
return ImmutableList.of(
|
||||||
|
FILE_AUDIO_RAW,
|
||||||
|
FILE_AUDIO_RAW_STEREO_48000KHZ,
|
||||||
|
"wav/sample_ima_adpcm.wav",
|
||||||
|
FILE_AUDIO_RAW_VIDEO,
|
||||||
|
FILE_AUDIO_AMR_NB,
|
||||||
|
FILE_AUDIO_VIDEO,
|
||||||
|
FILE_VIDEO_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Rule public final TemporaryFolder outputDir = new TemporaryFolder();
|
||||||
|
|
||||||
|
@Parameter public String assetFile;
|
||||||
|
|
||||||
|
private final CapturingMuxer.Factory muxerFactory = new CapturingMuxer.Factory();
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
// Only add RAW decoder, so non-RAW audio has no options for decoding.
|
||||||
|
addAudioDecoders(MimeTypes.AUDIO_RAW);
|
||||||
|
// Use an AAC encoder because Muxer supports AAC.
|
||||||
|
addAudioEncoders(MimeTypes.AUDIO_AAC);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
removeEncodersAndDecoders();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void export() throws Exception {
|
||||||
|
Transformer transformer =
|
||||||
|
createTransformerBuilder(muxerFactory, /* enableFallback= */ false).build();
|
||||||
|
|
||||||
|
transformer.start(
|
||||||
|
MediaItem.fromUri(ASSET_URI_PREFIX + assetFile), outputDir.newFile().getPath());
|
||||||
|
TransformerTestRunner.runLooper(transformer);
|
||||||
|
|
||||||
|
DumpFileAsserts.assertOutput(
|
||||||
|
ApplicationProvider.getApplicationContext(),
|
||||||
|
muxerFactory.getCreatedMuxer(),
|
||||||
|
getDumpFileName(assetFile));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue