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

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

Related

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.

When converting mkv to mp4, the audio is lost

I have converted my .mkv file into an .mp4 by using the command:
sudo avconv -i input.mkv -codec copy output.mp4
I am trying to play the mp4 file in the browser, but the audio is not playing. The video player shows that it is on mute, but the button is disabled so you cannot turn it off of mute.
Other mp4s are working, but they were not converted from .mkv. Any help would be much appreciated.
In an MP4 container, browsers usually support only H.264 video and either AAC or MP3 audio. The output from your avconv command should show the format of your video and audio; look under "Input #0" for the lines that start with "Stream #". If you audio is not already AAC or MP3 you will want to convert it instead of just copying it to the MP4 container. You can copy the video and convert only the audio with a command like this:
avconv -i input.mkv -c:v copy -c:a libmp3lame -q:a 2 output.mp4
The -c:v copy will copy the video, and -c:a libmp3lame will convert the audio to MP3 using the libmp3lame encoder. -q:a 2 sets the audio quality; use a lower number for better quality (and a larger file). You could instead convert to AAC audio if your avconv was configured with non-free codecs enabled and a good quality AAC encoder.

ffmpeg adts streaming with ezstream for icecast

I'm trying to use ezstream to stream to an icecast server, my problem is while encoding the audio, I decode it from mp3 with madplay and I'm trying to encode it with ffmpeg so the output is aac, someone told me to use adts to be able to stream aac the problem is that the encoding doesn't stream the audio, it shows the timer on the console but it goes from 0:00:00 to 0:00:40 to 0:01:30, etc until the song ends instead of going second by second, this is my config:
<ezstream>
<url>http://localhost:8100/t</url>
<sourcepassword>password</sourcepassword>
<format>MP3</format>
<filename>/home/vybroo/server/audio/play.m3u</filename>
<reencode>
<enable>1</enable>
<encdec>
<format>MP3</format>
<match>.mp3</match>
<decode>madplay -b 16 -R 44100 -S -o raw:- #T#</decode>
<encode>ffmpeg -f s16le -ar 44.1k -ac 2 -i - -b:a 32k -ar 44.1k -f adts -</encode>
</encdec>
</reencode>
</ezstream>
is the enconding config wrong?, what should i change so it streams second by second correctly

Normalize audio in an avi file

I have an avi file that has different levels of audio. Is there a way to decrease and increase appropriately where needed the audio of my file using ffmpeg?
In ffmpeg you can use the volume filter to change the volume of a track. Make sure you download a recent version of the program.
Find out the gain to apply
First you need to analyze the audio stream for the maximum volume to see if normalizing would even pay off:
ffmpeg -i video.avi -af "volumedetect" -f null /dev/null
Replace /dev/null with NUL on Windows. This will output something like the following:
[Parsed_volumedetect_0 # 0x7f8ba1c121a0] mean_volume: -16.0 dB
[Parsed_volumedetect_0 # 0x7f8ba1c121a0] max_volume: -5.0 dB
[Parsed_volumedetect_0 # 0x7f8ba1c121a0] histogram_0db: 87861
As you can see, our maximum volume is -5.0 dB, so we can apply 5 dB gain. If you get a value of 0 dB, then you don't need to normalize the audio.
Apply the volume filter:
Now we apply the volume filter to an audio file. Note that applying the filter means we will have to re-encode the audio stream. What codec you want for audio depends on the original format, of course. Here are some examples:
Plain audio file: Just encode the file with whatever encoder you need:
ffmpeg -i input.wav -af "volume=5dB" output.mp3
Your options are very broad, of course.
AVI format: Usually there's MP3 audio with video that comes in an AVI container:
ffmpeg -i video.avi -af "volume=5dB" -c:v copy -c:a libmp3lame -q:a 2 output.avi
Here we chose quality level 2. Values range from 0–9 and lower means better. Check the MP3 VBR guide for more info on setting the quality. You can also set a fixed bitrate with -b:a 192k, for example.
MP4 format: With an MP4 container, you will typically find AAC audio. We can use ffmpeg's build-in AAC encoder.
ffmpeg -i video.mp4 -af "volume=5dB" -c:v copy -c:a aac -strict experimental -b:a 192k output.mp4
Here you can also use other AAC encoders. Some of them support VBR, too. See this answer and the AAC encoding guide for some tips.
In the above examples, the video stream will be copied over using -c:v copy. If there are subtitles in your input file, or multiple video streams, use the option -map 0 before the output filename.
The author's info is: Jon Skarpeteig in SuperUser
You can use my ffmpeg-normalize script for that.
First, install a recent version of ffmpeg. Then, install via pip install ffmpeg_normalize, then run it on an AVI file:
ffmpeg-normalize input.avi -o output.mkv -c:a aac -b:a 192k
Here, we're choosing to re-encode the audio with AAC at 192 kBit/s, and copy the video stream over to the output. This will perform EBU R128 normalization, but simple peak/RMS normalization is also possible.

getting error while converting wav to amr using ffmpeg

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

Resources