getting error while converting wav to amr using ffmpeg - audio

I am using ffmpeg to convert amr to wav and wav to amr.Its successfully converting amr to wav but not viceversa. As ffmpeg is supporting amr encoder decoder, its giving error.
ffmpeg -i testwav.wav audio.amr
Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

You can try setting the sample rate and bit rate.
Amr supports only 8000Hz sample rate and 4.75k, 5.15k, 5.9k, 6.7k, 7.4k, 7.95k, 10.2k or 12.2k bit rates:
ffmpeg -i testwav.wav -ar 8000 -ab 12.2k audio.amr

Related

I need to convert an audio from .mp3 to .gsm

I need to convert from .mp3 to .gsm (preferably with ffmpeg).
I used it for several different formats but with this isn't as simple as it was with the others.
I don't know what parameters I'm missing.
I tried using ffmpeg with the following comand:
ffmpeg -i ".\example.mp3" ".\example.gsm"
But it shows me the following error:
Sample rate 8000Hz required for GSM, got 44100Hz Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed!
ffmpeg -ar 8000 -ac 1 -i ".\example.mp3" ".\example.gsm"
-ar sample rate
-ac audio channel

ffmpeg default audio codec instead of specifying it with acodec option

In raspberry pi I've following i2s microphone breakout board and use it like the guide suggested. When I try record audio from it using ffmpeg to the file with ffmpeg -f alsa -i dmic_sv out.wav command. I'll receive following error
[alsa # 0x22e21c0] cannot set sample format 0x10000 2 (Invalid argument)
dmic_sv: Input/output error
When I specify the used codec explicitly with -acodec it works fine:
ffmpeg -f alsa -acodec pcm_s32le -i dmic_sv out.wav
And from the output ffmpeg will reencode to pcm_s16le
Input #0, alsa, from 'dmic_sv':
Duration: N/A, start: 1597597938.887969, bitrate: 3072 kb/s
Stream #0:0: Audio: pcm_s32le, 48000 Hz, stereo, s32, 3072 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s32le (native) -> pcm_s16le (native))
How I can tell ffmpeg to use signed 32-bit little endian by default without specifying it explicitly? And where ffmpeg gets this default and can I configure it somehow?
I figured this one out myself by reading ffmpeg source code. It seems when codec is not specified and alsa device is used. FFmpeg will default to pcm 16-bit samples instead. Code to set the default here and the default macro here.

Is there some way to configure ffmpeg to include support for signed 24-bit WAV output?

24-bit sample sizes are not at all uncommon for PCM/WAV data, so I was surprised to see this:
Invalid sample format 's24'
... when I ran this:
ffmpeg -i input.oga -y -f wav -ar 44100 -sample_fmt s24 -ac 2 output.wav
When I look at the ffmpeg FAQ page it says that it doesn't support signed 24-bit sample sizes.
Fair enough, but I'm having a hard time accepting that this very powerful tool which supports an impressively large number of formats is somehow missing support for this really common sample width.
All I can think of is that maybe it's a build configuration issue.
So this question is...
Is there some way to configure ffmpeg to include support for signed 24-bit WAV output?
There is no sample format to compactly store 24-bit samples, but they can be stored in 32-bits with padding. For that, select a 24-bit PCM encoder
ffmpeg -i input.oga -y -f wav -ar 44100 -c:a pcm_s24le -ac 2 output.wav
Run ffmpeg -encoders | grep 24 to get a list of all 24-bit encoders.

FFmpeg - how to set output sample_size

Trying to create a simple command line player for .dsf (DSD audio) files, and output to an alsa device that supports up to 24-bit 192 kHz sample rate. The following command almost works and it does play the track. Examining the bold text below, the dsf input file is converted to 24-bit/192 kHz, but the output is then truncated to 16-bit 192 kHz (pcm_s16le i.e, 16 bit little endian).
ffmpeg -i '01 - Sweet Georgia Brown.dsf' -f alsa hw:0,0
After displaying the ffmpeg banner and song metadata (tags), here is the result, bold is my emphasis:
Duration: 00:05:14.83, start: 0.000000, bitrate: 9234 kb/s
Stream #0:0: Audio: flac, 192000 Hz, stereo, s32 (24 bit)
Stream mapping:
Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, alsa, to 'hw:0,0':
Since I can play this and many other tracks at full resolution using another player (foobar2000) it seems there might be an option in the encoder which is part of FFmpeg: Lavf57.83.100 I can find no information in any of the FFmpeg documentation that helps. Tried finding options in FFplay and even guessing using other FFmpeg options like this example.
ffmpeg -sample_fmt s24 -i '01 - Sweet Georgia Brown.dsf' -f alsa hw:0,0 ***** same results.
I'm stuck. Any suggestions?
Environment: Linux Mint 19.2, 64-bit, ASUS Xonar STXii sound card.
Each output format or device has a default encoder registered for each media type it accepts. ALSA accepts audio and its default encoder is 16-bit signed PCM.
You can change the encoder by specifying one.
ffmpeg -i '01 - Sweet Georgia Brown.dsf' -c:a pcm_s24le -f alsa hw:0,0

Streaming mp4a to localhost using udp and ffmpeg

I am using the following command to stream a video and it's audio to localhost:
ffmpeg -re -i out.mp4 -map 0:0 -vcodec libx264 -f h264 udp://127.0.0.1:1234 -map 0:1 -acodec libfaac -f mp4a udp://127.0.0.1:2020
FFmpeg is not recognising my audio codec and my audio format so I get the following error message:
Error
What audio format and codec do I need to use? The codec information of the video I wish to send is as follows:
Codecs used
When I convert the audio track to mp3 I can run the above command and stream the video and audio properly. However I dont want to convert all my video audio-tracks to mp3.
(I am confused by all the encoders, decoders, codec names in the ffmpeg documentation) Is there a way of finding the right encoder to use with the mp4a audio codec other than reading the whole list of codecs and options?
Thanks.

Resources