簡體   English   中英

在 ReactNative “concat imposible to open”中使用 ffmpeg concat 出現此錯誤

[英]Getting this error using ffmpeg concat in ReactNative “concat imposible to open”

嗨,我正在嘗試使用 ffmpeg concat 連接多個視頻,在 samsung j76、android 版本 8.1.0 上進行測試

const textFile = await (await writeTextFileWithAllVideoFiles(filePaths))  
const outputPath = Platform.OS === 'ios' ? `${RNFS.DocumentDirectoryPath}/video-1.mp4` : `${RNFS.DocumentDirectoryPath}/video-1.mp4`
console.log(`-f concat -safe 0 -i ${textFile} -c copy ${outputPath}`)
const result = await RNFFmpeg.execute(`-f concat -safe 0 -i ${textFile} -c copy ${outputPath}`)

這是我創建 txt 文件的方式

const writeTextFileWithAllVideoFiles = async (filePaths) => {
var RNFS = require('react-native-fs');
var path = RNFS.DocumentDirectoryPath + '/videoList.txt';

var fileContent = ''
console.log("fileplay1");
filePaths.forEach(path => {
   fileContent += 'file ' + '\'' + path.substring(8) + '\'' + '\r\n'
});
console.log(fileContent);
return RNFS.writeFile(path, fileContent, 'utf8')
.then((success) => {
   console.log(path)
   if (RNFS.exists(path))
      console.log('FILE WRITTEN!')
   return path
})
.catch((err) => {
    console.log(err.message)
    return err.message
});  
}

這是我的控制台日志 output

file 'data/user/0/com.videoeditorapp/cache/Camera/f27579d2-1488-4a59-8a9d-7a4e7b6fe716.mp4'
file 'data/user/0/com.videoeditorapp/cache/Camera/58130175-bd20-4002-9629-070d0cdd18ac.mp4'

[Tue Feb 02 2021 16:30:45.375]  LOG      /data/user/0/com.videoeditorapp/files/videoList.txt
[Tue Feb 02 2021 16:30:45.376]  LOG      FILE WRITTEN!
[Tue Feb 02 2021 16:30:45.376]  LOG      -f concat -safe 0 -i /data/user/0/com.videoeditorapp/files/videoList.txt -c copy /data/user/0/com.videoeditorapp/files/video-1.mp4
[Tue Feb 02 2021 16:30:45.376]  LOG      [concat @ 0xe2b22000] Impossible to open '/data/user/0/com.videoeditorapp/files/data/user/0/com.videoeditorapp/cache/Camera/f27579d2-1488-4a59-8a9d-7a4e7b6fe716.mp4'
[Tue Feb 02 2021 16:30:45.377]  LOG      /data/user/0/com.videoeditorapp/files/videoList.txt: No such file or directory

而且txt文件不在我的android設備上我的清單是這樣的

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />  
      

<application android:requestLegacyExternalStorage="true" ... />

我沒有看到該文本文件將其路徑添加到我的 txt 文件/data/user/0/com.videoeditorapp/files /data/user/0/com.videoeditorapp/cache/Camera/f27579d2-1488- 4a59-8a9d-7a4e7b6fe716.mp4

我把它改成了

var path = 'data/user/0/com.videoeditorapp/cache/Camera/videoList.txt';

而這

const arr = path.split('/');    
fileContent += `file '${arr[arr.length - 1]}'\r\n`;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM