【问题标题】:How to convert a .m4a file to a .wav file on Android using React Native?如何使用 React Native 在 Android 上将 .m4a 文件转换为 .wav 文件?
【发布时间】:2022-10-23 20:48:19
【问题描述】:

我正在尝试将使用 expo-audio 录制的 .m4a 文件转换为 .wav 文件。然后,目标是将其用作 blob 以将其发送到 Google Cloud Storage。 我尝试使用 ffmpeg-kit-react-native 来做到这一点:

const uri = recording.getURI();
console.log(uri);

if (Platform.OS === 'android') {
    FFmpegKit.execute(`-i ${uri} temp.wav`).then(async (session) => {
    // const returnCode = await session.getReturnCode();
    uri = 'temp.wav';
    });
}

const response = await fetch(uri);
const blob = await response.blob();

但我没有成功(得到错误):

TypeError:null 不是对象(评估 'FFmpegKitReactNativeModule.ffmpegSession')

uri 有这种形式:

file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540aamorel%252Fvoki/Audio/recording-4038abed-f264-48ca-a0cc-861268190874.m4a

我不确定我是否正确使用了 FFmpeg 工具包。你知道如何进行这项工作吗?或者有更简单的方法吗?

【问题讨论】:

    标签: react-native ffmpeg expo wav m4a


    【解决方案1】:

    您找到解决方案了吗?我在尝试将 m4a 文件合并在一起时遇到了同样的错误:

    FFmpegKit
        .execute(`-i "concat:shard.aac|ohshit.aac" -c copy output.aac`)
        .then((session) => {console.log(session)}
      ).catch((error)=>console.error(error));
    

    【讨论】:

      猜你喜欢
      • 2011-06-17
      • 2022-09-26
      • 2011-12-23
      • 2019-01-07
      • 1970-01-01
      • 1970-01-01
      • 2012-04-14
      • 2021-06-13
      • 1970-01-01
      相关资源
      最近更新 更多