2

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.

anoncgain
  • 375
  • 3
  • 14
  • There is a space in your input filename, add quotes – Dirk V Aug 13 '20 at 12:23
  • When I created the string I added quotes, when the arguments in the console, quotes are not being printed. Filenames are passed as : '''$_savePath/"${item.fileName}"''' I tried with other ogg files with no spaces, the same error was thrown. – anoncgain Aug 14 '20 at 05:23

1 Answers1

5

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.

Hernán Alarcón
  • 3,494
  • 14
  • 16