-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Sample format for Audio files #101
Comments
Should be easy to implement. I will add that. |
I checked if the parameter can be added. Actually it is not so easily possible. The FFmpeg API supports these formats: U8: unsigned 8 bits U8P: unsigned 8 bits, planar This does not mean that the target necessarily supports all these. And selecting a format does not necessarily create the expected result. For example, creating a flac with S32: For WAV, s16 seems to be supported only. |
I was more or less aware of this, actually |
I think I will add the parameter anyway, but it requires a bit more work than expected:
For example, I could successfully create S16 WAV files with ffmpeg only. Other formats failed... For FLAC, S16 and S32 worked. That created 16 and 24 bit files, respectively. Well, like said, I*ll add it but it will take some time :) |
I did a bit of research and actually when using s32 we do expect 24 bit files (padded to 32 bits) from the FLAC encoder
Weird, I do have 24 bit and 32 bit WAV files on my library!
Sure thing! |
Not weird, WAV can have 8 to 64 bits sample size: 8-bit 16.8 floating point To create them with FFmpeg, you have to select the correct codec, not the sample format (there is always only one for each of these codecs, very confusing :) Example: |
I have fiddled about with the sample format, and it turned out that setting the sample_fmt parameter not really does what we would like to happen. First of all, most formats only support flt.
This makes things rather awkward. For WAV, I need to select the proper codec, For others, I have to select flt and probably set bits_per_raw_sample (need to check if that works). For formats that do not support flt (ALAC), I would have to select s16, s32 etc. For ProRes, that only has s16 support, there is probably no way to do anything. This little option appears to be quite a big thing :) |
Note: I just created two mp3s with ffmpeg: 32 bit sample format: 16 bit sample format: Both result files have the same size and are binary the same. Note the hint "s32p (16 bit)". I am afraid the parameter could work on WAV only... Or probably on FLAC, but I*d have to add that format, though. |
Finally I understood the whole problem. Bit depth, or "sample format", does not apply to lossy formats. The encoding process loses this information. You can feed s32 into the mp3 encoder, for example, but the encoded file does not contain this detail. In fact, encoding a 24 bit source can result in a better quality mp3 than an 16 bit original, but you won*t be able to determine that from the encoded file. Thus, lossless formats only (e.g. WAV, AIFF, ALAC and FLAC) will keep that information. Means, that the current implementation in FFmpegfs will always create 16 bit AIFF or WAV, up- or downgrading the source if necessary. ALAC files will be 16 or 32 bit, depending on the source (a 32 or 16 bit source will create a 32 or 16 bit ALAC, respectively. 8 bit will be upgraded to 16 bit as ALAC does not suppord 8 bit). So for you, creating WAVs/AIFFs will always result in CD quality (16 bit) files (provided you limit the sample rate to 44.1 kHz with --audiosamplerate=44.1K). I think I will add extra destination types, like WAV8, WAV32 or ALAC16/32 to allow selecting a bit width for these types (#106). Possibly I could add FLAC that at least allows 16 or 24 bit. See #105. But for all lossy formats, MP3, MP4, WebM etc. the option does not apply. |
After some research, I decided to add this parameter instead of #105. The possible settings are:
This option is only available for lossless formats, but not all formats support all options:
Invalid combinations will be reported as command line error. |
I have a bunch of 24 bit / >= 48KHz FLAC files. I would like to transcode them to the standard CD-quality 16 bit / 44.1KHz format, and as of now, I don't see a way of specifying the sample format in the
man
page. Therefore, I am requesting for a setting to be added as follows:The text was updated successfully, but these errors were encountered: