Cannot convert .ogg file to .mp3 or other file formats

岁酱吖の 提交于 2020-12-15 04:40:05

问题


I am trying to convert ogg audio file to mp3 or other audio file formats that can be played in ios devices But ogg files are not being converted into other formats like mp3 and caf. I am testing the conversion in android device.

This is my ffmpeg command arguments:

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]

When I try to convert into mp3 . this error is thrown:

 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

When I try to convert into .caf file this error is thrown:


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

But if I try to convert mp3 file to formats like caf, mkv, mp4, no error is thrown.


回答1:


Remove the -c:a copy option.

About that option, the ffmpeg documentation says:

a special value copy (output only) to indicate that the stream is not to be re-encoded.

You are disabling encoding and suggesting ffmpeg to treat a vorbis stream as an mp3 stream.

In your case you want to encode your input stream as a different output stream.



来源:https://stackoverflow.com/questions/63394725/cannot-convert-ogg-file-to-mp3-or-other-file-formats

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!