Read optional video display dimensions.
Add RequiresApi annotations. Fixes #8982
This commit is contained in:
parent
c4a4374465
commit
1bd1e9cc65
2 changed files with 15 additions and 4 deletions
|
@ -139,6 +139,7 @@ public final class MediaConverter {
|
|||
}
|
||||
|
||||
@WorkerThread
|
||||
@RequiresApi(23)
|
||||
public void convert() throws EncodingException, IOException {
|
||||
// Exception that may be thrown during release.
|
||||
Exception exception = null;
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.view.Surface;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
|
||||
|
@ -27,6 +28,9 @@ final class VideoTrackConverter {
|
|||
|
||||
private static final int TIMEOUT_USEC = 10000;
|
||||
|
||||
private static final String MEDIA_FORMAT_KEY_DISPLAY_WIDTH = "display-width";
|
||||
private static final String MEDIA_FORMAT_KEY_DISPLAY_HEIGHT = "display-height";
|
||||
|
||||
private final long mTimeFrom;
|
||||
private final long mTimeTo;
|
||||
|
||||
|
@ -60,8 +64,8 @@ final class VideoTrackConverter {
|
|||
|
||||
private Muxer mMuxer;
|
||||
|
||||
static @Nullable
|
||||
VideoTrackConverter create(
|
||||
@RequiresApi(23)
|
||||
static @Nullable VideoTrackConverter create(
|
||||
final @NonNull MediaConverter.Input input,
|
||||
final long timeFrom,
|
||||
final long timeTo,
|
||||
|
@ -78,6 +82,8 @@ final class VideoTrackConverter {
|
|||
return new VideoTrackConverter(videoExtractor, videoInputTrack, timeFrom, timeTo, videoResolution, videoBitrate, videoCodec);
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(23)
|
||||
private VideoTrackConverter(
|
||||
final @NonNull MediaExtractor videoExtractor,
|
||||
final int videoInputTrack,
|
||||
|
@ -104,8 +110,12 @@ final class VideoTrackConverter {
|
|||
mInputDuration = inputVideoFormat.containsKey(MediaFormat.KEY_DURATION) ? inputVideoFormat.getLong(MediaFormat.KEY_DURATION) : 0;
|
||||
|
||||
final int rotation = inputVideoFormat.containsKey(MediaFormat.KEY_ROTATION) ? inputVideoFormat.getInteger(MediaFormat.KEY_ROTATION) : 0;
|
||||
final int width = inputVideoFormat.getInteger(MediaFormat.KEY_WIDTH);
|
||||
final int height = inputVideoFormat.getInteger(MediaFormat.KEY_HEIGHT);
|
||||
final int width = inputVideoFormat.containsKey(MEDIA_FORMAT_KEY_DISPLAY_WIDTH)
|
||||
? inputVideoFormat.getInteger(MEDIA_FORMAT_KEY_DISPLAY_WIDTH)
|
||||
: inputVideoFormat.getInteger(MediaFormat.KEY_WIDTH);
|
||||
final int height = inputVideoFormat.containsKey(MEDIA_FORMAT_KEY_DISPLAY_HEIGHT)
|
||||
? inputVideoFormat.getInteger(MEDIA_FORMAT_KEY_DISPLAY_HEIGHT)
|
||||
: inputVideoFormat.getInteger(MediaFormat.KEY_HEIGHT);
|
||||
int outputWidth = width;
|
||||
int outputHeight = height;
|
||||
if (outputWidth < outputHeight) {
|
||||
|
|
Loading…
Add table
Reference in a new issue