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

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.

Related

ffmpeg - output 5.1 AAC without lowpass on the LFE channel

I'm trying to encode 6 arbitrary mono audio streams into a single AAC 5.1 track in an mp4 container (here with test streams):
ffmpeg -f lavfi -i testsrc=duration=10:size=100x100:rate=30 -f lavfi -i aevalsrc="-2+random(0)" -filter_complex "[1:a][1:a][1:a][1:a][1:a][1:a]join=inputs=6:channel_layout=5.1:map=0.0-FL|1.0-FR|2.0-FC|3.0-LFE|4.0-BL|5.0-BR[a]" -map '0:v' -map "[a]" -c:a aac -channel_layout 5.1 -t 10 testlfe.mp4
5 of the channels replicate the input audio just fine (modulo encoding). However, the LFE channel is lowpassed. Extracting with:
ffmpeg -i testlfe.mp4 -filter_complex "channelsplit=channel_layout=5.1:channels=LFE[LFE]" -map '[LFE]' testlfe.wav
I get a lowpassed rumble, instead of the original full white noise
(from ffmpeg -i testlfe.wav -lavfi showspectrumpic=s=640x320 testlfe.png)
Is there a way to prevent the lowpass from happening?
I couldn't find any references whether that's inherent to the AAC 5.1 encoding, something that ffmpeg does, or inherent to the decoding process. (I did decode my same test files using something that uses Microsoft MediaFoundation and the LFE channel was still lowpassed).
Turns out, the AAC codec inherently limits the LFE bandwidth, so there's no way around it.
(thanks to kesh in the comments) Wikipedia's Advanced Audio Encoding article claims the upper limit is 120Hz which matches my spectrogram, but doesn't cite a source. The actual ISO/IEC 13818-7:2006(en) Standard costs a bunch of money to read as usual, but in the free glossary there is an entry:
low frequency enhancement ( LFE ) channel:
limited bandwidth channel for low frequency audio effects in a multichannel system
Encode with
ffmpeg -i 6channels.wav -filter "channelmap=0|1|2|3|4|5:6.0(front)" -c:a libfdk_aac -ac 6 -profile:a aac_he -vbr 1 -cutoff 18000 -movflags +faststart 6channels-vbr1-fdk.m4a
It can also be done with regular aac codec.

FFMPEG (Input 8K AAC -> (AAC FLV) youtube streaming noise

Hello I run a streaming encoder for a non profit cause. Chosen FFMPEG as it's very simple and doing the job near perfectly however the audio is noisy popping and cracking. Video is crystal clear.
ffmpeg version N-86950-g1bef008 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.1.0 (GCC)
Here is my command.
ffmpeg -rtsp_transport tcp -i $RTSP_SRC -vcodec copy -af "volume=12dB" -ar 8000 -acodec aac -f flv rtmp://a.rtmp.youtube.com/live2/$DEST_KEY
However when I just play the stream the noise levels are quite acceptable.
ffplay -rtsp_transport tcp -i $RTSP_SRC
What I have tried so far.
Change input audio sampling from 8K to 16K (that's all is supported currently). It made the noise problem much worse. I can't change it to a native FLV sampling(44100 or 22050 or 11025) at least not yet, the integrated rtsp stream does not support it.)
My working theory is during resampling stream noise is getting boosted. So to eliminate that I tried audio copy codec even then there is no significant improvement.
-af "equalizer=f=100:t=h:width=200:g=-64" Suppressing this frequency band cut all the crackling / popping noise for me.

FFMPEG Encode encode into .3g2 best quality?

I'd like to get the best .3g2 quality for my video encoding. I've read about this format on wiki, but as a newbie, I'm not sure to get the best sound/video bitrate.
Format sizes are 128x96, 176x144, 352x288, 704x576, and max 1408x1152 pixels.
I couldn't find the highest video bitrate.
I've tried this :
ffmpeg -i C:\projet.avi -s 1408x1152 -vf "split [a], pad=iw*2:ih [b], [a] alphaextract, [b] overlay=w" -vb 1220000000 -ac 1 -ar 8000 C:\projet.alpha.3g2
it says
"[h263 # 0000000000666bc0] bitrate tolerance 4000000 too small for bitrate 12200000000, overriding
[libopencore_amrnb # 000000000066aee0] bitrate not supported: use one of 4.75k, 5.15k, 5.90k, 6.70k, 7.40k, 7.95k, 10.20k, 12.20k, using 12.20k"
I don't understand what it means ?
Others : I've tried to mention stereo sound, 44000Hz, but it seems not supported.
Any help/Suggestions ? Thank you !
P.S: I need alpha channel and .3g2 for an Augmented Reality software on iOS and Android.
LAST EDIT : I'm still with
ffmpeg -i c:/test.avi -s 1408x1152 -vf "split [a], pad=iw*2:ih [b], [a] alphaextract, [b] overlay=w" -vb 4000000 -ac 1 -ar 8000 C:\test.alpha.3g2
It's working well except error messages, and bad quality sound. Any more ideas ?
For video, your supplied bitrate (1200M!) is too high. Use -q:v 1 instead of -b:v for best quality.
For audio, by default, ffmpeg tells the encoder to use a bitrate of 128k unless specified otherwise. Which is not valid for the default encoder used here. So the encoder has overridden the generic value with 12.20k.
If your application supports it, use
ffmpeg -i C:\projet.avi -filter_complex "[0]alphaextract[a];[0][a]hstack" -c:v libx264 -crf 20 -c:a aac C:\projet.alpha.3g2

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.

FFmpeg audio conversion

I have been using FFMPEG for some time for audio file conversions. I just downloaded the newest version and the command below:
ffmpeg -i x.flac -ab 128k x.mp3
no longer produces a 128k file.
It produces a 48k file no matter what the -ab command requests. Any suggestions?
According to the documentation
`-ab bitrate'
Set the audio bitrate in bit/s (default = 64k).
So this is the bitrate, which means that per second by default 64k bits are used for storing sound information. So only a one second file would return a 128k file.
If I misunderstood your question and you mean that the bitrate is 48k instead of 128k then double check if ffmpeg is not using variable bit rate. If this is not the case I suggest you submit a bug report.

Resources