-1

I am working with FFMPEG Library. I am capturing streams in particular compression codes to the destination file with the specified format with the following command:

ffmpeg -i rtsp://username:password@server-ip/filename -acodec adpcm_ms -t 10 -f mp3 C:\FFMPEG_Recordings\ADPCM_10.mp3

I am getting the following the error:

Could not write header for output file #0 (incorrect codec parameters ?): Error number -22 occurred

So, when I specify some other file format against '-f' option this executes normally. Such as:

ffmpeg -i rtsp://username:password@server-ip/filename -acodec adpcm_ms -t 10 -f mov C:\FFMPEG_Recordings\ADPCM_10.mp3

So, when I specified 'mov' against '-f' option It works fine and It captures the streams in media file of 'mp3' format.

I am unable to understand that why I am getting this error? and why I have to specify 'mov' against '-f' format while I want to capture streams in 'mp3' file format?

Bilal Ahmed Yaseen
  • 2,506
  • 2
  • 23
  • 48
  • 1
    Your question has nothing to do with programming, esp. Java. You are basically asking how to use ffmpeg. I recommend to turn to superuser.com - stackover flow is about programming problems; not options of ffmpeg. – GhostCat Apr 13 '15 at 12:49
  • This question may be related to programming as I am creating Java Processes to execute these command. And this could be due to some permissions issue with those created processes. – Bilal Ahmed Yaseen Apr 13 '15 at 12:53
  • What do you think about this question: http://stackoverflow.com/questions/11986279/can-ffmpeg-convert-audio-from-raw-pcm-to-wav? I can show you lot of such questions over here. – Bilal Ahmed Yaseen Apr 13 '15 at 13:01
  • Then that person was lucky to receive helpful answers. But it is really not relevant if you want to invoke ffmpeg directly on the command line, or from java, or from C++. There is **nothing** specific about Java in your question, isn*t it? – GhostCat Apr 13 '15 at 13:04

1 Answers1

2

In short, you're trying to create a mp3 file that has a non-mp3 codec, which is non-sensical and thus doesn't work. The reason mov works is because adpcm-ms in mov is a supported codec configuration.

When muxing mp3, use the mp3 audio codec. When using adpcm-ms, you're restricted to boa, caf, mov, avi and wav.

Ronald S. Bultje
  • 10,828
  • 26
  • 47
  • Hi Ronald, thanks a lot for time and answer. The reason seems logical. Can you provide me any link in which I can see the supported compression codecs for media files of any format? And these constraints generically exists or these are imposed by FFMPEG? Thanks – Bilal Ahmed Yaseen Apr 14 '15 at 05:15
  • And One more thing even though I specify 'wav' with '-f' option it will still generate file with '.mp3' extension. While it shouldn't be in '.wav' format due to compression codec type used? – Bilal Ahmed Yaseen Apr 14 '15 at 07:59
  • I don't believe fm peg has an API for that, sadly. I just grepped the source code but realize that's not helpful for most people. Extensions are an application thing, ffmpeg just writes to whatever file name you specify. – Ronald S. Bultje Apr 15 '15 at 10:34