Open hy21116 opened 3 years ago
react-native-video-processing
const compressVideo
밑의 시도들은 const compressVideo 함수에 대한 것.
const uploadSolution = async () => { const { uri, fileName } = media const response = await fetch(uri) const blob = await response.blob() const uploadFile = isImageType ? blob : compressVideo(uri) ..........
const compressVideo = async (uri) => { console.log('==================') console.log(uri) console.log('==================') const origin = await ProcessingManager.getVideoInfo(uri) console.log('==================') console.log(origin) console.log('==================') try { const compressed = await ProcessingManager.compress(uri, { width: origin.size && origin.size.width / 3, height: origin.size && origin.size.height / 3, bitrateMultiplier: 7, minimumBitrate: 300000, }) } catch (e) { console.error(e) } return compressed.source }
compress error
react-native-fs
import * as RNFS from 'react-native-fs' ... const compressVideo = async (uri) => { const path = await RNFS.copyFile(uri, path) console.log('==================') console.log(uri) console.log(path) console.log('==================') const origin = await ProcessingManager.getVideoInfo(uri) console.log('==================') console.log(origin) console.log('==================') try { const compressed = await ProcessingManager.compress(path, { width: origin.size && origin.size.width / 3, height: origin.size && origin.size.height / 3, bitrateMultiplier: 7, minimumBitrate: 300000, }) } catch (e) { console.error(e) } return compressed.source }
RNFS
path = uri.replace('content', 'file')
[issue] 압축 삽질 무한궤도
react-native-video-processing
라이브러리 적용const compressVideo
함수 구현하여 uploadSolution 함수에서 다음과 같이 받아옴.밑의 시도들은
const compressVideo
함수에 대한 것.compress error
는 열심히 이슈를 뒤져보니 emulator 문제일 가능성. 따라서 핸드폰에 직접 빌드하여 실행!react-native-fs
라는 것을 이용해 content uri를 file uri로 바꿔서 시도RNFS
에서 에러난듯path = uri.replace('content', 'file')