diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-09-11 18:50:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-11 18:50:36 +0100 |
commit | f943239894477cf66340b86672b18d9550e29871 (patch) | |
tree | 6c494d5f20f1950fde49fc8f5cf7157be1dbf672 /src | |
parent | 24b07c6cf495367acfcf6a3f44a841e8f355d08f (diff) | |
download | voidsky-f943239894477cf66340b86672b18d9550e29871.tar.zst |
fix min size for compression (#5272)
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/media/video/compress.ts | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/lib/media/video/compress.ts b/src/lib/media/video/compress.ts index d2d51f9b4..dec9032a3 100644 --- a/src/lib/media/video/compress.ts +++ b/src/lib/media/video/compress.ts @@ -1,11 +1,11 @@ import {getVideoMetaData, Video} from 'react-native-compressor' import {ImagePickerAsset} from 'expo-image-picker' -// import {SUPPORTED_MIME_TYPES, SupportedMimeTypes} from '#/lib/constants' +import {SUPPORTED_MIME_TYPES, SupportedMimeTypes} from '#/lib/constants' import {extToMime} from '#/state/queries/video/util' import {CompressedVideo} from './types' -// const MIN_SIZE_FOR_COMPRESSION = 1024 * 1024 * 25 // 25mb +const MIN_SIZE_FOR_COMPRESSION = 25 // 25mb export async function compressVideo( file: ImagePickerAsset, @@ -16,13 +16,13 @@ export async function compressVideo( ): Promise<CompressedVideo> { const {onProgress, signal} = opts || {} - // const isAcceptableFormat = SUPPORTED_MIME_TYPES.includes( - // file.mimeType as SupportedMimeTypes, - // ) + const isAcceptableFormat = SUPPORTED_MIME_TYPES.includes( + file.mimeType as SupportedMimeTypes, + ) - // const minimumFileSizeForCompress = isAcceptableFormat - // ? MIN_SIZE_FOR_COMPRESSION - // : 0 + const minimumFileSizeForCompress = isAcceptableFormat + ? MIN_SIZE_FOR_COMPRESSION + : 0 const compressed = await Video.compress( file.uri, @@ -30,7 +30,8 @@ export async function compressVideo( compressionMethod: 'manual', bitrate: 3_000_000, // 3mbps maxSize: 1920, - // minimumFileSizeForCompress, + // WARNING: this ONE SPECIFIC ARG is in MB -sfn + minimumFileSizeForCompress, getCancellationId: id => { if (signal) { signal.addEventListener('abort', () => { |