Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Can you help me create a Convert command to reduce flac file sizes (Read 5248 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Can you help me create a Convert command to reduce flac file sizes

Hello everyone,

I often want to convert from hi-res flacs to lower-res flacs. For example, I'd like to convert hi-res to 16 bit / 44.1 KHz flacs.

How can I do this in Foobar?

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #1
You need a FLAC encoder. The easiest way to get a suitable encoder is to install Free Encoder Pack: https://www.foobar2000.org/encoderpack.

In theory when downmixing you should also dither. It makes sure sample truncation doesn't introduce artifacts, though in reality no one can hear those at 16-bit target. But in theory it improves quality and the optimal dither is simple TPDF. If you wish to use dithering, I recommend Smart Dither DSP. The "smart" part in the name comes from the fact that this DSP doesn't introduce dither noise to parts that need to be silent.

foobar2000 comes with very hiqh quality SSRC-resampler, but it's somewhat slow and its frequency cutoff is super steep. Mathematically such steep filter preserves most of the original signal, but some experts say it's actually not ideal and introduces high frequency ringing. That's mostly a theoretical problem, but the extra high frequency noise could in theory be audible with some equipment under some circumstances. As an alternative you can use SoX Resampler. It's much faster and by default uses less steep filter avoiding all the potential issues.

Then you need to create a Converter preset for the job. Select the tracks you want to convert, or for example a test track, right click one of the selected tracks and click 'Convert' -> '...'.

Select 'Output format' on the right, then either pick FLAC from the existing output format list, or click 'Add New' and add a new FLAC profile. If you pick existing FLAC format, I recommend hitting the Edit button and changing the compression level from default 5 to highest 8. If you created a new encoder profile instead, pick FLAC as the encoder and set the compression level to what you want. Again, I recommend setting to highest 8. Encoding at level 8 is still very fast, files will be smaller than with the default level and decoding speed isn't any slower.
Click OK to return to output format selection dialog. At the bottom of the window there's an 'Output bit depth' dropdown list. Set it from 'Auto' to '16'. Leave foobar2000 dither setting at 'Never'. It uses heavy noise shaping, it will inflate bitrates and heavily affect audio spectrum as it creates a ton of high frequency noise. Click 'Back' to return to main Converter dialog.

Select 'Destination' to configure where the converted files will be saved and how they will be named. For your purpose some temporary path might be best output directory as you can't overwrite the source files with Converter. Set that by picking 'Specify folder' and browse to suitable location, it can be for example something like 'C:\Converter Output'.
In the lower part of the dialog select 'Convert each track to an individual file' and pick a suitable naming pattern. If your files have good tags you can format the new names from tags. Or you can utilize the existing file and path names. For example my files are stored as "Album Artist\(Year) Album\DNN. Title", at max two directories deep. I can use existing directory and filenames by string "$directory(%path%,2)\$directory(%path%,1)\%filename%".
Once output naming and path are set, hit 'Back' again to return to main dialog.

Now click on 'Processing'. Add a resampler from 'Available DSPs' list on the right to the 'Active DSPs' list by double clicking. The highest quality built-in resampler is the "Resampler (dBpoweramp/SSRC)" one. The alternative I recommended is listed as "Resampler (SoX)". Once a resampler is added to the active DSP chain, you can open its configuration by clicking on the '...' symbol behind its name. If you open the configuration you can verify that target sample rate is 44100 Hz and quality settings are the highest. No need to touch anything else.
If you wish to use dithering, add the "Smart Dither" DSP from available list to active list too by double clicking it. No need to alter its settings, defaults are optimal for this purpose. It defaults to 16-bit target using just enough dither to remove all truncation artifacts.
Resampling alters the sample points so loud sources could have had high intersamples that could cause clipping. We can prevent any nasty clipping artifacts by also adding "Advanced Limiter" to the end of the DSP chain.
Now hit 'Back' again to return to main dialog.

Click on 'Other' and make sure at least "Transfer metadata (tags)" is selected. If you use ReplayGain you should also enable the "ReplayGain-scan output files as albums". If you use embedded cover art you can also transfer that. And if source files have some extra files, you can configure the 'Copy other files to destination folder' option too. For example if you have external cover art named something like Folder.jpg, Folder.png, Cover.jpg, Cover.png, Front.jpg and Front.png you can copy them for example with string "*.jpg;*.png".
Return once more to main screen with 'Back'.

Click 'Save <<' to store the carefully configured Converter preset so you can easily use it later at any time. Give the preset a descriptive name.

Now that you have the preset, you can either continue with the operation you started by clicking on 'Convert'. Or you can cancel at this point and test the new preset by right clicking the selection again, and select directly 'Convert' -> '<the name you picked>'. If you open it through the saved preset the Converter will instantly start converting without bothering you with any more dialogs.

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #2
Excellent write-up, gold standard.  Not applicable to me right now, but if/when I need to do this I know where to come.  If only all instructions were this clear (but I know it must have taken a while to write)!
It's your privilege to disagree, but that doesn't make you right and me wrong.

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #3
@Case thank you so much!

A couple of questions:

1) Do I think correctly that if I downmix from 96 or 192 KHz it's better to choose sample rate of 48 Khz, so that 96 or 192 are divided by 48 without any remainder?

2) I tried to downmix from a DSD file and got a message from foobar: "foobar does not support DSD-passthrough; the conversion will not be lossless". Do you know what it means and is it normal?

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #4
Ratio between sample rates doesn't affect quality with any proper resampler. Integer ratio being better is some old myth, probably from times when resamplers were using linear interpolation or similar approximations.

The DSD message you saw is normal. As the foobar2000 pipeline never transfers DSD as-is the converter could never pass it through losslessly. What Converter gets from DSD decoder is DSD converted to PCM and that step already is lossy, even if quality isn't affected. It's just a warning in case someone expects foobar2000 Converter to always be lossless when the target would otherwise allow it.

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #5
Although that warning may sometimes be confusing, it helps safeguard against those misconceptions that could otherwise make irreversible changes.
For example as goes DSD: WavPack can losslessly contain DSD, but you cannot use fb2k (nor ffmpeg) to do that - they can convert DSD to PCM, but not process DSD in any other way. So you must use WavPack itself. fb2k warns. (ffmpeg does not.)

Is that warning appropriate when applying DSPs? Yeah I even think so. For example, not everyone knows up front the difference between ReplayGain tagging, and applying the values to change the actual audio.

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #6
Do I think correctly that if I downmix from 96 or 192 KHz it's better to choose sample rate of 48 Khz, so that 96 or 192 are divided by 48 without any remainder?
I'd strongly argue: Also for another reason. 44.1 is CD specific and past. 48 is natively supported in many contemporary and for sure future devices, so by all means go for that, because on playback no resampling on the fly is necessary then.

Also you may consider not downsampling to 16 bits, or leave at 24, but e.g. to 20. As Case indicated, we're probably in inaudible realms, it's for your peace of mind. You'd need "mda dither" instead of Smart Dither for that (for changing the bit depth, it also has the relevat dithering algos). 20 bits is still a million states vs. 65536 in 16 bits, and more dyn range. 20 vs. 24 saves you a lot of disc space. You could say at a file may turn out to have 1000 vs. 1500 kbps. I personally never downsample high samplerate material with 24 bits per sample to 16bps. Feels wrong to me :-)

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #7
Do those settings indicated protect against clipping? Or should one lower volume too?
I don't know if fb2k - which processes everything in float - could do a simple halving, and I don't know if that is even a point. But avoiding clipping is.

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #8
I knew you would come mentioning clipping so my instructions add Advanced Limiter to the end of the DSP chain. Perfect solution as it doesn't need possibly noticeable level adjustment, doesn't need multiple passes, doesn't rely on metadata that is no longer valid if other processing takes place and has superb quality.

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #9
Ouch. I tried to text search for it. Obviously I cannot spell. Sorry.

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #10
Advanced Limiter to the end of the DSP chain. Perfect solution as it doesn't need possibly noticeable level adjustment
So that would bring down the clipping samples which are messed up anyway... but preserve the gain stage, right? I was always wondering if any way of clipping treatment is necessary at all. Doing nothing, you don't make them worse. Doing something, you won't heal them.
Haha, anyone know Qebrus with his electronic hell? I've got flacs with like 2 mio. samples clipping. Ah btw Case, your Replaygain Plugin with "Compress peaks" introduced heavy crackling artifacts, unfortunately that's a while ago, I can't remember the audio I used.

A quick test with Advanced Limiter tracks still loud and clipping (that's an Apple AAC conversion). But yeah, I tested the heaviest clipping tracks, in one the Advanced Limiter brought down the # of clipping samples from 2 mio. to 50000. According to Truepeak scanner.

X

 

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #11
So that would bring down the clipping samples which are messed up anyway... but preserve the gain stage, right?
If the input is already clipped there's no way to restore it.  What (I think) is under discussion is samples over full scale which are the direct result of resampling (when the interpolated waveform exceeds FS).  With FB2K working floating point internally, there is no clipping as the result of resampling, but could be when the output is converted to fixed point.  And that's where the limiter comes into play.

If I have the wrong end of the stick, somebody say so.
It's your privilege to disagree, but that doesn't make you right and me wrong.

[edited] Can you help me create a Convert command to reduce flac file sizes

Reply #12
I just used Co Pilot to help me make scripts this month

You've probably got all the help you needed already, but just for future ref its really easy to get things like what you were looking for going yourself these days, and i feel you learn a fair bit as well because you have to make things function if you over complicate the task, the AI will start to fumble and you'll learn stuff just from watching minor changes to codelines and getting involved in the process of building it.
I will say tho you did right to ask as well because someone always knows something better, my video editing script works fine, but its no where near as good as two GUI's made to convert everything under the sun i found by looking around.

Re: Can you help me create a Convert command to reduce flac file sizes

Reply #13
I just used Co Pilot to help me make scripts this month
Sure, but as stated in the first post:
How can I do this in Foobar?
...so it's not about creating a script (although it could have been, just going on the title).

In case you're wondering, your post was originally deleted as breaking TOS5 (straying too far off-topic).  I appealed on your behalf and an edited version was restored.
It's your privilege to disagree, but that doesn't make you right and me wrong.