Skip to content

Commit

Permalink
Upgrade to FFmpeg5 (#3298)
Browse files Browse the repository at this point in the history
Summary:
This commit upgrade the version of FFmpeg compiled against TorchAudio binary distribution to 5.0.4.

FFmpeg 5.0 was released in Jan 2022, and many package managers provide a version of FFmpeg v5.
Conda-forge lists 5.1 for all the platforms TorchAudio supports.https://anaconda.org/conda-forge/ffmpeg

Pull Request resolved: #3298

Reviewed By: hwangjeff

Differential Revision: D45865599

Pulled By: mthrok

fbshipit-source-id: d95638eb80daaf477a710a992f4ead9b9009bb9b
  • Loading branch information
mthrok authored and facebook-github-bot committed May 16, 2023
1 parent e4c1d70 commit d38a785
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 50 deletions.
12 changes: 4 additions & 8 deletions .circleci/config.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ jobs:
name: smoke test
command: |
source /usr/local/etc/profile.d/conda.sh && conda activate python${PYTHON_VERSION}
conda install 'ffmpeg<5'
conda install 'ffmpeg>=5.0,<6'
./test/smoke_test/run_smoke_test.sh

smoke_test_linux_conda_gpu:
Expand All @@ -485,7 +485,7 @@ jobs:
name: smoke test
command: |
source /usr/local/etc/profile.d/conda.sh && conda activate python${PYTHON_VERSION}
conda install 'ffmpeg<5'
conda install 'ffmpeg>=5.0,<6'
./test/smoke_test/run_smoke_test.sh

smoke_test_linux_pip:
Expand Down Expand Up @@ -537,11 +537,7 @@ jobs:
command: |
eval "$('/C/tools/miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
conda activate python${PYTHON_VERSION}
if [[ "${PYTHON_VERSION}" == "3.11" ]]; then
conda install -c conda-forge ffmpeg=4.4.2
else
conda install 'ffmpeg<5'
fi
conda install 'ffmpeg>=5.0,<6'
./test/smoke_test/run_smoke_test.sh

smoke_test_windows_conda_gpu:
Expand All @@ -568,7 +564,7 @@ jobs:
conda env remove -n python${PYTHON_VERSION} || true
conda create -yn python${PYTHON_VERSION} python=${PYTHON_VERSION}
conda activate python${PYTHON_VERSION}
conda install -v -y ${CONDA_CHANNEL_FLAGS:-} -c pytorch-${UPLOAD_CHANNEL} -c nvidia pytorch numpy ffmpeg pytorch-cuda=${CU_VERSION:2:2}.${CU_VERSION:4}
conda install -v -y ${CONDA_CHANNEL_FLAGS:-} -c pytorch-${UPLOAD_CHANNEL} -c nvidia pytorch numpy 'ffmpeg>=5.0,<6' pytorch-cuda=${CU_VERSION:2:2}.${CU_VERSION:4}

# Install from torchaudio file
conda install -v -y $(ls ~/workspace/conda-bld/win-64/torchaudio*.tar.bz2)
Expand Down
2 changes: 1 addition & 1 deletion .circleci/unittest/linux/scripts/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ conda activate "${env_dir}"

# 3. Install minimal build tools
pip --quiet install cmake ninja
conda install --quiet -y 'ffmpeg>=4.1' pkg-config
conda install --quiet -y -c conda-forge 'ffmpeg==5.1' pkg-config
2 changes: 1 addition & 1 deletion .circleci/unittest/windows/scripts/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ conda activate "${env_dir}"

# 3. Install minimal build tools
pip --quiet install cmake ninja
conda install --quiet -y 'ffmpeg>=4.1'
conda install --quiet -y -c conda-forge 'ffmpeg==5.1'
2 changes: 1 addition & 1 deletion .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
# Install torchaudio
# TODO: Enable NVDec/NVEnc
conda install --quiet -y 'ffmpeg>=4.1' pkg-config
conda install --quiet -y -c conda-forge 'ffmpeg>=5.0,<6' pkg-config
pip --quiet install cmake>=3.18.0 ninja
cd packaging
. ./pkg_helpers.bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unittest-linux-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
"${CUDATOOLKIT}"
# Install torchaudio
conda install --quiet -y 'ffmpeg>=4.1' pkg-config
conda install --quiet -y -c conda-forge 'ffmpeg==5.1' pkg-config
python3 -m pip --quiet install cmake>=3.18.0 ninja
USE_FFMPEG=1 python3 -m pip install -v -e . --no-use-pep517
Expand Down
6 changes: 3 additions & 3 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Please refer to https://pytorch.org/get-started/locally/ for the details.
each of which requires a corresponding PyTorch distribution.

.. note::
This software was compiled against an unmodified copy of FFmpeg (licensed under `the LGPLv2.1 <https://github.com/FFmpeg/FFmpeg/blob/a5d2008e2a2360d351798e9abe883d603e231442/COPYING.LGPLv2.1>`_), with the specific rpath removed so as to enable the use of system libraries. The LGPL source can be downloaded `here <https://github.com/FFmpeg/FFmpeg/releases/tag/n4.1.8>`_.
This software was compiled against an unmodified copy of FFmpeg (licensed under `the LGPLv2.1 <https://github.com/FFmpeg/FFmpeg/blob/0e15444aceca0e78f99f3d67758eb79d11b86599/COPYING.LGPLv2.1>`_), with the specific rpath removed so as to enable the use of system libraries. The LGPL source can be downloaded `here <https://github.com/FFmpeg/FFmpeg/releases/tag/n5.0.3>`_.

Dependencies
------------
Expand All @@ -31,8 +31,8 @@ Optional Dependencies
* `FFmpeg <https://ffmpeg.org>`_.

Required to use :py:mod:`torchaudio.io` module.
TorchAudio official binary distributions are compatible with FFmpeg 4.1 to 4.4.
If you need to use FFmpeg 5, please build TorchAudio from source.
TorchAudio official binary distributions are compatible with FFmpeg 5.
If you need to use FFmpeg 6, please build TorchAudio from source.

* `sentencepiece <https://pypi.org/project/sentencepiece/>`_

Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/device_asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
.. note::
This tutorial requires FFmpeg libraries (>=4.1, <4.4) and SentencePiece.
This tutorial requires FFmpeg libraries (>=5.0, <6) and SentencePiece.
There are multiple ways to install FFmpeg libraries.
If you are using Anaconda Python distribution,
``conda install 'ffmpeg<4.4'`` will install
``conda install -c conda-forge 'ffmpeg<6'`` will install
the required FFmpeg libraries.
You can install SentencePiece by running ``pip install sentencepiece``.
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/effector_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#
# .. note::
#
# This tutorial requires FFmpeg libraries (>=4.1, <5).
# This tutorial requires FFmpeg libraries (>=5.0, <6).
#
# There are multiple ways to install FFmpeg libraries.
# If you are using Anaconda Python distribution,
# ``conda install -c anaconda 'ffmpeg<5'`` will install
# ``conda install -c conda-forge 'ffmpeg<6'`` will install
# the required libraries.
#

Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/online_asr_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#
# .. note::
#
# This tutorial requires FFmpeg libraries (>=4.1, <4.4) and SentencePiece.
# This tutorial requires FFmpeg libraries (>=5, <6) and SentencePiece.
#
# There are multiple ways to install FFmpeg libraries.
# If you are using Anaconda Python distribution,
# ``conda install 'ffmpeg<4.4'`` will install
# ``conda install -c conda-forge 'ffmpeg<6'`` will install
# the required FFmpeg libraries.
#
# You can install SentencePiece by running ``pip install sentencepiece``.
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/streamreader_basic_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#
# .. note::
#
# This tutorial requires FFmpeg libraries (>=4.1, <4.4).
# This tutorial requires FFmpeg libraries (>=5.0, <6).
#
# There are multiple ways to install FFmpeg libraries.
# If you are using Anaconda Python distribution,
# ``conda install -c anaconda 'ffmpeg<4.4'`` will install
# ``conda install -c conda-forge 'ffmpeg<6'`` will install
# the required libraries.
#

Expand Down
13 changes: 5 additions & 8 deletions examples/tutorials/streamwriter_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@
#
# .. note::
#
# This tutorial requires torchaudio nightly build and FFmpeg libraries (>=4.1, <4.4).
#
# To install torchaudio nightly build, please refer to
# https://pytorch.org/get-started/locally/ .
#
# This tutorial requires FFmpeg libraries (>=5.0, <6).
#
# There are multiple ways to install FFmpeg libraries.
# If you are using Anaconda Python distribution,
# ``conda install 'ffmpeg<4.4'`` will install the required FFmpeg libraries,
# however, this distribution does not have SDL plugin, so it cannot play
# video.
# ``conda install -c conda-forge 'ffmpeg<6'`` will install
# the required libraries.
# This distribution, however, does not have SDL plugin, so
# it cannot play video.
#

######################################################################
Expand Down
8 changes: 3 additions & 5 deletions examples/tutorials/streamwriter_basic_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
#
# .. note::
#
# This tutorial requires torchaudio nightly build and FFmpeg libraries (>=4.1, <4.4).
#
# To install torchaudio nightly build, please refer to
# https://pytorch.org/get-started/locally/ .
# This tutorial requires FFmpeg libraries (>=5.0, <6).
#
# There are multiple ways to install FFmpeg libraries.
# If you are using Anaconda Python distribution,
# ``conda install 'ffmpeg<4.4'`` will install the required FFmpeg libraries.
# ``conda install -c conda-forge 'ffmpeg<6'`` will install
# the required libraries.
#

######################################################################
Expand Down
12 changes: 6 additions & 6 deletions packaging/ffmpeg/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cd "${build_dir}"
# NOTE:
# When changing the version of FFmpeg, update the README so that the link to the source points
# the same version.
curl -LsS -o ffmpeg.tar.gz https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n4.1.8.tar.gz
curl -LsS -o ffmpeg.tar.gz https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n5.0.3.tar.gz
tar -xf ffmpeg.tar.gz --strip-components 1
./configure \
--prefix="${prefix}" \
Expand Down Expand Up @@ -72,11 +72,11 @@ ls ${prefix}/*
# macOS: Fix rpath so that the libraries are searched dynamically in user environment.
# In Linux, this is handled by `--enable-rpath` flag.
if [[ "$(uname)" == Darwin ]]; then
avcodec=libavcodec.58
avdevice=libavdevice.58
avfilter=libavfilter.7
avformat=libavformat.58
avutil=libavutil.56
avcodec=libavcodec.59
avdevice=libavdevice.59
avfilter=libavfilter.8
avformat=libavformat.59
avutil=libavutil.57

otool="/usr/bin/otool"
# NOTE: miniconda has a version of otool and install_name_tool installed and we want
Expand Down

0 comments on commit d38a785

Please sign in to comment.