mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-23 19:26:17 +00:00
Calculate video encoding settings based on trimmed duration.
This commit is contained in:
committed by
Greyson Parrelli
parent
a3438d3345
commit
6fc9055221
@@ -249,10 +249,12 @@ public final class AttachmentCompressionJob extends BaseJob {
|
||||
throw new UndeliverableMessageException("Cannot get media data source for attachment.");
|
||||
}
|
||||
|
||||
allowSkipOnFailure = !transformProperties.getVideoEdited();
|
||||
TranscoderOptions options = null;
|
||||
if (transformProperties.videoTrim) {
|
||||
options = new TranscoderOptions(transformProperties.videoTrimStartTimeUs, transformProperties.videoTrimEndTimeUs);
|
||||
if (transformProperties != null) {
|
||||
allowSkipOnFailure = !transformProperties.getVideoEdited();
|
||||
if (transformProperties.videoTrim) {
|
||||
options = new TranscoderOptions(transformProperties.videoTrimStartTimeUs, transformProperties.videoTrimEndTimeUs);
|
||||
}
|
||||
}
|
||||
|
||||
if (FeatureFlags.useStreamingVideoMuxer()) {
|
||||
|
||||
@@ -98,7 +98,7 @@ public final class VideoEditorHud extends LinearLayout {
|
||||
long size = tryGetUriSize(getContext(), uri, Long.MAX_VALUE);
|
||||
|
||||
if (size > maxSendSize) {
|
||||
videoTimeLine.setTimeLimit(VideoUtil.getMaxVideoUploadDurationInSeconds(), TimeUnit.SECONDS);
|
||||
videoTimeLine.setTimeLimit(videoBitRateCalculator.getMaxVideoUploadDurationInSeconds(), TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
videoTimeLine.setOnRangeChangeListener(new VideoThumbnailsRangeSelectorView.OnRangeChangeListener() {
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@RequiresApi(26)
|
||||
public final class InMemoryTranscoder implements Closeable {
|
||||
@@ -63,8 +64,13 @@ public final class InMemoryTranscoder implements Closeable {
|
||||
throw new VideoSourceException("Unable to read datasource", e);
|
||||
}
|
||||
|
||||
if (options != null && options.endTimeUs != 0) {
|
||||
this.duration = TimeUnit.MICROSECONDS.toMillis(options.endTimeUs - options.startTimeUs);
|
||||
} else {
|
||||
this.duration = getDuration(mediaMetadataRetriever);
|
||||
}
|
||||
|
||||
this.inSize = dataSource.getSize();
|
||||
this.duration = getDuration(mediaMetadataRetriever);
|
||||
this.inputBitRate = VideoBitRateCalculator.bitRate(inSize, duration);
|
||||
this.targetQuality = new VideoBitRateCalculator(upperSizeLimit).getTargetQuality(duration, inputBitRate);
|
||||
this.upperSizeLimit = upperSizeLimit;
|
||||
|
||||
@@ -29,10 +29,6 @@ public final class VideoUtil {
|
||||
return Math.min(duration, VideoConstants.VIDEO_MAX_RECORD_LENGTH_S);
|
||||
}
|
||||
|
||||
public static int getMaxVideoUploadDurationInSeconds() {
|
||||
return Math.toIntExact(TimeUnit.MINUTES.toSeconds(10));
|
||||
}
|
||||
|
||||
private static Size screenSize() {
|
||||
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
|
||||
return new Size(metrics.widthPixels, metrics.heightPixels);
|
||||
|
||||
Reference in New Issue
Block a user