From 741b0125de60ddfccca25e37de8a724c636aed05 Mon Sep 17 00:00:00 2001 From: moto <855818+mthrok@users.noreply.github.com> Date: Mon, 14 Aug 2023 15:36:36 -0400 Subject: [PATCH] Update pre-built ffmpeg4 to 4.4.4 --- docs/source/installation.rst | 20 +++++++++-- examples/tutorials/device_asr.py | 33 +++++++++---------- examples/tutorials/effector_tutorial.py | 25 ++++---------- examples/tutorials/online_asr_tutorial.py | 9 ++--- .../tutorials/streamreader_basic_tutorial.py | 9 ++--- examples/tutorials/streamwriter_advanced.py | 11 ++----- .../tutorials/streamwriter_basic_tutorial.py | 9 ++--- third_party/ffmpeg/multi/CMakeLists.txt | 20 +++++------ 8 files changed, 61 insertions(+), 75 deletions(-) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 32cef7d52b..44d64a8d38 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -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 copies of FFmpeg, with the specific rpath removed so as to enable the use of system libraries. The LGPL source can be downloaded from the following locations: `n4.1.8 `__ (`license `__), `n5.0.3 `__ (`license `__) and `n6.0 `__ (`license `__). + This software was compiled against an unmodified copies of FFmpeg, with the specific rpath removed so as to enable the use of system libraries. The LGPL source can be downloaded from the following locations: `n4.1.8 `__ (`license `__), `n5.0.3 `__ (`license `__) and `n6.0 `__ (`license `__). Dependencies ------------ @@ -25,18 +25,28 @@ Dependencies Please refer to the compatibility matrix bellow for supported PyTorch versions. +.. _optional_dependencies: + Optional Dependencies ~~~~~~~~~~~~~~~~~~~~~ +.. _ffmpeg: + * `FFmpeg `__ Required to use :py:mod:`torchaudio.io` module. and ``backend="ffmpeg"`` in `I/O functions <./torchaudio.html#i-o>`__. Starting version 2.1, TorchAudio official binary distributions are compatible with - FFmpeg version 6, 5 and 4. At runtime, TorchAudio first looks for FFmpeg 6, + FFmpeg version 6, 5 and 4. (>=4.4, <7). At runtime, TorchAudio first looks for FFmpeg 6, if not found, then it continues to looks for 5 and move on to 4. + There are multiple ways to install FFmpeg libraries. + Please refer to the official documentation for how to install FFmpeg. + If you are using Anaconda Python distribution, + ``conda install -c conda-forge 'ffmpeg<7'`` will install + compatible FFmpeg libraries. + If you need to specify the version of FFmpeg TorchAudio searches and links, you can specify it via the environment variable ``TORCHAUDIO_USE_FFMPEG_VERSION``. For example, by setting ``TORCHAUDIO_USE_FFMPEG_VERSION=5``, TorchAudio will only look for FFmpeg @@ -46,6 +56,11 @@ Optional Dependencies the FFmpeg integration entirely by setting the environment variable ``TORCHAUDIO_USE_FFMPEG=0``. + There are multiple ways to install FFmpeg libraries. + If you are using Anaconda Python distribution, + ``conda install -c conda-forge 'ffmpeg<7'`` will install + compatible FFmpeg libraries. + .. note:: When searching for FFmpeg installation, TorchAudio looks for library files @@ -86,6 +101,7 @@ Optional Dependencies * `sentencepiece `__ Required for performing automatic speech recognition with :ref:`Emformer RNN-T`. + You can install it by running ``pip install sentencepiece``. * `deep-phonemizer `__ diff --git a/examples/tutorials/device_asr.py b/examples/tutorials/device_asr.py index 01e90a4440..281b596d8f 100644 --- a/examples/tutorials/device_asr.py +++ b/examples/tutorials/device_asr.py @@ -7,26 +7,23 @@ This tutorial shows how to use Emformer RNN-T and streaming API to perform speech recognition on a streaming device input, i.e. microphone on laptop. - -.. note:: - - This tutorial requires FFmpeg libraries (>=4.1, <7) and SentencePiece. - - There are multiple ways to install FFmpeg libraries. - If you are using Anaconda Python distribution, - ``conda install -c conda-forge 'ffmpeg<7'`` will install - compatible FFmpeg libraries. - - You can install SentencePiece by running ``pip install sentencepiece``. - -.. note:: - - This tutorial was tested on MacBook Pro and Dynabook with Windows 10. - - This tutorial does NOT work on Google Colab because the server running - this tutorial does not have a microphone that you can talk to. """ +###################################################################### +# +# .. note:: +# +# This tutorial requires FFmpeg libraries. +# Please refer to :ref:`FFmpeg dependency ` for +# the detail. +# +# .. note:: +# +# This tutorial was tested on MacBook Pro and Dynabook with Windows 10. +# +# This tutorial does NOT work on Google Colab because the server running +# this tutorial does not have a microphone that you can talk to. + ###################################################################### # 1. Overview # ----------- diff --git a/examples/tutorials/effector_tutorial.py b/examples/tutorials/effector_tutorial.py index e0ee8c7084..d1fdce7fad 100644 --- a/examples/tutorials/effector_tutorial.py +++ b/examples/tutorials/effector_tutorial.py @@ -13,12 +13,9 @@ # # .. note:: # -# This tutorial requires FFmpeg libraries (>=4.1, <7). -# -# There are multiple ways to install FFmpeg libraries. -# If you are using Anaconda Python distribution, -# ``conda install -c conda-forge 'ffmpeg<7'`` will install -# compatible FFmpeg libraries. +# This tutorial requires FFmpeg libraries. +# Please refer to :ref:`FFmpeg dependency ` for +# the detail. # ###################################################################### @@ -42,25 +39,15 @@ ###################################################################### # -try: - from torchaudio.io import AudioEffector, CodecConfig -except ImportError as err: - raise RuntimeError( - "This tutorial requires nightly build of TorchAudio. " - "Please install the nightly versions of PyTorch and torchaudio. " - "https://pytorch.org/get-started/locally/" - ) from err +from torchaudio.io import AudioEffector, CodecConfig import matplotlib.pyplot as plt from IPython.display import Audio ###################################################################### # -try: - for k, v in torchaudio.utils.ffmpeg_utils.get_versions().items(): - print(k, v) -except Exception: - raise RuntimeError("This tutorial requires FFmpeg libraries 4.2>,<5. " "Please install FFmpeg.") +for k, v in torchaudio.utils.ffmpeg_utils.get_versions().items(): + print(k, v) ###################################################################### # Usage diff --git a/examples/tutorials/online_asr_tutorial.py b/examples/tutorials/online_asr_tutorial.py index 03b8e91759..2995bd3d97 100644 --- a/examples/tutorials/online_asr_tutorial.py +++ b/examples/tutorials/online_asr_tutorial.py @@ -13,14 +13,11 @@ # # .. note:: # -# This tutorial requires FFmpeg libraries (>=4.1, <7) and SentencePiece. +# This tutorial requires FFmpeg libraries and SentencePiece. # -# There are multiple ways to install FFmpeg libraries. -# If you are using Anaconda Python distribution, -# ``conda install -c conda-forge 'ffmpeg<7'`` will install -# compatible FFmpeg libraries. +# Please refer to :ref:`Optional Dependencies ` +# for the detail. # -# You can install SentencePiece by running ``pip install sentencepiece``. ###################################################################### # 1. Overview diff --git a/examples/tutorials/streamreader_basic_tutorial.py b/examples/tutorials/streamreader_basic_tutorial.py index ce94088c79..599bf4ca15 100644 --- a/examples/tutorials/streamreader_basic_tutorial.py +++ b/examples/tutorials/streamreader_basic_tutorial.py @@ -14,12 +14,9 @@ # # .. note:: # -# This tutorial requires FFmpeg libraries (>=4.1, <7). -# -# There are multiple ways to install FFmpeg libraries. -# If you are using Anaconda Python distribution, -# ``conda install -c conda-forge 'ffmpeg<7'`` will install -# compatible FFmpeg libraries. +# This tutorial requires FFmpeg libraries. +# Please refer to :ref:`FFmpeg dependency ` for +# the detail. # ###################################################################### diff --git a/examples/tutorials/streamwriter_advanced.py b/examples/tutorials/streamwriter_advanced.py index 7d988dacb0..1000118bde 100644 --- a/examples/tutorials/streamwriter_advanced.py +++ b/examples/tutorials/streamwriter_advanced.py @@ -23,14 +23,9 @@ # # .. note:: # -# This tutorial requires FFmpeg libraries (>=4.1, <7). -# -# There are multiple ways to install FFmpeg libraries. -# If you are using Anaconda Python distribution, -# ``conda install -c conda-forge 'ffmpeg<7'`` will install -# compatible FFmpeg libraries. -# However, this distribution does not have SDL plugin, so it cannot play -# video. +# This tutorial requires FFmpeg libraries. +# Please refer to :ref:`FFmpeg dependency ` for +# the detail. # ###################################################################### diff --git a/examples/tutorials/streamwriter_basic_tutorial.py b/examples/tutorials/streamwriter_basic_tutorial.py index 5d9980cd8e..92e48092c1 100644 --- a/examples/tutorials/streamwriter_basic_tutorial.py +++ b/examples/tutorials/streamwriter_basic_tutorial.py @@ -13,12 +13,9 @@ # # .. note:: # -# This tutorial requires FFmpeg libraries (>=4.1, <7). -# -# There are multiple ways to install FFmpeg libraries. -# If you are using Anaconda Python distribution, -# ``conda install -c conda-forge 'ffmpeg<7'`` will install -# compatible FFmpeg libraries. +# This tutorial requires FFmpeg libraries. +# Please refer to :ref:`FFmpeg dependency ` for +# the detail. # ###################################################################### diff --git a/third_party/ffmpeg/multi/CMakeLists.txt b/third_party/ffmpeg/multi/CMakeLists.txt index 5164fa75cd..11ea5d1dce 100644 --- a/third_party/ffmpeg/multi/CMakeLists.txt +++ b/third_party/ffmpeg/multi/CMakeLists.txt @@ -15,8 +15,8 @@ if (APPLE) if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64") FetchContent_Declare( f4 - URL ${base_url}/2023-07-06/macos_arm64/4.1.8.tar.gz - URL_HASH SHA256=a44b8152b7f204ce5050fc7f6fd2bbbafe7ae4e45f03e135f3b45dd9a08f404e + URL ${base_url}/2023-08-14/macos_arm64/4.4.4.tar.gz + URL_HASH SHA256=9a593eb241eb8b23bc557856ee6db5d9aecd2d8895c614a949f3a1ad9799c1a1 ) FetchContent_Declare( f5 @@ -31,8 +31,8 @@ if (APPLE) elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") FetchContent_Declare( f4 - URL ${base_url}/2023-07-06/macos_x86_64/4.1.8.tar.gz - URL_HASH SHA256=392d5af0b24535bfc69d6244e7595e5f07117b93d94505d0a4b34c82ae479f48 + URL ${base_url}/2023-08-14/macos_x86_64/4.4.4.tar.gz + URL_HASH SHA256=0935e359c0864969987d908397f9208d6dc4dc0ef8bfe2ec730bb2c44eae89fc ) FetchContent_Declare( f5 @@ -58,8 +58,8 @@ elseif (UNIX) if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64") FetchContent_Declare( f4 - URL ${base_url}/2023-07-06/linux_aarch64/4.1.8.tar.gz - URL_HASH SHA256=aae0b713040e30ceebe0d0bc82353d3d9054055c7af8a4f4abc1766015ab7681 + URL ${base_url}/2023-08-14/linux_aarch64/4.4.4.tar.gz + URL_HASH SHA256=6f00437d13a3b3812ebe81c6e6f3a84a58f260d946a1995df87ba09aae234504 ) FetchContent_Declare( f5 @@ -74,8 +74,8 @@ elseif (UNIX) elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") FetchContent_Declare( f4 - URL ${base_url}/2023-07-06/linux_x86_64/4.1.8.tar.gz - URL_HASH SHA256=52e53b8857739bdd54f9d8541e22569b57f6c6f16504ee83963c2ed3e7061a23 + URL ${base_url}/2023-08-14/linux_x86_64/4.4.4.tar.gz + URL_HASH SHA256=9b87eeba9b6975e25f28ba12163bd713228ed84f4c2b3721bc5ebe92055edb51 ) FetchContent_Declare( f5 @@ -101,8 +101,8 @@ elseif (UNIX) elseif(MSVC) FetchContent_Declare( f4 - URL ${base_url}/2023-07-06/windows/4.1.8.tar.gz - URL_HASH SHA256=c45cd36e0575490f97ace07365bb67c5e1cbe9f3e6a4272d035c19348df96790 + URL ${base_url}/2023-08-14/windows/4.4.4.tar.gz + URL_HASH SHA256=9f9a65cf03a3e164edca601ba18180a504e44e03fae48ce706ca3120b55a4db5 ) FetchContent_Declare( f5