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: HowTo .dsf --> .flac (Read 4706 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

HowTo .dsf --> .flac

Understanding question dsf to flac:
Quote
"flac supports as input RIFF WAVE, Wave64, RF64, AIFF, FLAC or Ogg FLAC format, or raw interleaved samples. The decoder currently can output to RIFF WAVE, Wave64, RF64, or AIFF format, or raw interleaved samples. flac only supports linear PCM samples (in other words, no A-LAW, uLAW, etc.), and the input must be between 4 and 32 bits per sample."
I want to use it to lossless save dsd64 in flac format.
I tried different GUIs and got different file sizes with the same compression value.
Is that just because there is a conversion to a convertible format first? Which is it and where can I see or change the parameters?
I prefer the command line.

Re: HowTo .dsf --> .flac

Reply #1
You can't directly use flac to convert dsf, you have to convert it to wav (pcm) first and then to flac - or use tools that will do that for you in one step. If you want to use lossless compression for dsf,
I suggest you to try wavpack, which have native support for dsf compression.
TAPE LOADING ERROR

Re: HowTo .dsf --> .flac

Reply #2
That is not possible. FLAC can only store PCM audio, and DSD is not PCM audio.

Try Wavpack.
Music: sounds arranged such that they construct feelings.

Re: HowTo .dsf --> .flac

Reply #3
OP's problem is their players don't support large files (and DSD makes for excessively large files only to make extra noise that should be filtered away) and also don't support WavPack.

Solution is explained in this thread: https://hydrogenaud.io/index.php/topic,124531.msg1030785.html

Re: HowTo .dsf --> .flac

Reply #4
Yes, exactly. Because of this problem I want to convert to flac. I'm just amazed at the different file sizes for GUIs that offer this in one step. The difference must lie in the creation of the PCM format,-right?

Re: HowTo .dsf --> .flac

Reply #5
I'm just amazed at the different file sizes for GUIs that offer this in one step. The difference must lie in the creation of the PCM format,-right?
You need to decide the sample size and sample rate of the PCM you will use to store the converted DSD.  It typically is anything from 16/44 to 24/384.  If the GUI is determining this without your input, that is why the files vary in size from one app to another.

Re: HowTo .dsf --> .flac

Reply #6
Note that this conversion from DSD to PCM is never lossless. As you said in your first message of this thread that you want 'to lossless save dsd64', please be aware of this.
Music: sounds arranged such that they construct feelings.

Re: HowTo .dsf --> .flac

Reply #7
I think one needs to be clear about the following:

FLAC being a lossless format does not mean it can carry a particular signal format. FLAC can losslessly represent signals in the most common audio PCM formats (and many many more), but not everything you could possibly come up with. 
FLAC being a lossless format does not rule out someone altering the audio before encoding the end result as a FLAC file.
Indeed, that scam called MQA would do lossy operations on the audio and storing it as FLAC - but it would still be lossy.
Of course, that is what happens in an audio workstation all the time too - they alter the audio, and that is the point of such software.

Now, if you want to convert DSD to FLAC, you need to do something about the audio first - convert to a PCM signal that FLAC can store. That process isn't lossless. That is on top of what they did when they produced those pesky DSD files; in virtually every case, they converted it from a PCM file. That was lossy too. Indeed, with the PCM format "designed for" DSD conversion, it removes most of the information content of the file - don't worry, you cannot hear the difference. I write "designed for" in quotation marks, because they didn't design a new format, only a new name for two specific PCM signal types that were already possible (and completely overkill).

Re: HowTo .dsf --> .flac

Reply #8
BTW, it is possible to transform DSD to DoP and then pack DoP into FLAC. This way it will be completely lossless. foobar2000 with latest foo_input_sacd can do this. There will be no benefit in file size. But here will be available all capabilities of FLAC tagging support. Although, there can be problems with playback, because not all devices support DoP.

Re: HowTo .dsf --> .flac

Reply #9
OK. Thanks to you, I now understand the principle.

I'll take a look at it with DSD --> DoP --> FLAC.
But I only want to use console tools.

Re: HowTo .dsf --> .flac

Reply #10
Yeah, that loophole. DoP is "DSD over PCM". It puts the bitstream from DSD into a PCM format, which needs to be unpacked afterwards. 
Your DAC (or whatever receives the bitstream) must support it - the "PCM" stream just doesn't sound anything like the music you are playing. 

Here is an application that can do the conversion - I know you asked for console, but in the very least you can use [whatever] to test stuff. https://www.dbpoweramp.com/codec-central-dsd-dff-dsf-sacd.htm

But still, you are better off getting a player that can handle the files. Here are some choices that may or may not work: https://en.wikipedia.org/wiki/List_of_UPnP_AV_media_servers_and_clients


Re: HowTo .dsf --> .flac

Reply #12
OK. Thanks for your hints. I will probably buy a new player.
But by testing there was a new question.

I did the following:

Code: [Select]
ffmpeg -i "quelle.dsf" -ar 96000 -af lowpass=f=30000 -c:a pcm_s24le -filter:a "volume=4dB" -map_metadata -1 "ffmpegout96k.wav
and:
Code: [Select]
sox -V3 -S "quelle.dsf" -b 24 "soxout96k.wav" rate -v 96000 gain +4 sinc -30k

The result was two identical files.
FFPROBE:
Code: [Select]
Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 96000 Hz, 5.1, s32 (24 bit), 13824 kb/s
However, after converting to .flac files, I have different bitrates.

Code: [Select]
Input #0, flac, from 'ffmpegout96k.flac':
  Duration: 00:17:07.24, start: 0.000000, bitrate: 8366 kb/s
  Stream #0:0: Audio: flac, 96000 Hz, 5.1, s32 (24 bit)

Code: [Select]
Input #0, flac, from 'soxout96k.flac':
  Duration: 00:17:07.24, start: 0.000000, bitrate: 6655 kb/s
  Stream #0:0: Audio: flac, 96000 Hz, 5.1, s32 (24 bit)

I can't explain why?


Re: HowTo .dsf --> .flac

Reply #13
The result was two identical files.
Maybe of identical size and not with any difference one can hear, but not identical.

Quote
I can't explain why?
With sox, you're using a rather steep filter and with ffmpeg a not so steep one. That means the ffmpeg created file has much more ultrasonic noise still in there, which makes it harder to compress. Just because the cut-off frequency is the same does not mean the filter is the same.
Music: sounds arranged such that they construct feelings.

Re: HowTo .dsf --> .flac

Reply #14
To get high steepness with ffmpeg, you can use sinc+afir. Also, many of available ffmpeg builds are built with sox resampler, but it is not used by default
Code: [Select]
ffmpeg -i "file.dsf" -f lavfi -i sinc=r=96000:lp=30000 -lavfi "aresample=96000:resampler=soxr:precision=28, afir=gtype=none, volume=4dB" -c:a pcm_s24le "file.wav"

Re: HowTo .dsf --> .flac

Reply #15
Quote
To get high steepness with ffmpeg, you can use sinc+afir.
OK. I'll try that. Why does ffmpeg only extract one channel?

Re: HowTo .dsf --> .flac

Reply #16
will probably buy a new player.
Oh, it is a hardware player?
When you said you have tried a few of them, I presumed it was different applications.

Now, if the problem was files > 2 GB ...
You can try to use DST - it is a lossless compression for DSD. Some software discussed on this forum this spring: https://hydrogenaud.io/index.php/topic,124117.0.html
But it is not given that your player supports that.

(Folks ... what file format should one use for DST?)

Re: HowTo .dsf --> .flac

Reply #17
Oh yes, it plays packed dst files with .dff extension. The files are also 50% smaller. But I can't tag them readable for the player yet. I haven't found out yet whether it's possible to use an additional file like the cover with the folder.jpg.

Re: HowTo .dsf --> .flac

Reply #18
@ Bogozo
Quote
afir=gtype=none
This parameter apparently ensures that only one channel is extracted. I haven't found how to change that. If I omit it, I get a .wav file that has the same values as the other two generated above. The file sizes are also identical.

Re: HowTo .dsf --> .flac

Reply #19
Quote
afir=gtype=none
This parameter apparently ensures that only one channel is extracted.
No, it doesn't.

Well, to properly process 5.1, command must be:
Code: [Select]
ffmpeg -i "file.dsf" -f lavfi -i "sinc=r=96000:lp=30000, pan=5.1|c0=c0|c1=c0|c2=c0|c3=c0|c4=c0|c5=c0" -lavfi "aresample=96000:resampler=soxr:precision=28, afir=gtype=none" -c:a pcm_ s24le "file.wav"

And to process stereo, it must be.
Code: [Select]
ffmpeg -i "file.dsf" -f lavfi -i "sinc=r=96000:lp=30000, pan=stereo|c0=c0|c1=c0" -lavfi "aresample=96000:resampler=soxr:precision=28, afir=gtype=none" -c:a pcm_ s24le "file.wav"

Re: HowTo .dsf --> .flac

Reply #20
@Bogozo
Unfortunately, I still don't know enough. When I use your example I get an error:
Spoiler (click to show/hide)

Re: HowTo .dsf --> .flac

Reply #21
I think there's an unintended space in the audio codec in @Bogozo's example.  It should be "pcm_s24le" and not "pcm_ s24le"


Re: HowTo .dsf --> .flac

Reply #23
Oh yes, it plays packed dst files with .dff extension. The files are also 50% smaller. But I can't tag them readable for the player yet. I haven't found out yet whether it's possible to use an additional file like the cover with the folder.jpg.
.dff is not supposed to be tagable, ... I think?

Can the .dsf format not contain DST?

Re: HowTo .dsf --> .flac

Reply #24
OK. That's it. I am blind.
Now I have compared the 3 filter variants.
Here are the results:
Spoiler (click to show/hide)
You can see that the generated WAV files have the same values.
However, the FLAC files have different bit rates and sizes.
Version 3 gives the smallest FLAC file with Bogozo's help.
Is that really just the noise filter?