mirror of
https://github.com/androidx/media.git
synced 2025-05-13 02:29:52 +08:00
Remove deprecated setOutputMimeType
This is to prepare Muxer to become public PiperOrigin-RevId: 481893842
This commit is contained in:
parent
b6bd35860c
commit
bd9181e6ba
@ -34,25 +34,18 @@ public final class DefaultMuxer implements Muxer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Muxer create(String path, String outputMimeType) throws IOException {
|
public Muxer create(String path) throws IOException {
|
||||||
return new DefaultMuxer(muxerFactory.create(path, outputMimeType));
|
return new DefaultMuxer(muxerFactory.create(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Muxer create(ParcelFileDescriptor parcelFileDescriptor, String outputMimeType)
|
public Muxer create(ParcelFileDescriptor parcelFileDescriptor) throws IOException {
|
||||||
throws IOException {
|
return new DefaultMuxer(muxerFactory.create(parcelFileDescriptor));
|
||||||
return new DefaultMuxer(muxerFactory.create(parcelFileDescriptor, outputMimeType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsOutputMimeType(String mimeType) {
|
public ImmutableList<String> getSupportedSampleMimeTypes(@C.TrackType int trackType) {
|
||||||
return muxerFactory.supportsOutputMimeType(mimeType);
|
return muxerFactory.getSupportedSampleMimeTypes(trackType);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ImmutableList<String> getSupportedSampleMimeTypes(
|
|
||||||
@C.TrackType int trackType, String containerMimeType) {
|
|
||||||
return muxerFactory.getSupportedSampleMimeTypes(trackType, containerMimeType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ import com.google.android.exoplayer2.util.MediaFormatUtil;
|
|||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -42,70 +41,42 @@ import java.nio.ByteBuffer;
|
|||||||
/* package */ final class FrameworkMuxer implements Muxer {
|
/* package */ final class FrameworkMuxer implements Muxer {
|
||||||
|
|
||||||
// MediaMuxer supported sample formats are documented in MediaMuxer.addTrack(MediaFormat).
|
// MediaMuxer supported sample formats are documented in MediaMuxer.addTrack(MediaFormat).
|
||||||
private static final ImmutableMap<String, ImmutableList<String>>
|
private static final ImmutableList<String> SUPPORTED_VIDEO_SAMPLE_MIME_TYPES =
|
||||||
SUPPORTED_CONTAINER_TO_VIDEO_SAMPLE_MIME_TYPES =
|
Util.SDK_INT >= 24
|
||||||
ImmutableMap.of(
|
? ImmutableList.of(
|
||||||
MimeTypes.VIDEO_MP4,
|
MimeTypes.VIDEO_H263,
|
||||||
Util.SDK_INT >= 24
|
MimeTypes.VIDEO_H264,
|
||||||
? ImmutableList.of(
|
MimeTypes.VIDEO_MP4V,
|
||||||
MimeTypes.VIDEO_H263,
|
MimeTypes.VIDEO_H265)
|
||||||
MimeTypes.VIDEO_H264,
|
: ImmutableList.of(MimeTypes.VIDEO_H263, MimeTypes.VIDEO_H264, MimeTypes.VIDEO_MP4V);
|
||||||
MimeTypes.VIDEO_MP4V,
|
|
||||||
MimeTypes.VIDEO_H265)
|
|
||||||
: ImmutableList.of(
|
|
||||||
MimeTypes.VIDEO_H263, MimeTypes.VIDEO_H264, MimeTypes.VIDEO_MP4V),
|
|
||||||
MimeTypes.VIDEO_WEBM,
|
|
||||||
Util.SDK_INT >= 24
|
|
||||||
? ImmutableList.of(MimeTypes.VIDEO_VP8, MimeTypes.VIDEO_VP9)
|
|
||||||
: ImmutableList.of(MimeTypes.VIDEO_VP8));
|
|
||||||
|
|
||||||
private static final ImmutableMap<String, ImmutableList<String>>
|
private static final ImmutableList<String> SUPPORTED_AUDIO_SAMPLE_MIME_TYPES =
|
||||||
SUPPORTED_CONTAINER_TO_AUDIO_SAMPLE_MIME_TYPES =
|
ImmutableList.of(MimeTypes.AUDIO_AAC, MimeTypes.AUDIO_AMR_NB, MimeTypes.AUDIO_AMR_WB);
|
||||||
ImmutableMap.of(
|
|
||||||
MimeTypes.VIDEO_MP4,
|
|
||||||
ImmutableList.of(MimeTypes.AUDIO_AAC, MimeTypes.AUDIO_AMR_NB, MimeTypes.AUDIO_AMR_WB),
|
|
||||||
MimeTypes.VIDEO_WEBM,
|
|
||||||
ImmutableList.of(MimeTypes.AUDIO_VORBIS));
|
|
||||||
|
|
||||||
/** {@link Muxer.Factory} for {@link FrameworkMuxer}. */
|
/** {@link Muxer.Factory} for {@link FrameworkMuxer}. */
|
||||||
public static final class Factory implements Muxer.Factory {
|
public static final class Factory implements Muxer.Factory {
|
||||||
@Override
|
@Override
|
||||||
public FrameworkMuxer create(String path, String outputMimeType) throws IOException {
|
public FrameworkMuxer create(String path) throws IOException {
|
||||||
MediaMuxer mediaMuxer = new MediaMuxer(path, mimeTypeToMuxerOutputFormat(outputMimeType));
|
MediaMuxer mediaMuxer = new MediaMuxer(path, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
|
||||||
return new FrameworkMuxer(mediaMuxer);
|
return new FrameworkMuxer(mediaMuxer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(26)
|
@RequiresApi(26)
|
||||||
@Override
|
@Override
|
||||||
public FrameworkMuxer create(ParcelFileDescriptor parcelFileDescriptor, String outputMimeType)
|
public FrameworkMuxer create(ParcelFileDescriptor parcelFileDescriptor) throws IOException {
|
||||||
throws IOException {
|
|
||||||
MediaMuxer mediaMuxer =
|
MediaMuxer mediaMuxer =
|
||||||
new MediaMuxer(
|
new MediaMuxer(
|
||||||
parcelFileDescriptor.getFileDescriptor(),
|
parcelFileDescriptor.getFileDescriptor(),
|
||||||
mimeTypeToMuxerOutputFormat(outputMimeType));
|
MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
|
||||||
return new FrameworkMuxer(mediaMuxer);
|
return new FrameworkMuxer(mediaMuxer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsOutputMimeType(String mimeType) {
|
public ImmutableList<String> getSupportedSampleMimeTypes(@C.TrackType int trackType) {
|
||||||
try {
|
|
||||||
mimeTypeToMuxerOutputFormat(mimeType);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ImmutableList<String> getSupportedSampleMimeTypes(
|
|
||||||
@C.TrackType int trackType, String containerMimeType) {
|
|
||||||
// MediaMuxer supported sample formats are documented in MediaMuxer.addTrack(MediaFormat).
|
|
||||||
if (trackType == C.TRACK_TYPE_VIDEO) {
|
if (trackType == C.TRACK_TYPE_VIDEO) {
|
||||||
return SUPPORTED_CONTAINER_TO_VIDEO_SAMPLE_MIME_TYPES.getOrDefault(
|
return SUPPORTED_VIDEO_SAMPLE_MIME_TYPES;
|
||||||
containerMimeType, ImmutableList.of());
|
|
||||||
} else if (trackType == C.TRACK_TYPE_AUDIO) {
|
} else if (trackType == C.TRACK_TYPE_AUDIO) {
|
||||||
return SUPPORTED_CONTAINER_TO_AUDIO_SAMPLE_MIME_TYPES.getOrDefault(
|
return SUPPORTED_AUDIO_SAMPLE_MIME_TYPES;
|
||||||
containerMimeType, ImmutableList.of());
|
|
||||||
}
|
}
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
@ -212,25 +183,6 @@ import java.nio.ByteBuffer;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a {@linkplain MimeTypes MIME type} into a {@linkplain MediaMuxer.OutputFormat
|
|
||||||
* MediaMuxer output format}.
|
|
||||||
*
|
|
||||||
* @param mimeType The {@linkplain MimeTypes MIME type} to convert.
|
|
||||||
* @return The corresponding {@linkplain MediaMuxer.OutputFormat MediaMuxer output format}.
|
|
||||||
* @throws IllegalArgumentException If the {@linkplain MimeTypes MIME type} is not supported as
|
|
||||||
* output format.
|
|
||||||
*/
|
|
||||||
private static int mimeTypeToMuxerOutputFormat(String mimeType) {
|
|
||||||
if (mimeType.equals(MimeTypes.VIDEO_MP4)) {
|
|
||||||
return MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4;
|
|
||||||
} else if (SDK_INT >= 21 && mimeType.equals(MimeTypes.VIDEO_WEBM)) {
|
|
||||||
return MediaMuxer.OutputFormat.MUXER_OUTPUT_WEBM;
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Unsupported output MIME type: " + mimeType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Accesses MediaMuxer state via reflection to ensure that muxer resources can be released even
|
// Accesses MediaMuxer state via reflection to ensure that muxer resources can be released even
|
||||||
// if stopping fails.
|
// if stopping fails.
|
||||||
@SuppressLint("PrivateApi")
|
@SuppressLint("PrivateApi")
|
||||||
|
@ -26,13 +26,12 @@ import java.nio.ByteBuffer;
|
|||||||
/**
|
/**
|
||||||
* Abstracts media muxing operations.
|
* Abstracts media muxing operations.
|
||||||
*
|
*
|
||||||
* <p>Query whether {@linkplain Factory#supportsOutputMimeType(String) container MIME type} and
|
* <p>Query whether {@linkplain Factory#getSupportedSampleMimeTypes(int)} sample MIME types} are
|
||||||
* {@linkplain Factory#getSupportedSampleMimeTypes(int, String)} sample MIME types} are supported
|
* supported and {@linkplain #addTrack(Format) add all tracks}, then {@linkplain
|
||||||
* and {@linkplain #addTrack(Format) add all tracks}, then {@linkplain #writeSampleData(int,
|
* #writeSampleData(int, ByteBuffer, boolean, long) write sample data} to mux samples. Once any
|
||||||
* ByteBuffer, boolean, long) write sample data} to mux samples. Once any sample data has been
|
* sample data has been written, it is not possible to add tracks. After writing all sample data,
|
||||||
* written, it is not possible to add tracks. After writing all sample data, {@linkplain
|
* {@linkplain #release(boolean) release} the instance to finish writing to the output and return
|
||||||
* #release(boolean) release} the instance to finish writing to the output and return any resources
|
* any resources to the system.
|
||||||
* to the system.
|
|
||||||
*/
|
*/
|
||||||
/* package */ interface Muxer {
|
/* package */ interface Muxer {
|
||||||
|
|
||||||
@ -55,11 +54,10 @@ import java.nio.ByteBuffer;
|
|||||||
* Returns a new muxer writing to a file.
|
* Returns a new muxer writing to a file.
|
||||||
*
|
*
|
||||||
* @param path The path to the output file.
|
* @param path The path to the output file.
|
||||||
* @param outputMimeType The container {@linkplain MimeTypes MIME type} of the output file.
|
* @throws IllegalArgumentException If the path is invalid.
|
||||||
* @throws IllegalArgumentException If the path is invalid or the MIME type is not supported.
|
|
||||||
* @throws IOException If an error occurs opening the output file for writing.
|
* @throws IOException If an error occurs opening the output file for writing.
|
||||||
*/
|
*/
|
||||||
Muxer create(String path, String outputMimeType) throws IOException;
|
Muxer create(String path) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new muxer writing to a file descriptor.
|
* Returns a new muxer writing to a file descriptor.
|
||||||
@ -68,25 +66,16 @@ import java.nio.ByteBuffer;
|
|||||||
* output. The file referenced by this ParcelFileDescriptor should not be used before the
|
* output. The file referenced by this ParcelFileDescriptor should not be used before the
|
||||||
* muxer is released. It is the responsibility of the caller to close the
|
* muxer is released. It is the responsibility of the caller to close the
|
||||||
* ParcelFileDescriptor. This can be done after this method returns.
|
* ParcelFileDescriptor. This can be done after this method returns.
|
||||||
* @param outputMimeType The {@linkplain MimeTypes MIME type} of the output.
|
* @throws IllegalArgumentException If the file descriptor is invalid.
|
||||||
* @throws IllegalArgumentException If the file descriptor is invalid or the MIME type is not
|
|
||||||
* supported.
|
|
||||||
* @throws IOException If an error occurs opening the output file descriptor for writing.
|
* @throws IOException If an error occurs opening the output file descriptor for writing.
|
||||||
*/
|
*/
|
||||||
Muxer create(ParcelFileDescriptor parcelFileDescriptor, String outputMimeType)
|
Muxer create(ParcelFileDescriptor parcelFileDescriptor) throws IOException;
|
||||||
throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the {@linkplain MimeTypes MIME type} provided is a supported output format.
|
|
||||||
*/
|
|
||||||
boolean supportsOutputMimeType(String mimeType);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the supported sample {@linkplain MimeTypes MIME types} for the given {@link
|
* Returns the supported sample {@linkplain MimeTypes MIME types} for the given {@link
|
||||||
* C.TrackType} and container {@linkplain MimeTypes MIME type}.
|
* C.TrackType}.
|
||||||
*/
|
*/
|
||||||
ImmutableList<String> getSupportedSampleMimeTypes(
|
ImmutableList<String> getSupportedSampleMimeTypes(@C.TrackType int trackType);
|
||||||
@C.TrackType int trackType, String containerMimeType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +51,6 @@ import java.nio.ByteBuffer;
|
|||||||
private final SparseIntArray trackTypeToSampleCount;
|
private final SparseIntArray trackTypeToSampleCount;
|
||||||
private final SparseLongArray trackTypeToTimeUs;
|
private final SparseLongArray trackTypeToTimeUs;
|
||||||
private final SparseLongArray trackTypeToBytesWritten;
|
private final SparseLongArray trackTypeToBytesWritten;
|
||||||
private final String containerMimeType;
|
|
||||||
|
|
||||||
private int trackCount;
|
private int trackCount;
|
||||||
private int trackFormatCount;
|
private int trackFormatCount;
|
||||||
@ -59,10 +58,9 @@ import java.nio.ByteBuffer;
|
|||||||
private @C.TrackType int previousTrackType;
|
private @C.TrackType int previousTrackType;
|
||||||
private long minTrackTimeUs;
|
private long minTrackTimeUs;
|
||||||
|
|
||||||
public MuxerWrapper(Muxer muxer, Muxer.Factory muxerFactory, String containerMimeType) {
|
public MuxerWrapper(Muxer muxer, Muxer.Factory muxerFactory) {
|
||||||
this.muxer = muxer;
|
this.muxer = muxer;
|
||||||
this.muxerFactory = muxerFactory;
|
this.muxerFactory = muxerFactory;
|
||||||
this.containerMimeType = containerMimeType;
|
|
||||||
|
|
||||||
trackTypeToIndex = new SparseIntArray();
|
trackTypeToIndex = new SparseIntArray();
|
||||||
trackTypeToSampleCount = new SparseIntArray();
|
trackTypeToSampleCount = new SparseIntArray();
|
||||||
@ -97,7 +95,7 @@ import java.nio.ByteBuffer;
|
|||||||
* track type}.
|
* track type}.
|
||||||
*/
|
*/
|
||||||
public ImmutableList<String> getSupportedSampleMimeTypes(@C.TrackType int trackType) {
|
public ImmutableList<String> getSupportedSampleMimeTypes(@C.TrackType int trackType) {
|
||||||
return muxerFactory.getSupportedSampleMimeTypes(trackType, containerMimeType);
|
return muxerFactory.getSupportedSampleMimeTypes(trackType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,7 +106,6 @@ public final class Transformer {
|
|||||||
private Muxer.Factory muxerFactory;
|
private Muxer.Factory muxerFactory;
|
||||||
private boolean removeAudio;
|
private boolean removeAudio;
|
||||||
private boolean removeVideo;
|
private boolean removeVideo;
|
||||||
private String containerMimeType;
|
|
||||||
private TransformationRequest transformationRequest;
|
private TransformationRequest transformationRequest;
|
||||||
private ImmutableList<Effect> videoEffects;
|
private ImmutableList<Effect> videoEffects;
|
||||||
private FrameProcessor.Factory frameProcessorFactory;
|
private FrameProcessor.Factory frameProcessorFactory;
|
||||||
@ -131,7 +130,6 @@ public final class Transformer {
|
|||||||
encoderFactory = new DefaultEncoderFactory.Builder(this.context).build();
|
encoderFactory = new DefaultEncoderFactory.Builder(this.context).build();
|
||||||
decoderFactory = new DefaultDecoderFactory(this.context);
|
decoderFactory = new DefaultDecoderFactory(this.context);
|
||||||
debugViewProvider = DebugViewProvider.NONE;
|
debugViewProvider = DebugViewProvider.NONE;
|
||||||
containerMimeType = MimeTypes.VIDEO_MP4;
|
|
||||||
transformationRequest = new TransformationRequest.Builder().build();
|
transformationRequest = new TransformationRequest.Builder().build();
|
||||||
videoEffects = ImmutableList.of();
|
videoEffects = ImmutableList.of();
|
||||||
frameProcessorFactory = new GlEffectsFrameProcessor.Factory();
|
frameProcessorFactory = new GlEffectsFrameProcessor.Factory();
|
||||||
@ -144,7 +142,6 @@ public final class Transformer {
|
|||||||
this.muxerFactory = transformer.muxerFactory;
|
this.muxerFactory = transformer.muxerFactory;
|
||||||
this.removeAudio = transformer.removeAudio;
|
this.removeAudio = transformer.removeAudio;
|
||||||
this.removeVideo = transformer.removeVideo;
|
this.removeVideo = transformer.removeVideo;
|
||||||
this.containerMimeType = transformer.containerMimeType;
|
|
||||||
this.transformationRequest = transformer.transformationRequest;
|
this.transformationRequest = transformer.transformationRequest;
|
||||||
this.videoEffects = transformer.videoEffects;
|
this.videoEffects = transformer.videoEffects;
|
||||||
this.frameProcessorFactory = transformer.frameProcessorFactory;
|
this.frameProcessorFactory = transformer.frameProcessorFactory;
|
||||||
@ -276,17 +273,6 @@ public final class Transformer {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This feature will be removed in a following release and the MIME type of the
|
|
||||||
* output will always be MP4.
|
|
||||||
*/
|
|
||||||
@CanIgnoreReturnValue
|
|
||||||
@Deprecated
|
|
||||||
public Builder setOutputMimeType(String outputMimeType) {
|
|
||||||
this.containerMimeType = outputMimeType;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #addListener(Listener)}, {@link #removeListener(Listener)} or {@link
|
* @deprecated Use {@link #addListener(Listener)}, {@link #removeListener(Listener)} or {@link
|
||||||
* #removeAllListeners()} instead.
|
* #removeAllListeners()} instead.
|
||||||
@ -454,9 +440,6 @@ public final class Transformer {
|
|||||||
}
|
}
|
||||||
mediaSourceFactory = new DefaultMediaSourceFactory(context, defaultExtractorsFactory);
|
mediaSourceFactory = new DefaultMediaSourceFactory(context, defaultExtractorsFactory);
|
||||||
}
|
}
|
||||||
checkState(
|
|
||||||
muxerFactory.supportsOutputMimeType(containerMimeType),
|
|
||||||
"Unsupported container MIME type: " + containerMimeType);
|
|
||||||
if (transformationRequest.audioMimeType != null) {
|
if (transformationRequest.audioMimeType != null) {
|
||||||
checkSampleMimeType(transformationRequest.audioMimeType);
|
checkSampleMimeType(transformationRequest.audioMimeType);
|
||||||
}
|
}
|
||||||
@ -469,7 +452,6 @@ public final class Transformer {
|
|||||||
muxerFactory,
|
muxerFactory,
|
||||||
removeAudio,
|
removeAudio,
|
||||||
removeVideo,
|
removeVideo,
|
||||||
containerMimeType,
|
|
||||||
transformationRequest,
|
transformationRequest,
|
||||||
videoEffects,
|
videoEffects,
|
||||||
frameProcessorFactory,
|
frameProcessorFactory,
|
||||||
@ -484,13 +466,9 @@ public final class Transformer {
|
|||||||
private void checkSampleMimeType(String sampleMimeType) {
|
private void checkSampleMimeType(String sampleMimeType) {
|
||||||
checkState(
|
checkState(
|
||||||
muxerFactory
|
muxerFactory
|
||||||
.getSupportedSampleMimeTypes(
|
.getSupportedSampleMimeTypes(MimeTypes.getTrackType(sampleMimeType))
|
||||||
MimeTypes.getTrackType(sampleMimeType), containerMimeType)
|
|
||||||
.contains(sampleMimeType),
|
.contains(sampleMimeType),
|
||||||
"Unsupported sample MIME type "
|
"Unsupported sample MIME type " + sampleMimeType);
|
||||||
+ sampleMimeType
|
|
||||||
+ " for container MIME type "
|
|
||||||
+ containerMimeType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,7 +560,6 @@ public final class Transformer {
|
|||||||
private final Muxer.Factory muxerFactory;
|
private final Muxer.Factory muxerFactory;
|
||||||
private final boolean removeAudio;
|
private final boolean removeAudio;
|
||||||
private final boolean removeVideo;
|
private final boolean removeVideo;
|
||||||
private final String containerMimeType;
|
|
||||||
private final TransformationRequest transformationRequest;
|
private final TransformationRequest transformationRequest;
|
||||||
private final ImmutableList<Effect> videoEffects;
|
private final ImmutableList<Effect> videoEffects;
|
||||||
private final FrameProcessor.Factory frameProcessorFactory;
|
private final FrameProcessor.Factory frameProcessorFactory;
|
||||||
@ -606,7 +583,6 @@ public final class Transformer {
|
|||||||
Muxer.Factory muxerFactory,
|
Muxer.Factory muxerFactory,
|
||||||
boolean removeAudio,
|
boolean removeAudio,
|
||||||
boolean removeVideo,
|
boolean removeVideo,
|
||||||
String containerMimeType,
|
|
||||||
TransformationRequest transformationRequest,
|
TransformationRequest transformationRequest,
|
||||||
ImmutableList<Effect> videoEffects,
|
ImmutableList<Effect> videoEffects,
|
||||||
FrameProcessor.Factory frameProcessorFactory,
|
FrameProcessor.Factory frameProcessorFactory,
|
||||||
@ -622,7 +598,6 @@ public final class Transformer {
|
|||||||
this.muxerFactory = muxerFactory;
|
this.muxerFactory = muxerFactory;
|
||||||
this.removeAudio = removeAudio;
|
this.removeAudio = removeAudio;
|
||||||
this.removeVideo = removeVideo;
|
this.removeVideo = removeVideo;
|
||||||
this.containerMimeType = containerMimeType;
|
|
||||||
this.transformationRequest = transformationRequest;
|
this.transformationRequest = transformationRequest;
|
||||||
this.videoEffects = videoEffects;
|
this.videoEffects = videoEffects;
|
||||||
this.frameProcessorFactory = frameProcessorFactory;
|
this.frameProcessorFactory = frameProcessorFactory;
|
||||||
@ -711,7 +686,7 @@ public final class Transformer {
|
|||||||
}
|
}
|
||||||
this.outputPath = path;
|
this.outputPath = path;
|
||||||
this.outputParcelFileDescriptor = null;
|
this.outputParcelFileDescriptor = null;
|
||||||
startTransformation(mediaItem, muxerFactory.create(path, containerMimeType));
|
startTransformation(mediaItem, muxerFactory.create(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -741,7 +716,7 @@ public final class Transformer {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
this.outputParcelFileDescriptor = parcelFileDescriptor;
|
this.outputParcelFileDescriptor = parcelFileDescriptor;
|
||||||
this.outputPath = null;
|
this.outputPath = null;
|
||||||
startTransformation(mediaItem, muxerFactory.create(parcelFileDescriptor, containerMimeType));
|
startTransformation(mediaItem, muxerFactory.create(parcelFileDescriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startTransformation(MediaItem mediaItem, Muxer muxer) {
|
private void startTransformation(MediaItem mediaItem, Muxer muxer) {
|
||||||
@ -749,7 +724,7 @@ public final class Transformer {
|
|||||||
if (player != null) {
|
if (player != null) {
|
||||||
throw new IllegalStateException("There is already a transformation in progress.");
|
throw new IllegalStateException("There is already a transformation in progress.");
|
||||||
}
|
}
|
||||||
MuxerWrapper muxerWrapper = new MuxerWrapper(muxer, muxerFactory, containerMimeType);
|
MuxerWrapper muxerWrapper = new MuxerWrapper(muxer, muxerFactory);
|
||||||
this.muxerWrapper = muxerWrapper;
|
this.muxerWrapper = muxerWrapper;
|
||||||
DefaultTrackSelector trackSelector = new DefaultTrackSelector(context);
|
DefaultTrackSelector trackSelector = new DefaultTrackSelector(context);
|
||||||
trackSelector.setParameters(
|
trackSelector.setParameters(
|
||||||
|
@ -35,11 +35,9 @@ public final class TestMuxer implements Muxer, Dumper.Dumpable {
|
|||||||
private final List<Dumper.Dumpable> dumpables;
|
private final List<Dumper.Dumpable> dumpables;
|
||||||
|
|
||||||
/** Creates a new test muxer. */
|
/** Creates a new test muxer. */
|
||||||
public TestMuxer(String path, String outputMimeType, Muxer.Factory muxerFactory)
|
public TestMuxer(String path, Muxer.Factory muxerFactory) throws IOException {
|
||||||
throws IOException {
|
muxer = muxerFactory.create(path);
|
||||||
muxer = muxerFactory.create(path, outputMimeType);
|
|
||||||
dumpables = new ArrayList<>();
|
dumpables = new ArrayList<>();
|
||||||
dumpables.add(dumper -> dumper.add("containerMimeType", outputMimeType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Muxer implementation.
|
// Muxer implementation.
|
||||||
|
@ -29,15 +29,6 @@ import org.junit.runner.RunWith;
|
|||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class TransformerBuilderTest {
|
public class TransformerBuilderTest {
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setOutputMimeType_unsupportedMimeType_throws() {
|
|
||||||
Context context = ApplicationProvider.getApplicationContext();
|
|
||||||
|
|
||||||
assertThrows(
|
|
||||||
IllegalStateException.class,
|
|
||||||
() -> new Transformer.Builder(context).setOutputMimeType(MimeTypes.VIDEO_UNKNOWN).build());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void build_removeAudioAndVideo_throws() {
|
public void build_removeAudioAndVideo_throws() {
|
||||||
Context context = ApplicationProvider.getApplicationContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
|
@ -863,28 +863,20 @@ public final class TransformerEndToEndTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Muxer create(String path, String outputMimeType) throws IOException {
|
public Muxer create(String path) throws IOException {
|
||||||
testMuxer = new TestMuxer(path, outputMimeType, defaultMuxerFactory);
|
testMuxer = new TestMuxer(path, defaultMuxerFactory);
|
||||||
return testMuxer;
|
return testMuxer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Muxer create(ParcelFileDescriptor parcelFileDescriptor, String outputMimeType)
|
public Muxer create(ParcelFileDescriptor parcelFileDescriptor) throws IOException {
|
||||||
throws IOException {
|
testMuxer = new TestMuxer("FD:" + parcelFileDescriptor.getFd(), defaultMuxerFactory);
|
||||||
testMuxer =
|
|
||||||
new TestMuxer("FD:" + parcelFileDescriptor.getFd(), outputMimeType, defaultMuxerFactory);
|
|
||||||
return testMuxer;
|
return testMuxer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsOutputMimeType(String mimeType) {
|
public ImmutableList<String> getSupportedSampleMimeTypes(@C.TrackType int trackType) {
|
||||||
return true;
|
return defaultMuxerFactory.getSupportedSampleMimeTypes(trackType);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ImmutableList<String> getSupportedSampleMimeTypes(
|
|
||||||
@C.TrackType int trackType, String containerMimeType) {
|
|
||||||
return defaultMuxerFactory.getSupportedSampleMimeTypes(trackType, containerMimeType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
format 0:
|
||||||
sampleMimeType = audio/mp4a-latm
|
sampleMimeType = audio/mp4a-latm
|
||||||
channelCount = 1
|
channelCount = 1
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
format 0:
|
||||||
sampleMimeType = audio/3gpp
|
sampleMimeType = audio/3gpp
|
||||||
maxInputSize = 61
|
maxInputSize = 61
|
||||||
|
@ -1,193 +0,0 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
|
||||||
id = 1
|
|
||||||
sampleMimeType = video/avc
|
|
||||||
codecs = avc1.640034
|
|
||||||
width = 1080
|
|
||||||
height = 720
|
|
||||||
selectionFlags = 1
|
|
||||||
language = und
|
|
||||||
initializationData:
|
|
||||||
data = length 30, hash F6F3D010
|
|
||||||
data = length 10, hash 7A0D0F2B
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -252482306
|
|
||||||
size = 36477
|
|
||||||
isKeyFrame = true
|
|
||||||
presentationTimeUs = 67000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 67864034
|
|
||||||
size = 5341
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 134000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 897273234
|
|
||||||
size = 596
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 100000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -1549870586
|
|
||||||
size = 7704
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 267000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 672384813
|
|
||||||
size = 989
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 200000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -988996493
|
|
||||||
size = 721
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 167000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 1711151377
|
|
||||||
size = 519
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 234000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -506806036
|
|
||||||
size = 6160
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 400000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 1902167649
|
|
||||||
size = 953
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 334000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 2054873212
|
|
||||||
size = 620
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 300000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 1556608231
|
|
||||||
size = 405
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 367000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -1648978019
|
|
||||||
size = 4852
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 500000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -484808327
|
|
||||||
size = 547
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 467000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -20706048
|
|
||||||
size = 570
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 434000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 2085064574
|
|
||||||
size = 5525
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 634000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -637074022
|
|
||||||
size = 1082
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 567000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -1824027029
|
|
||||||
size = 807
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 534000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -1701945306
|
|
||||||
size = 744
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 600000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -952425536
|
|
||||||
size = 4732
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 767000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -1978031576
|
|
||||||
size = 1004
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 700000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -2128215508
|
|
||||||
size = 794
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 667000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -259850011
|
|
||||||
size = 645
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 734000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 1920983928
|
|
||||||
size = 2684
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 900000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 1100642337
|
|
||||||
size = 787
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 834000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 1544917830
|
|
||||||
size = 649
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 800000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -116205995
|
|
||||||
size = 509
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 867000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = 696343585
|
|
||||||
size = 1226
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 1034000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -644371190
|
|
||||||
size = 898
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 967000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -1606273467
|
|
||||||
size = 476
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 934000
|
|
||||||
sample:
|
|
||||||
trackIndex = 0
|
|
||||||
dataHashCode = -571265861
|
|
||||||
size = 486
|
|
||||||
isKeyFrame = false
|
|
||||||
presentationTimeUs = 1000000
|
|
||||||
released = true
|
|
@ -1,4 +1,3 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
format 0:
|
||||||
sampleMimeType = audio/mp4a-latm
|
sampleMimeType = audio/mp4a-latm
|
||||||
channelCount = 1
|
channelCount = 1
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
format 0:
|
||||||
peakBitrate = 200000
|
peakBitrate = 200000
|
||||||
id = 2
|
id = 2
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
format 0:
|
||||||
id = 1
|
id = 1
|
||||||
sampleMimeType = video/avc
|
sampleMimeType = video/avc
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
format 0:
|
||||||
peakBitrate = 200000
|
peakBitrate = 200000
|
||||||
id = 2
|
id = 2
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
format 0:
|
||||||
id = 1
|
id = 1
|
||||||
sampleMimeType = video/avc
|
sampleMimeType = video/avc
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
format 0:
|
||||||
sampleMimeType = audio/mp4a-latm
|
sampleMimeType = audio/mp4a-latm
|
||||||
channelCount = 6
|
channelCount = 6
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
format 0:
|
||||||
sampleMimeType = audio/mp4a-latm
|
sampleMimeType = audio/mp4a-latm
|
||||||
channelCount = 2
|
channelCount = 2
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
containerMimeType = video/mp4
|
|
||||||
format 0:
|
format 0:
|
||||||
averageBitrate = 192181
|
averageBitrate = 192181
|
||||||
peakBitrate = 192181
|
peakBitrate = 192181
|
||||||
|
Loading…
x
Reference in New Issue
Block a user