FS#45186 - [ffmpeg] Please include libsoxr support in build
Attached to Project:
Arch Linux
Opened by Luis Quiles (lquiles) - Tuesday, 02 June 2015, 23:36 GMT
Last edited by Maxime Gauduin (Alucryd) - Tuesday, 28 July 2015, 22:20 GMT
Opened by Luis Quiles (lquiles) - Tuesday, 02 June 2015, 23:36 GMT
Last edited by Maxime Gauduin (Alucryd) - Tuesday, 28 July 2015, 22:20 GMT
|
Details
Description:
FFmpeg's own resampler (SWR) is of notoriously poor quality. It can use SoX resampler (soxr), though. Please add --enable-libsoxr to PKGBUILD. |
This task depends upon
Closed by Maxime Gauduin (Alucryd)
Tuesday, 28 July 2015, 22:20 GMT
Reason for closing: Fixed
Additional comments about closing: 1:2.7.2-2
Tuesday, 28 July 2015, 22:20 GMT
Reason for closing: Fixed
Additional comments about closing: 1:2.7.2-2
It does its job perfectly fine as it is. Audacity, for example, uses it internally.
It was complaints about quality issues of swr in the first place that got FFmpeg developers to include soxr support.
Explaining what needs work (resampling? mixing? format conversion?) and some comparisons of the output from other resamplers like Soxr would greatly help improve the library.
There is no upstream issue. No one upstream is making a fuss about having libsoxr support in FFmpeg or contesting its better quality compared to the computationally cheaper swr. Should FFmpeg developers be interested in improving swr they have at least two different open-source resamplers of proven higher quality (src, soxr) at their disposal to consider.
FFmpeg currently supports two resamplers: swr and soxr. One is internal, the other external. Both are equally relevant to FFmpeg's functionality. One does not come at the expense of the other.
I requested the addition of --enable-libsoxr flag so that the higher quality resampler which FFmpeg documentation clearly refers to, see ffmpeg-resampler(1), would be available in Arch's default FFmpeg build. That is all. Otherwise, most self-respecting users of FFmpeg can just go ahead and do a local build all the same with this switch added.
What exactly is "the way to go," Barthalion? If you don't wish to add this flag for any odd reason you are of course the sole decision maker on this package and can do so. It must be understood, however, that this is not an upstream issue in any way, shape, or form.
There have been no core changes to swr since late 2012 and addition of libsoxr support. The algorithm has not changed, of course, and changes affecting quality have not been added. There are bug fixes and peformance optimizations such as SSE and AVX support. The mathematics of transformations applied does not change either. FFmpeg's swr is made to be fast and computationally cheap which is important to playback software, like mpv, that rely on FFmpeg. While libsoxr (derived from SoX) aims for high quality conversion; at a computational cost. The importance of being fast and cheap has rapidly declined. Even a low-end recent machine can comfortably use libsoxr conversion in playback, let alone transcoding.
Anecdote: In my personal A/V playback setup I use upsampling (for most audio which comes in 44.1 kHz or 48 kHz) to 96 kHz because I have a D/A converter that's happier with 96 kHz. It outputs to a pair of studio monitors. I use mpv to play multimedia. Prior to learning of libsoxr support in FFmpeg and enabling it in a local build I heard occasional transient clicks generated in the audio output. I assumed it was a source defect or I/O latency of transport but disabling upsampling at the price of the D/A converter not being as happy revealed the source was clean. I could probably have decided that based on unrepeatability of the clicks that it was not a source problem. I still had to rule out latency issues. It turned out simply playing back the media at its native sample rate resolved the click issue. So I looked further into mpv resampling and traced the problem to FFmpeg and its default resampler. Doing the local build and passing the right lavfi bridge parameters to mpv to serve to FFmpeg resolved the click issue in upsampling. I had different quality and performance issues with MPD's internal resampler that were also resolved by using its support for libsoxr. I added a request for inclusion of libsoxr support in Arch's MPD build and the maintainer kindly agreed to it. No complaints so far. (Plus, others and I are spared remembering to do a local build at every update.)
There have been a some changes since 2012 that affected the quality of the audio generated by the library, and probably more than those listed there since the tests were only added in late 2013.
I'm not against the inclusion of libsoxr for that matter. It wouldn't affect the default behavior of using swr's internal resampling unless explicitly requested, and since it's now been moved to the extra repository it's certainly guaranteed to be maintained. The more options available the better.
But as i said before if you have reproducible examples where the swr's quality is below other resampling libraries you should either open a ticket in ffmpeg's trac, send an email to the ffmpeg-devel list or directly to Michael Niedermayer (the maintainer). He's always open to suggestions and feedback and countless times fixed and improved code this way.
I agree it would have been best if I had examples but I was motivated to open this task due to the problem I mentioned in my earlier comment and then looking into quality of resamplers. The problem was nuisome. I had nothing but an elusive hope that changing to soxr would fix it. Thankfully, it did. Even the resource that compares qualities does not look for random clicks in the output audible on high quality speakers. They're not supposed to be there regardless of how computationally cheap the resampler is, as long as it is sound in theory and implementation. It is almost certainly a bug and not a characteristic of swr. On hand, I have nothing but that anecdote. It is possible if some FFmpeg people have a similar audio setup they may be able to observe similar degradation.