aboutsummaryrefslogtreecommitdiff
path: root/src/utils/camera.ts
diff options
context:
space:
mode:
authorMichael <michael.foiani@gmail.com>2021-07-06 15:04:28 -0400
committerMichael <michael.foiani@gmail.com>2021-07-06 15:04:28 -0400
commitc44406e1da3e6fedcd1ebd03b0c62db470f4daa4 (patch)
treef4abe35f6247859743f12c8c43789284b23bffe2 /src/utils/camera.ts
parent843a9d39b99815bc232b4a105e5900f1d29535b5 (diff)
Made basic video/image compressor.
Diffstat (limited to 'src/utils/camera.ts')
-rw-r--r--src/utils/camera.ts21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/utils/camera.ts b/src/utils/camera.ts
index 85bf8d73..ccdd42b0 100644
--- a/src/utils/camera.ts
+++ b/src/utils/camera.ts
@@ -8,13 +8,10 @@ import {
TakePictureOptions,
TakePictureResponse,
} from 'react-native-camera';
-<<<<<<< HEAD
import {ProcessingManager} from 'react-native-video-processing';
-import ImagePicker, {Image, Video} from 'react-native-image-crop-picker';
-=======
import ImagePicker, {ImageOrVideo, Video} from 'react-native-image-crop-picker';
->>>>>>> master
import {ERROR_UPLOAD} from '../constants/strings';
+import RNFetchBlob from 'rn-fetch-blob';
/*
* Captures a photo and pauses to show the preview of the picture taken
@@ -72,8 +69,9 @@ export const navigateToImagePicker = (
mediaType: 'any',
})
.then((media) => {
- ProcessingManager.compress(media, options.compress) // like VideoPlayer compress options
- .then((data: any) => console.log(data));
+ const path: String = getVideoPath(media);
+ ProcessingManager.compress(path, options.compress) // like VideoPlayer compress options
+ .then((data: any) => console.log(data));
callback(media);
})
.catch((err) => {
@@ -83,13 +81,18 @@ export const navigateToImagePicker = (
});
};
+const getVideoPath = (uri) => {
+ console.log(uri);
+ return uri.path;
+};
+
export const navigateToVideoPicker = (callback: (vid: Video) => void) => {
ImagePicker.openPicker({
mediaType: 'video',
})
.then(async (vid) => {
if (vid.path) {
- ProcessingManager.compress(vid, options.compress) // like VideoPlayer compress options
+ ProcessingManager.compress(vid.path, options.compress) // like VideoPlayer compress options
.then((data: any) => console.log(data));
callback(vid);
}
@@ -103,8 +106,8 @@ export const navigateToVideoPicker = (callback: (vid: Video) => void) => {
const options = {
compress: {
- width: 720,
- height: 1280,
+ width: 1080,
+ height: 1920,
bitrateMultiplier: 3,
saveToCameraRoll: true, // default is false, iOS only
saveWithCurrentDate: true, // default is false, iOS only