Skip to main content

Topic: a command line conversion program that i can pass wavpack arguments to? (Read 2755 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
a command line conversion program that i can pass wavpack arguments to?
Os: Linux
shell: zsh
gstreamer: 1.8.3
wavpack: 5.0.0
flac: 1.3.1-r1
sox: 14.4.2
ffmpeg: 3.2.2
beets: git  ( https://github.com/beetbox/beets )

I had briefly changed over from using wavpack to flac, and after being dissatisfied with flac, i'm back to wavpack again. I'm sorry Brant! I'll never leave you again! So, i'm looking to convert my collection (some 17k files) back again.

I use the beets tagger to organize my music collection. With it i can issue a "convert" command that takes a script or commandline and converts files in my collection from one codec to another.  I can use any command i like and currently, i'm trying it with gstreamer. Right now, it looks like this:
Code: [Select]
[gst-launch-1.0 filesrc location="$source" ! decodebin ! audioconvert ! wavpackenc extra-processing=1 md5=true ! apev2mux ! filesink location="$dest"

However, gstreamer seems to be limited in what i can pass to wavpack. What i'd like the convert script/program to do is the equivalent of
Code: [Select]
wavpack -hhx3md -w Encoder -w Settings
and convert to 16/44.1 when applicable.

I've played with all the apps listed above. I suppose i'm just better off writing a script, yes?

  • Last Edit: 17 December, 2016, 01:38:12 AM by kode54
Music lover and recovering high end audiophile

  • bryant
  • [*][*][*][*][*]
  • Developer (Donating)
Re: a command line conversion program that i can pass wavpack arguments to?
Reply #1
Well, don't worry, I don't take it personally. Everyone has to use what they feel is best for them. My mom switched to FLAC too and I got over it!  :)

I would be a little careful with gstreamer for encoding. At one point it was putting the Ape tags at the beginning of the file.

Of course, if method you're suggesting copied all the tags that you needed and did any audio conversion you needed, you could simply use the most basic WavPack settings for encode (so everything would be super fast), and then use the command-line wavpack program to transcode to the exact settings you wanted, including adding the “Encoder” and “Settings” or any other tweaks you like.

Even if gstreamer puts the tags at the beginning, when you transcode they'll be put back at the end, and this will also give you the latest stream format (5).

Re: a command line conversion program that i can pass wavpack arguments to?
Reply #2
Ahh, i didn't know that gstreamer might be doing that. Thank you.
When you say that i can use the wavpack program to encode, you mean that it can encode in-place? Also, it doesn't look like i can convert to 16/44 with wavpack and that i'll need another tool. I'm leaning towards sox.  Caudec used to do just what i needed, but it's a dead project.
Music lover and recovering high end audiophile

  • bryant
  • [*][*][*][*][*]
  • Developer (Donating)
Re: a command line conversion program that i can pass wavpack arguments to?
Reply #3
Yes, the command-line encoder (wavpack) will accept WavPack files as source and overwrite the original file (with the -y option). I always recommend using -v also in this case because then wavpack will decode the entire generated file and verify an exact match before deleting the source file and renaming the temporary file.

As for converting to 16/44.1, sox would certainly work. I thought you were suggesting gstreamer for that too in your original post, and I think it can do stuff like that (not sure), but sox is certainly a less risky choice. Obviously you have to have some way to preserve your tags.

Now most people will consider this suggestion crazy, but I would use WavPack lossy mode to encode the 24/96 sources, using a bitrate of 768 kbps (or 4 bits per sample), which would result in just about the same bitrate as down-sampling to 16/44.1 lossless. Both operations are very lossy, but one of them preserves the 24 bits of dynamic range and 40+ kHz bandwidth, and the other doesn't.

The disadvantage of that is that resulting file is a little specialized, and if you ever went back to FLAC again you'd have to downsample it then, and it would be from a lossy source.

Re: a command line conversion program that i can pass wavpack arguments to?
Reply #4
The converting to a lossy is an idea (this stuff is why i love wavpack). i suppose doing a hybrid of that rate would allow me to move back to flac or what have you, but it would remove the space saving advantage, right?

Using Sox, i get warnings:
Code: [Select]
sox -S "01-finest_worksong.flac" -r 44100 -b 16 01-finest.wv 
i get warnings

sox WARN rate: rate clipped 78 samples; decrease volume?
sox WARN dither: dither clipped 73 samples; decrease volume?

I donno if that's making an audible difference and in any case it doesn't transfer tags.


I don't mean to turn this into a "help me do my research, 'cause i'm too lazy" thread, i was just wondering if you or anyone else had a solution that you used commonly that could be easily inserted into another script.  I'll keep looking and report back here in case anyone else would find it useful as well.  Right now, i'm going through the Caudec code by @skamp to see if i can glean any info from that, since it seemed to do what i wanted albeit not working consistently.
Music lover and recovering high end audiophile

  • bennetng
  • [*][*][*][*][*]
Re: a command line conversion program that i can pass wavpack arguments to?
Reply #5
I donno if that's making an audible difference
If you only need "inaudible differences", simply use any lossy formats and use a preset which is transparent to you. In case you are paranoid about clipping regardless of audibility:

http://sox.sourceforge.net/sox.html
Quote
−G, −−guard
Automatically invoke the gain effect to guard against clipping. E.g.
   sox −G infile −b 16 outfile rate 44100 dither −s
  • Last Edit: 18 December, 2016, 06:16:57 AM by bennetng

  • bryant
  • [*][*][*][*][*]
  • Developer (Donating)
Re: a command line conversion program that i can pass wavpack arguments to?
Reply #6
The converting to a lossy is an idea (this stuff is why i love wavpack). i suppose doing a hybrid of that rate would allow me to move back to flac or what have you, but it would remove the space saving advantage, right?
Right, if you used hybrid lossless then you would end up with something no smaller that the lossless 24/96 (at least until you decided to delete the correction files).

As for the SoX, yeah I thought you might run into trouble with the tagging (which I think SoX has never handled).

FFmpeg does sample rate conversion too and I'm pretty sure it retains tags; certainly worth a shot.

As for the clipping, this is pretty common when "almost" clipping material is resampled. You can always just reduce the gain 1/2 a dB or so and it should go away.

I donno if that's making an audible difference
If you only need "inaudible differences", simply use any lossy formats and use a preset which is transparent to you.

That's fine, but if the original 24/96 was going to be deleted (because it's a huge waste of space), then I wouldn't want my only backup copy to be a lossy codec like AAC or Opus. What if I changed my mind later and wanted a different lossy codec or setting? Even though they're also lossy copies, I would definitely prefer either a 16/44.1 conversion or a lossy WavPack 24/96 as the replacement "master", and the OP has already indicated that they don't feel that those bitrates (about 750-1000 kbps) are unacceptable.

Re: a command line conversion program that i can pass wavpack arguments to?
Reply #7
Thanks @bryant.  I'm still searching. If i come up with a good solution i'll post it in this thread, in case anyone else needs the same thing.
Music lover and recovering high end audiophile