ffmpeg from .mp3 to .al appears to slow and deepen the audio - ffmpeg

I have an mp3 input file that is 22050Hz and 48kb/s. I need to convert it to a .al file in order to stream it to a camera on my network for output.
ffmpeg -i file.mp3 file.al
creates a file that does play but the bitrate of the output is 176kb/s and it clearly slower/deeper sounding. I have tried -b:a 48k and -filter:a without success but I could be doing it wrong.
Documentation states that this is the format I need: PCM ADPCM G.711A G.711.Mu G.726 G.729 MPEG2 AMR AAC

ffmpeg -i input.mp3 -ar 8000 -ac 1 -ab 64 output.al -ar 8000 -ac 1 -ab 64 -f mulaw
This has produced the correct result. Conversion is for playing audio over an Amcrest camera speaker.

Related

Convert PCM to AAC using PyAV

I need to convert PCM (G.711U) audio to AAC in realtime. I've been able to do it with ffmpeg, but would like to use PyAV to have direct control and not have to run a separate process. What's the best way to do that?
cat input.raw | ffmpeg -hide_banner -f mulaw -ar 8000 -ac 1 -i - -c:a aac -f adts - > output.mp4
(NOTE: in the actually use case there aren't actual files for input.raw and output.mp4 and those are just streaming data but I did them to be able to show the example)

Ffmpeg makes audio longer when changing bitrate

I've been using ffmpeg convert audio from one format to another and to change audio's bitrate. When I try to convert aac audio to mp3 audio using the command:
ffmpeg -i SomeAudio.aac -c:a mp3 -b:a 128k SomeOutputPath.mp3
everything works correctly and output audio is of the same length as the input audio (6 minutes, 15 seconds).
However, when I try converting it to aac audio using a similar command:
ffmpeg -i SomeAudio.aac -c:a aac -b:a 128k SomeOutputPath.aac
it makes the output audio longer (around 10 minutes). I have tried specifying output length but that still makes the video longer, it just cuts of part of the audio:
ffmpeg -i SomeAudio.aac -c:a aac -b:a 128k -t 00:06:15 SomeOutputPath.aac
Here is a link to the screenshot:
My suspicion is that message "Estimating duration from bitrate, this may be innacurate" (the one in the screenshot) is the root of my problem but I just haven't been able to find any useful information about it on the web.
Thanks a lot for any help in advance :)
The duration shown for raw AAC is a guess because it does not contain duration info. You can find the actual duration with:
ffmpeg -i input.aac -f null -
Or a faster, "close enough" method:
ffmpeg -i input.aac -c copy -f null -
Workaround is to remux to M4A:
ffmpeg -i input.aac -c copy output.m4a

What is the right command to convert an mp3 file to the required codec version (MPEG version 2) and bit rate (48 kbps) for Amazon Alexa SSML?

I am trying to convert an mp3 file to the format expected by the audio tag in the Amazon Alexa SSML markup language as described here: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference
The documentation recommends using https://www.ffmpeg.org/ffmpeg.html
I tried this command but can't find the right codec to use:
ffmpeg -y -i input.mp3 -ar 44100 -ab 48k -codec:a mpeg2 -ac 1 output.mp3
I know I need to convert the file because Alexa fails with the following error: The audio is not of a supported MPEG version
Its a little confusing, and frankly a little odd that amazon requires this. mp3 files can be mpeg1 or mpeg2 or mpeg-2.5 (non standard, but widely supported). For this purpose, the main differences between the versions are bitrate and sample rate. Amazon requires 48kbps (which is supported in all mpeg versions). Next, mpeg-2 only supports sample rates of 22050 Hz, 24000 Hz, and 16000 Hz. So resampling to one of those frequencies should force ffmpeg to MPEG-2 layer 3.
ffmpeg -y -i input.mp3 -ar 16000 -ab 48k -codec:a libmp3lame -ac 1 output.mp3
more info here and here:
http://www.mp3-tech.org/programmer/frame_header.html
https://en.wikipedia.org/wiki/MP3
Here's what I had to do to get it working:
ffmpeg -i input.mp3 -b:a 48k -ar 16000 output.mp3
Here's the output when I play it with mpg123:
$ mpg123 output.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
version 1.22.4; written and copyright by Michael Hipp and others
free software (LGPL) without any warranty but with best wishes
Playing MPEG stream 1 of 1: output.mp3 ...
MPEG 2.0 layer III, VBR, 16000 Hz joint-stereo
[0:02] Decoding of output.mp3 finished.

Getting the original video quality while converting in ffmpeg

In my site, having upload video(only mp4 videos) functionality and then to combine. For the combining i used Mp4Box, If we want combine all the mp4 video, those videos have to same dimesions,bitrate,codecs,samplerate,etc, So while uploading the mp4 videos itself we set the constant dimension and other details like
ffmpeg -i test.mp4 -r 25 -s 640x360 -ar 48000 -acodec copy -f mp4 -vcodec libx264 -vpre default -async 1 -strict -2 -qscale 10 test.mp4
After using this command the video quality will loss fro the original video, Kindly suggest any solution?
Add
-qp 0
ยง Lossless H.264

FMS FLV to mp3/aac/wav

How can I decode a FLV's audio if it's recorded from a live stream using Flash Media Server and uses NellyMoser codec?
I'm writing a script that process several FLVs, using FFmpeg, so I need a command line solution.
Any ideas?
This should work for you, since NellyMoser is supported by FFmpeg.
1. Using mp3
ffmpeg -i yourinput.flv -vn -acodec libmp3lame output.flv
2. Using AAC (switch aac with libfaac depending on which you have loaded)
ffmpeg -i yourinput.flv -vn -acodec libfaac output.mp4
I'm assuming of course you dont care about video.

Resources