Preserve bitdepth of input audio file during conversion to wav
Hello to all, i would like to ask you. Is there any FFmpeg option or trick to preserve bitdepth of input file during decompression to wave file? For instance during conversion of 24bit FLAC or ALAC audio to WAV. When i use straight "ffmpeg -i whatever-24bit.flac output.wav", resulting file is always coded as PCM_S16LE. I didn't find any way, how to do this, except of some wrapper script, which will run ffmpeg or ffprobe before conversion, parse it's output for audio stream info and set proper format to subsequent conversion. However this approach is quite cumbersome, because it needs to lookup in some table with corresponding formats for particular codec as for instance ALAC with bitdepth > 16bit has format PCM_S32P which usually needs to be adjusted to PCM_S24LE for output wav. And on Windows it also requires to install some additional script interpreter (like cygwin bash and coreutils or python). Thanks Michal
Michal Šmucr <msmucr <at> gmail.com> writes:
When i use straight "ffmpeg -i whatever-24bit.flac output.wav", resulting file is always coded as PCM_S16LE.
(Complete, uncut console output missing.) If you do not specify a (audio) codec with -acodec xyz ffmpeg will use the one that is set as default for the file type you used. In your case you chose "wav" as file type and since you did not specify a codec (and since no human being can distinguish between the original 32bit source and the 16bit encoding), 16bit pcm is used. Carl Eugen
Hello Carl Eugen, thank you for reply. I wrote that command to question only as an example, but if you'd like to see it, i have attached output from one conversion. I understand to behavior of FFmpeg and its basic logic with setting default options of target format, which is guessed from output file extension. But i think, it is not good in case of lossless audio formats, i should wrote it clearly, that i aimed only to that. Main point of its usage is, that these codecs don't modify PCM content (regardless someone will hear that or not, that is different question to me), so you can use it for instance during archiving. Its coding and decoding should be transparent. And in this particular case - conversion to uncompressed WAV (or AIFF), FFmpeg should (IMO) output some default flavor of codec (eg. most used signed LE) and pick shortest appropriate wordlength to avoid truncation. For sure, it is not error, but rather usability thing. Generally, using of FFmpeg for this tasks is very convenient, because it is not necessary to utilize special tool for each lossless codec (eg. flac, wvunpack, wavpack.. plus many which don't have its unix tool) and have also useful mappings between particular metadata formats, but if you try to use it with mixed bitdepths, it falls short without mentioned wrapper. So i asked mainly, if i didn't miss some option for that. Michal 2013/11/27 Carl Eugen Hoyos <cehoyos@ag.or.at>:
Michal Šmucr <msmucr <at> gmail.com> writes:
When i use straight "ffmpeg -i whatever-24bit.flac output.wav", resulting file is always coded as PCM_S16LE.
(Complete, uncut console output missing.)
If you do not specify a (audio) codec with -acodec xyz ffmpeg will use the one that is set as default for the file type you used. In your case you chose "wav" as file type and since you did not specify a codec (and since no human being can distinguish between the original 32bit source and the 16bit encoding), 16bit pcm is used.
Carl Eugen
_______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
participants (2)
-
Carl Eugen Hoyos -
Michal Šmucr