mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Move video track extraction method to AndroidTestUtil
The method can be reused in other tests as well PiperOrigin-RevId: 729528829
This commit is contained in:
parent
05c8a66dc2
commit
b6aa21a427
@ -62,6 +62,8 @@ import androidx.media3.exoplayer.mediacodec.MediaCodecSelector;
|
||||
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil;
|
||||
import androidx.media3.muxer.MuxerException;
|
||||
import androidx.media3.test.utils.BitmapPixelTestUtil;
|
||||
import androidx.media3.test.utils.FakeExtractorOutput;
|
||||
import androidx.media3.test.utils.FakeTrackOutput;
|
||||
import androidx.media3.test.utils.VideoDecodingWrapper;
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -1138,6 +1140,21 @@ public final class AndroidTestUtil {
|
||||
.isAnyOf(C.COLOR_SPACE_BT709, C.COLOR_SPACE_BT601, Format.NO_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@linkplain FakeTrackOutput video track} from the {@link FakeExtractorOutput} or
|
||||
* {@code null} if a video track is not found.
|
||||
*/
|
||||
@Nullable
|
||||
public static FakeTrackOutput getVideoTrackOutput(FakeExtractorOutput extractorOutput) {
|
||||
for (int i = 0; i < extractorOutput.numberOfTracks; i++) {
|
||||
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(i);
|
||||
if (MimeTypes.isVideo(checkNotNull(trackOutput.lastFormat).sampleMimeType)) {
|
||||
return trackOutput;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ImmutableList<Bitmap> extractBitmapsFromVideo(Context context, String filePath)
|
||||
throws IOException, InterruptedException {
|
||||
return extractBitmapsFromVideo(context, filePath, Config.ARGB_8888);
|
||||
|
@ -46,6 +46,7 @@ import static androidx.media3.transformer.AndroidTestUtil.createFrameCountingEff
|
||||
import static androidx.media3.transformer.AndroidTestUtil.createOpenGlObjects;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.generateTextureFromBitmap;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.getMuxerFactoryBasedOnApi;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.getVideoTrackOutput;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.recordTestSkipped;
|
||||
import static androidx.media3.transformer.ExportResult.CONVERSION_PROCESS_NA;
|
||||
import static androidx.media3.transformer.ExportResult.CONVERSION_PROCESS_TRANSCODED;
|
||||
@ -70,7 +71,6 @@ import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.Pair;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.Effect;
|
||||
import androidx.media3.common.Format;
|
||||
@ -2537,17 +2537,6 @@ public class TransformerEndToEndTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static FakeTrackOutput getVideoTrackOutput(FakeExtractorOutput extractorOutput) {
|
||||
for (int i = 0; i < extractorOutput.numberOfTracks; i++) {
|
||||
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(i);
|
||||
if (MimeTypes.isVideo(checkNotNull(trackOutput.lastFormat).sampleMimeType)) {
|
||||
return trackOutput;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final class VideoUnsupportedEncoderFactory implements Codec.EncoderFactory {
|
||||
|
||||
private final Codec.EncoderFactory encoderFactory;
|
||||
|
Loading…
x
Reference in New Issue
Block a user