Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg FLAC 24 bit 96khz to 16 bit 48khz

Trying to figure out ffmpeg, currently working on getting 24bit/96khz FLAC files into 16bit/48khz.

like image 650
Corey Avatar asked Jan 02 '17 01:01

Corey


People also ask

Does FFmpeg support FLAC?

As slhck says, ffmpeg appears unable to recognise flac.

How do I change bit depth in FFmpeg?

The bit depth can be changed with the sample_fmt option, e.g. Note that not all formats are supported by every encoder. See the chapter Audio Options in the FFmpeg command line documentation. @xjcl The codec you are using only supports 4 bit.

Is 24 bit FLAC worth it?

Tl;DR If the source was recorded mastered and released with 24 bit depth and a 96kHz sample rate. The answer is absolutely, yes.

What is pcm_s16le?

Reading and Writing Raw Audio The pcm_s16le tells you what format your audio is in. And that happens to be a common format.


2 Answers

Basic example

ffmpeg -i input.flac -sample_fmt s16 -ar 48000 output.flac
  • List sample formats: ffmpeg -sample_fmts
  • List additional flac encoding options: ffmpeg -h encoder=flac

aresample filter example

ffmpeg -i input.flac -af aresample=out_sample_fmt=s16:out_sample_rate=48000 output.flac

Either example will result in the same output: you can verify with the hash muxer.


Changing the dithering method

See the -dither_method option for a list of available dithering methods and additional resampling options. Example:

ffmpeg -i input.flac -dither_method triangular_hp -sample_fmt s16 -ar 48000 output.flac

SoX resampler

FFmpeg supports two resamplers: the default swresample library, and the external SoX resampler (soxr).

To use soxr your ffmpeg must be compiled with --enable-libsoxr. Then choose it with the -resampler option:

ffmpeg -i input.flac -resampler soxr -sample_fmt s16 -ar 48000 output.flac

Or use the aresample filter to do it all:

ffmpeg -i input.flac -af aresample=resampler=soxr:out_sample_fmt=s16:out_sample_rate=48000 output.flac

More info

  • FFmpeg Resampler Documentation
like image 159
llogan Avatar answered Oct 19 '22 05:10

llogan


As a bash script, that produces new files with -16 appended to their names; one could rename then delete the original files easily in the script but I'm a little too paranoid for that.

#!/bin/sh
# requires: ffmpeg
for f in *.flac;
do
echo "Processing $f"
ffmpeg -i "$f" -sample_fmt s16 -ar 48000 "${f%.flac}-16.flac"
done
like image 42
Steve Kinney Avatar answered Oct 19 '22 05:10

Steve Kinney