fix min size for compression (#5272)
parent
24b07c6cf4
commit
f943239894
|
@ -1,11 +1,11 @@
|
||||||
import {getVideoMetaData, Video} from 'react-native-compressor'
|
import {getVideoMetaData, Video} from 'react-native-compressor'
|
||||||
import {ImagePickerAsset} from 'expo-image-picker'
|
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 {extToMime} from '#/state/queries/video/util'
|
||||||
import {CompressedVideo} from './types'
|
import {CompressedVideo} from './types'
|
||||||
|
|
||||||
// const MIN_SIZE_FOR_COMPRESSION = 1024 * 1024 * 25 // 25mb
|
const MIN_SIZE_FOR_COMPRESSION = 25 // 25mb
|
||||||
|
|
||||||
export async function compressVideo(
|
export async function compressVideo(
|
||||||
file: ImagePickerAsset,
|
file: ImagePickerAsset,
|
||||||
|
@ -16,13 +16,13 @@ export async function compressVideo(
|
||||||
): Promise<CompressedVideo> {
|
): Promise<CompressedVideo> {
|
||||||
const {onProgress, signal} = opts || {}
|
const {onProgress, signal} = opts || {}
|
||||||
|
|
||||||
// const isAcceptableFormat = SUPPORTED_MIME_TYPES.includes(
|
const isAcceptableFormat = SUPPORTED_MIME_TYPES.includes(
|
||||||
// file.mimeType as SupportedMimeTypes,
|
file.mimeType as SupportedMimeTypes,
|
||||||
// )
|
)
|
||||||
|
|
||||||
// const minimumFileSizeForCompress = isAcceptableFormat
|
const minimumFileSizeForCompress = isAcceptableFormat
|
||||||
// ? MIN_SIZE_FOR_COMPRESSION
|
? MIN_SIZE_FOR_COMPRESSION
|
||||||
// : 0
|
: 0
|
||||||
|
|
||||||
const compressed = await Video.compress(
|
const compressed = await Video.compress(
|
||||||
file.uri,
|
file.uri,
|
||||||
|
@ -30,7 +30,8 @@ export async function compressVideo(
|
||||||
compressionMethod: 'manual',
|
compressionMethod: 'manual',
|
||||||
bitrate: 3_000_000, // 3mbps
|
bitrate: 3_000_000, // 3mbps
|
||||||
maxSize: 1920,
|
maxSize: 1920,
|
||||||
// minimumFileSizeForCompress,
|
// WARNING: this ONE SPECIFIC ARG is in MB -sfn
|
||||||
|
minimumFileSizeForCompress,
|
||||||
getCancellationId: id => {
|
getCancellationId: id => {
|
||||||
if (signal) {
|
if (signal) {
|
||||||
signal.addEventListener('abort', () => {
|
signal.addEventListener('abort', () => {
|
||||||
|
|
Loading…
Reference in New Issue