tanersener / react-native-ffmpeg

FFmpeg for react-native. Not maintained anymore. Superseded by FFmpegKit.
GNU General Public License v3.0
401 stars 52 forks source link

No such file or directory error getting even i a able to play the files #185

Closed nivas412 closed 4 years ago

nivas412 commented 4 years ago

Description I am trying to mix the video and audio but what I am getting no such file or directory even I am able to play those files with audio and video player getting this error. I have tried many ways like 'file://', 'file:///', remove completely file fro this but getting the same error.

Expected behavior video and audio should mix together

Current behavior No such file or directory

Screenshots image

image

Logs The above screenshots provided for the logs please check

Environment "react": "16.13.1", "react-native": "0.63.1", "react-native-ffmpeg": "^0.4.4",

I am using full package in android/build.gradle reactNativeFFmpegPackage = "full"

Other I think is it saying the files which I provided not found anything else plz let me know what's the exact issue

Note: I am able to extract the audio from video with the same FFmpeg package

sample code is given below:


  const { config, fs } = RNFetchBlob;
        // alert(config);
        let PictureDir = Platform.OS === 'ios' ? fs.dirs.PictureDir : fs.dirs.PictureDir;
        alert(PictureDir);
        const date = new Date();
        const finalisedVideo =  PictureDir + '/sample.mp4'; //'file://data/user/0/com.febbler/files/RNFetchBlobTmp_d4eq66i66k9zw8i4prwi5s.mp4';
        // '-i ' + this.state.videoUrl + ' - i ' + this.state.audioUrl + ' -c:v copy -c:a aac ' + finalisedVideo
        RNFFmpeg.execute('-i ' + this.state.videoUrl + ' - i ' + this.state.audioUrl + ' -c:v copy -c:a aac ' + finalisedVideo).then(result => {
            // -i video.mp4 -i audio.wav -c:v copy -c:a aac output.mp4 
            AsyncStorage.setItem('finalVideo', finalisedVideo);
            RNFFmpegConfig.getLastCommandOutput().then(result => {
                alert("Last command output: " + JSON.stringify(result.lastCommandOutput));
            });
            // this.props.navigation.navigate('videoDemo', {
            //     'videoUrl': finalisedVideo,
            //     'audioUrl': this.state.audioUrl
            // });
        });
nivas412 commented 4 years ago

It worked with this commands


        // const videoPath = await AsyncStorage.setItem('videoPath', this.state.videoUrl);
            const date = new Date();
            let videoPath = this.state.videoUrl.replace("file://", "");
            const finalisedVideo = '/data/user/0/com.febbler/files/' + Math.floor(date.getTime() + date.getSeconds() / 2) + '.mp4';
            RNFFmpeg.execute('-i ' + videoPath + ' -i ' + this.state.audioUrl + ' ' + finalisedVideo).then(result => {
                // -i ' + this.state.videoUrl + ' -i ' + this.state.audioUrl + ' -map 0:v -map 1:a -c copy -y ' + finalisedVideo
                AsyncStorage.setItem('finalVideo', finalisedVideo);
                RNFFmpegConfig.getLastCommandOutput().then(result => {
                    alert("Last command output: " + JSON.stringify(result.lastCommandOutput));
                });
                // this.props.navigation.navigate('videoDemo', {
                //     'videoUrl': finalisedVideo,
                //     'audioUrl': this.state.audioUrl
                // });
            });