Skip to content
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

ffmpeg must be built with soxr enabled #156

Closed
auroracramer opened this issue Aug 5, 2021 · 5 comments
Closed

ffmpeg must be built with soxr enabled #156

auroracramer opened this issue Aug 5, 2021 · 5 comments

Comments

@auroracramer
Copy link

resample_wav specifies soxr as the resampler for ffmpeg, but when I run heareval.tasks.runner, the assertion fails. Upon further inspection (after commenting out the error redirection to /dev/null and reporting the error code on AssertionError), I get the following errors:

Traceback (most recent call last):                                                                   
  File "/ext3/miniconda3/lib/python3.9/site-packages/luigi/worker.py", line 191, in run              
    new_deps = self._run_get_new_deps()                                                              
  File "/ext3/miniconda3/lib/python3.9/site-packages/luigi/worker.py", line 133, in _run_get_new_deps
    task_gen = self.task.run()                                                                       
  File "/ext3/code/hear-eval-kit/heareval/tasks/pipeline.py", line 628, in run                       
    audio_util.resample_wav(audiofile, resampled_audiofile, self.sr)
  File "/ext3/code/hear-eval-kit/heareval/tasks/util/audio.py", line 80, in resample_wav             
    assert ret == 0, str(ret)                                                                        
AssertionError: 1                                                                                    
[Parsed_aresample_0 @ 0x563d51610e40] [SWR @ 0x563d51611380] Requested resampling engine is unavailable
[Parsed_aresample_0 @ 0x563d51610e40] Failed to configure output pad on Parsed_aresample_0             
Error reinitializing filters!                                                                          
Failed to inject frame into filter network: Invalid argument

I'm using the ffmpeg==4.3.2 (from the conda-forge build), but it appears that soxr is not enabled by default (perhaps according to this) and must be explicitly enabled when building from source according to this page.

What is the best way to reliably install ffmpeg with libsoxr support? If it is from source, it might be good to mention this in the documentation and warn users not to install using conda.

@auroracramer
Copy link
Author

I was able to get it to work building from source with something like this:

CODEDIR="/ext3/code"
BINDIR="/ext3/bin"
mkdir -p $CODEDIR
mkdir -p $BINDIR

# Install libsoxr                                                                                  
git clone https://github.com/chirlu/soxr.git                                                       
mkdir -p $CODEDIR/soxr/build/lib                                                                   
cd $CODEDIR/soxr/build                                                                             
cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=$CODEDIR/soxr/build/output ..
make && make test && make install                                   
                                                    
# Install ffmpeg                                                                                   
cd $CODEDIR                                                                                        
wget https://www.ffmpeg.org/releases/ffmpeg-4.4.tar.gz                                             
tar xvfz ffmpeg-4.4.tar.gz                                                                         
ffmpeg_build_dir="$CODEDIR/ffmpeg_build"                                                           
mkdir -p $ffmpeg_build_dir/lib                                                                     
cd $CODEDIR/ffmpeg-4.4                                                                             
PATH="$BINDIR:$PATH" PKG_CONFIG_PATH="$CODEDIR/lib/pkgconfig" ./configure \                        
  --prefix="$ffmpeg_build_dir" \                                                                   
  --pkg-config-flags="--static" \                                                                  
  --extra-cflags="-I$CODEDIR/soxr/build/output/include" \                                          
  --extra-ldflags="-L$CODEDIR/soxr/build/output/lib" \                                             
  --extra-libs="-lpthread -lm" \                                                                   
  --ld="g++" \                                                                                     
  --bindir="$BINDIR" \                                                                             
  --enable-libsoxr                                                                                 
PATH="$BINDIR:$PATH" make && make install                   

export PATH="$BINDIR:$PATH"                                       

@turian
Copy link
Contributor

turian commented Aug 5, 2021

Are you on ubuntu? You can also try libsox-fmt-ffmpeg.

We added some install instructions here: #158

Thank you for helping us test the software. This package will be out of alpha soon, and we will hopefully test it on a handful of platforms from scratch.

@auroracramer
Copy link
Author

I'm using an Ubuntu singularity container on a compute cluster, so I don't have root access to install through apt, though this dpkg workaround may be able to install it. Either way it's great to know about libsox-fmt-ffmpeg package!

Thanks for putting all of this together, we're excited about this challenge! :)

@turian
Copy link
Contributor

turian commented Aug 5, 2021

@auroracramer okay, good to know. When we finalize the preprocessing, we will be releasing the preprocessed datasets as tar-files, so running luigi+sox preprocessing will not be necessary for end-user competitors.

We are glad you are excited about the challenge! We are too. Tell your friends, tell your enemies. The more people who enter, the more attention your entry and PMLR writeup will get :)

@turian
Copy link
Contributor

turian commented Sep 9, 2021

@auroracramer moving this issue to the hear-preprocess repo: hearbenchmark/hear-preprocess#80. If you have any more questions or comments, feel free to re-open or open a new issue.

@turian turian closed this as completed Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants