【问题标题】:Cannot convert .ogg file to .mp3 or other file formats无法将 .ogg 文件转换为 .mp3 或其他文件格式
【发布时间】:2020-12-03 06:38:25
【问题描述】:

我正在尝试将 ogg 音频文件转换为 mp3 或其他可以在 ios 设备中播放的音频文件格式,但是 ogg 文件没有被转换为其他格式,例如 mp3 和 caf。我正在android设备中测试转换。

这是我的 ffmpeg 命令参数:

Command: "ffmpeg -y -i $inputFilePath -c:a copy $outputFilePath"
Both input and output filenames were surrounded with quotations

 [-y, -i, /data/user/0/com.musicapp/files/composer_audios/testtt ogg file.ogg, -c:a, copy, /storage/emulated/0/Android/data/com.musicapp/files/ball.mp3]

当我尝试转换为 mp3 时。抛出此错误:

 FFmpeg exited with rc: 1
 [mp3 @ 0x73f7b36a00] Invalid audio stream. Exactly one MP3 audio stream is required.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

当我尝试转换为 .caf 文件时,会抛出此错误:


FFmpeg exited with rc: 1
 [caf @ 0x73f7b36a00] unsupported codec
 Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input

但如果我尝试将 mp3 文件转换为 caf、mkv、mp4 等格式,则不会引发错误。

【问题讨论】:

  • 你输入的文件名有空格,加引号
  • 当我创建字符串时我添加了引号,当控制台中的参数时,引号没有被打印。文件名传递为:'''$_savePath/"${item.fileName}"''' 我尝试使用其他没有空格的 ogg 文件,抛出了同样的错误。

标签: ffmpeg android-ffmpeg


【解决方案1】:

删除-c:a copy 选项。

关于那个选项,the ffmpeg documentation 说:

一个特殊值copy(仅输出)表示流不会被重新编码。

您正在禁用编码并建议 ffmpeg 将 vorbis 流视为 mp3 流。

在您的情况下,您想要将输入流编码为不同的输出流。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-06
    • 2012-06-18
    • 1970-01-01
    • 2014-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-06
    相关资源
    最近更新 更多