shahen94 / react-native-video-processing

Native Video editing/trimming/compressing :movie_camera: library for React-Native
https://shahen94.github.io/react-native-video-processing/
MIT License
1.25k stars 327 forks source link

Android compression throw error : {"framesToPop":1,"code":"EUNSPECIFIED"} #173

Open DalalAbadi opened 6 years ago

DalalAbadi commented 6 years ago

I am trying to compress videos it's work fine with iOS but Android throw{"framesToPop":1,"code":"EUNSPECIFIED"}

Bellow my code:

     ProcessingManager.compress(this.state.videoPath, options) 
    .then((newSource) =>{

    }).catch(console.warn);

Your Environment

software version
react-native-video-processing 1.13.0
react-native 0.53.3
shenyuanqing commented 6 years ago

+1,i have the same problem

shenyuanqing commented 6 years ago

react-native-video-processing v1.13.0,react-native v0.54.2, android 5、6、8 all have this problem

djleonskennedy commented 6 years ago

Hello guys it's critical issue !

MohammadFakhreddin commented 5 years ago

Hello guys ,I did a few tricks to avoid this issue I hope it helps ` const videoTrimOptions = () => { return { startTime: 0, endTime: 30 } }

const videoCompressOptions = () => { return { // width: 360, // height: 640, bitrateMultiplier: 3, // saveToCameraRoll: false, // default is false, iOS only // saveWithCurrentDate: false, // default is false, iOS only minimumBitrate: 300000 // removeAudio: false // default is false } }

export interface IVideoProcessOutput { uri?: string, error?: any }

export class VideoProcessHelper { public static trimAndCompressForUpload(uri: string): Promise { return new Promise(async (resolve) => { if (CommonValidator.isNullOrEmpty(uri)) { resolve({uri: null, error: 'Uri is empty'}) return } let trimmedSource: string = null try { uri = FileHelper.getImagePickerFileAddress(uri) trimmedSource = await ProcessingManager.trim(uri, videoTrimOptions()) } catch (exception) { Logger.warn(exception) resolve({ error: exception }) return } if (CommonValidator.isNullOrEmpty(trimmedSource)) { resolve({error: 'Trim result is empty'}) return } trimmedSource = FileHelper.getImagePickerFileAddress(trimmedSource) if (CommonValidator.isNullOrEmpty(trimmedSource)) { resolve({uri}) return } try { const compressedSource = await ProcessingManager.compress(trimmedSource, videoCompressOptions()) if (CommonValidator.isNullOrEmpty(compressedSource)) { resolve({ uri: trimmedSource }) return } resolve({ uri: FileHelper.getImagePickerFileAddress(compressedSource) }) } catch (exception) { Logger.warn(exception) resolve({ error: exception }) return } }) } } And getImagePickerFileAddress is: public static getImagePickerFileAddress = (path: string): string => { return (EnvironmentVariables.isIos) ? path.replace('file://', '') : path }`

Now it works correctly in both android and ios ,Although it takes lots of time in android and you need a timeout

farnabaz commented 5 years ago

In my case, it was URI issue, library pass source path directly to FFmpeg and FFmpeg does not soppurt content:// or 'file://` or other protocols

Issue solved by converting URI to real path, I use react-native-get-real-path to convert uri

yogeshchoudhary147 commented 5 years ago

Hi @farnabaz

I am stuck at same problem. Can you please tell me what exactly needs to be passed as source here. This is what I am doing and getting same error.

const source ={"uri":"content://com.android.providers.media.documents/document/video%3A160","fileSize":10498677,"fileName":"SampleVideo_1280x720_10mb-1.mp4","type":"video/mp4"}

I am using react-native-document-picker to pick video.

const options = {bitrateMultiplier: 3, minimumBitrate: 300000};

ProcessingManager.compress(source, options).

Thanks in advance