Req Implement sox as audio resampler
#1
I am currently playing around with room correction via brutefir and FIR filters.
To reduce the delay I am resampling the output of kodi to 192khz.
I just found out that the quality of the resampling in kodi (even with resampling quality "high")
is not on the same level like on my music computer, where I am using JRiver, with sox as resampler.

As far as I know kodi is using ffmpeg for resampling. With ffmpeg you can also use sox as resampler

https://trac.ffmpeg.org/wiki/FFmpeg%20an...0Resampler
http://www.transcoding.dk/2011/11/16/car...ng-ffmpeg/

Is there a way to include sox-resampling via ffmpeg in kodi?

Maybe activate it over an advancedsettings entry. So at default swr from ffmpeg as resampler will still be used.
Audiophile ones can then maybe switch over advancedsettings to sox.

There is definitly a big improvement in sound quality by using sox instead of swr over ffmpeg.
On the following link a guy did some resampler comparing.

http://src.infinitewave.ca/

I didn´t get it working adding a picture here.
So just go to the mentioned url and select "ffmpeg 1.1.1 (soxr)" and "ffmpeg 1.1.1 (swr)" to compare. Then you should see sox is definitly the better resampler.

I also had a look at the kodi source code.
I already change some files for testing to activate soxr when "high" for quality of resampling is selected.

./xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp

Code:
if(quality == AE_QUALITY_HIGH)
  {
    av_opt_set_double(m_pContext,"cutoff", 1.0, 0);
    //av_opt_set_int(m_pContext,"filter_size", 256, 0);
    av_opt_set(m_pContext,"resampler", "soxr", 0);
    av_opt_set_int(m_pContext,"precision", 28, 0);
    av_opt_set_int(m_pContext,"linear_interp", 1, 0);
  }
  ...
  if (m_dst_fmt == AV_SAMPLE_FMT_S32 || m_dst_fmt == AV_SAMPLE_FMT_S32P)
  {
    // av_opt_set_int(m_pContext, "output_sample_bits", m_dst_bits, 0);
  }

and ./tools/depends/target/ffmpeg/autobuild.sh

Code:
--enable-libsoxr \

and ./tools/depends/target/ffmpeg/CMakeLists.txt

Code:
--enable-libsoxr

then installed libsoxr-dev on my ubuntu system and compiled kodi again.
Build where succesfully but I will not get sound when resampling with quality=high is active in kodi.
I think there is something or bit more missing.
I think I dont have the coding skill to do this.
Maybe the kodi-team is interested in implementing this?
I would also help as far as I can with my limited skills or maybe just for testing.
Reply
#2
I used Sox as a resampler for a stereo to surround upmixer (SpecWeb) but got feedback that it was adding artefacts to the upsampled output. I was shown some samples that clearly showed added spikes in the resampled output from Sox.
Reply
#3
I am using sox on two diffent machines (one via jriver on windows and one linux via piped output to sox command line util). Both without any problem.
So why not give it try?
Reply
#4
Code:
av_opt_set(m_pContext,"resampler", "soxr", 0);

is wrong. It's an integer.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#5
Any news about this?
Reply
#6
I'd love a follow up on this as well. Were you able to figure out how to modify the audio resample settings Kodi uses, or a way to have the resample commands configurable via advancedsettings.xml ?

thanks!
Kodi v17.6 on Asustor NAS
Kodi v17.6 on Fire Stick v2
Reply

Logout Mark Read Team Forum Stats Members Help
Implement sox as audio resampler0