audioread icon indicating copy to clipboard operation
audioread copied to clipboard

ffdec should not assume s16le format

Open gfidente opened this issue 11 years ago • 4 comments
trafficstars

hi,

ffdec will silently fail (providing unreliable output) when fed with non s16le files cause we enforce it in ffdec.py

maybe just removing the option would allow for autodetection? not sure.

gfidente avatar May 06 '14 15:05 gfidente

Hmm; thanks for pointing this out. That flag (-f s16le) is intended to dictate the output format from ffmpeg, which is necessary, but you seem to be saying that it's causing ffmpeg to be confused about the input format. If you use 24-bit input, we need to resample for consistency.

Do you know how to correctly instruct ffmpeg to produce s16le output when necessary (and preserve the stream untouched when not necessary)? Maybe something to do with this filter?

sampsyo avatar May 06 '14 15:05 sampsyo

hi there, thanks for replying

I don't think we should resample or change the input/output format; such a thing would introduce distortions and degradations so I think we better keep the source unchanged

yet the ffmpeg man page seems a bit confusing to me on the "-f" description:

Force input or output file format. The format is normally auto detected for input files and guessed from the file extension for output files, so this option is not needed in most cases

I think we're forced to set some format for the output as this is outputting into stdout and can't be "guessed". I don't seem to be able to tell ffmpeg to just use same format as input; "-c copy" apparently requires a format anyway!

gfidente avatar May 06 '14 17:05 gfidente

It's really valuable to have audioread output a consistent format. If we pass through the underlying sample format, applications will need to add code to deal with, for example, floating-point formats, which is clearly undesirable.

Also, I totally mistyped in my previous comment: changing the sample format is of course not the same as resampling, which changes the sample rate. Normalizing to 16-bit signed integers will not introduce distortion like resampling might. It does lose information, but I think this is an acceptable trade-off.

Anyway, the ffmpeg CLI is confounding. Somehow we need to adapt the output format while leaving the input format "guessed"...

sampsyo avatar May 06 '14 17:05 sampsyo

just wanted to let you know that loading 8 bit wav files fails as well (returning useless output)

jonasrauber avatar Mar 15 '16 13:03 jonasrauber