2

实际上,我ffmpeg-kit在 react native 项目中用于多种目的,例如在水平方向合并两个,修剪,从视频中获取音频等。所以我首先创建本地路径,然后将其传递给 ffmpeg 命令,现在我想获取编码文件的实际 Url 让我给你看我的代码:

    const _makeDuet = async (firstVideo, secondVideo) => {
        // console.log(firstVideo,secondVideo)
        setmodalvisible(true)
        const path = `${RNFS.MainBundlePath}`
        let filepath = RNFS.ExternalDirectoryPath + '/panting_duet' + Date.now() + '.mp4'

        let cmd2 = `-i ${secondVideo} -i ${secondVideo} -filter_complex [0:v][1:v]hstack=inputs=2:shortest=1[outv]  -r 25 -b:v 8M -minrate 6M -maxrate 8M -bufsize 4M  -map 1:a -shortest -map [outv] ${filepath}`


        // const path = `${RNFS.MainBundlePath}/intro.mp4`
        // let filepath = RNFS.ExternalStorageDirectoryPath+'/panting_videos'+Date.now()+'.mp3'
        // let mkdir = RNFS.mkdir("panting")


        // console.log(filepath)


        await FFmpegKit.executeAsync(cmd2, async (session) => {
            const returnCode = await session.getReturnCode();
            if (ReturnCode.isSuccess(returnCode)) {
                console.log('Success')
                // SUCCESS
                console.log(session)
                setmodalvisible(false)
                props.navigation.navigate('DuetDetails', { filepath });

            } else if (ReturnCode.isCancel(returnCode)) {

                // CANCEL
                console.log('cancle by user')
                setmodalvisible(false)

            } else {

                // ERROR
                console.log('error')
                setmodalvisible(false)

            }
        })

其次,有没有办法ffmpeg像从firebase存储一样在命令远程url中编码/传递输入文件?

4

0 回答 0