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

Use FFmpeg-based I/O as fallback in sox_io backend #2419

Closed
wants to merge 1 commit into from

Conversation

mthrok
Copy link
Collaborator

@mthrok mthrok commented May 27, 2022

This commit add fallback mechanism to info and load functions of sox_io backend.
If torchaudio is compiled to use FFmpeg, and runtime dependencies are properly loaded,
in case info and load fail, it fallback to FFmpeg-based implementation.

BC-breaking changes:

  • FFmpeg does not report the number of frames for MP3, this is because MP3 does not store the information of the number of frames. It can be estimated from the audio duration and sample rate, but it might be inaccurate, so we keep it 0.

Depends on

@facebook-github-bot
Copy link
Contributor

@mthrok has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mthrok mthrok force-pushed the ffmpeg-mp3 branch 10 times, most recently from cd012b3 to e978398 Compare May 29, 2022 05:23
@facebook-github-bot
Copy link
Contributor

@mthrok has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

mthrok added a commit to mthrok/audio that referenced this pull request May 29, 2022
Summary:
This commit add fallback mechanism to `info` and `load` functions of sox_io backend.
If torchaudio is compiled to use FFmpeg, and runtime dependencies are properly loaded,
in case `info` and `load` fail, it fallback to FFmpeg-based implementation.

Depends on pytorch#2416, pytorch#2417, pytorch#2418

Pull Request resolved: pytorch#2419

Differential Revision: D36740306

Pulled By: mthrok

fbshipit-source-id: b933f5a55ec5f5bb8d6ec4abbf1ad796839258d0
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D36740306

mthrok added a commit to mthrok/audio that referenced this pull request May 29, 2022
Summary:
This commit add fallback mechanism to `info` and `load` functions of sox_io backend.
If torchaudio is compiled to use FFmpeg, and runtime dependencies are properly loaded,
in case `info` and `load` fail, it fallback to FFmpeg-based implementation.

Depends on pytorch#2416, pytorch#2417, pytorch#2418

Pull Request resolved: pytorch#2419

Differential Revision: D36740306

Pulled By: mthrok

fbshipit-source-id: b933f5a55ec5f5bb8d6ec4abbf1ad796839258d0
@facebook-github-bot
Copy link
Contributor

@mthrok has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

mthrok added a commit to mthrok/audio that referenced this pull request May 29, 2022
Summary:
This commit add fallback mechanism to `info` and `load` functions of sox_io backend.
If torchaudio is compiled to use FFmpeg, and runtime dependencies are properly loaded,
in case `info` and `load` fail, it fallback to FFmpeg-based implementation.

Depends on pytorch#2416, pytorch#2417, pytorch#2418

Pull Request resolved: pytorch#2419

Differential Revision: D36740306

Pulled By: mthrok

fbshipit-source-id: b933f5a55ec5f5bb8d6ec4abbf1ad796839258d0
@facebook-github-bot
Copy link
Contributor

@mthrok has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

mthrok added a commit to mthrok/audio that referenced this pull request May 29, 2022
Summary:
This commit add fallback mechanism to `info` and `load` functions of sox_io backend.
If torchaudio is compiled to use FFmpeg, and runtime dependencies are properly loaded,
in case `info` and `load` fail, it fallback to FFmpeg-based implementation.

Depends on pytorch#2416, pytorch#2417, pytorch#2418

Pull Request resolved: pytorch#2419

Differential Revision: D36740306

Pulled By: mthrok

fbshipit-source-id: 91dfdd199959d83ce643ccc38cf163ce29fba55e
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D36740306

mthrok added a commit to mthrok/audio that referenced this pull request May 30, 2022
Summary:
This commit add fallback mechanism to `info` and `load` functions of sox_io backend.
If torchaudio is compiled to use FFmpeg, and runtime dependencies are properly loaded,
in case `info` and `load` fail, it fallback to FFmpeg-based implementation.

Depends on pytorch#2416, pytorch#2417, pytorch#2418

Pull Request resolved: pytorch#2419

Differential Revision: D36740306

Pulled By: mthrok

fbshipit-source-id: 91dfdd199959d83ce643ccc38cf163ce29fba55e
@facebook-github-bot
Copy link
Contributor

@mthrok has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Summary:
This commit add fallback mechanism to `info` and `load` functions of sox_io backend.
If torchaudio is compiled to use FFmpeg, and runtime dependencies are properly loaded,
in case `info` and `load` fail, it fallback to FFmpeg-based implementation.

BC-breaking changes:
 - FFmpeg does not report the number of frames for MP3, this is because MP3 does not store the information of the number of frames. It can be estimated from the audio duration and sample rate, but it might be inaccurate, so we keep it 0.

Depends on
- pytorch#2416
- pytorch#2417
- pytorch#2418
- pytorch#2423
- pytorch#2427

Pull Request resolved: pytorch#2419

Reviewed By: carolineechen

Differential Revision: D36740306

Pulled By: mthrok

fbshipit-source-id: 071d9441019b7e76bd9a7f44ed236333ca406be9
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D36740306

@github-actions
Copy link

github-actions bot commented Jun 2, 2022

Hey @mthrok.
You merged this PR, but labels were not properly added. Please add a primary and secondary label (See https://github.com/pytorch/audio/blob/main/.github/process_commit.py)

@mthrok mthrok deleted the ffmpeg-mp3 branch June 2, 2022 00:48
@mthrok mthrok mentioned this pull request Jun 2, 2022
facebook-github-bot pushed a commit that referenced this pull request Jun 2, 2022
Summary:
Remove the code related to libmad, which had been disabled in #2354

In #2419, we mp3 decoding to ffmpeg. But CI tests were still using libmad.
This commit completely removes libmad from torchaudio.

This is BC-breaking change as `apply_sox_effects_file` function cannot handle MP3, and it cannot fallback to ffmpeg.
The workaround for this is to use `torchaudio.load` then `apply_sox_effects_tensor`.

Pull Request resolved: #2428

Reviewed By: carolineechen

Differential Revision: D36851805

Pulled By: mthrok

fbshipit-source-id: f98795c59a1ac61cef511f2bbeac37f7c3c69d55
mthrok added a commit to mthrok/audio that referenced this pull request Jun 13, 2022
Loading and querying file-like object is not possible to use the fallback
mechanism introduced in pytorch#2419 because file-like objects are not seekable.

This commit add special case handling to mp3.

For filelike object mp3 input, it was required to pass `format="mp3"`
because libsox did not auto detect the format.

With the transition of mp3 handling from libsox to ffmpeg, the logic
is to let the ffmpeg handle it without waiting for libsox to fail,
if the `format="mp3"`
mthrok added a commit to mthrok/audio that referenced this pull request Jun 14, 2022
Loading and querying file-like object is not possible to use the fallback
mechanism introduced in pytorch#2419 because file-like objects are not seekable.

This commit add special case handling to mp3.

For filelike object mp3 input, it was required to pass `format="mp3"`
because libsox did not auto detect the format.

With the transition of mp3 handling from libsox to ffmpeg, the logic
is to let the ffmpeg handle it without waiting for libsox to fail,
if the `format="mp3"`
mthrok added a commit that referenced this pull request Jun 14, 2022
Loading and querying file-like object is not possible to use the fallback
mechanism introduced in #2419 because file-like objects are not seekable.

This commit add special case handling to mp3.

For filelike object mp3 input, it was required to pass `format="mp3"`
because libsox did not auto detect the format.

With the transition of mp3 handling from libsox to ffmpeg, the logic
is to let the ffmpeg handle it without waiting for libsox to fail,
if the `format="mp3"`
mthrok added a commit to mthrok/audio that referenced this pull request Jun 14, 2022
Loading and querying file-like object is not possible to use the fallback
mechanism introduced in pytorch#2419 because file-like objects are not seekable.

This commit add special case handling to mp3.

For filelike object mp3 input, it was required to pass `format="mp3"`
because libsox did not auto detect the format.

With the transition of mp3 handling from libsox to ffmpeg, the logic
is to let the ffmpeg handle it without waiting for libsox to fail,
if the `format="mp3"`
facebook-github-bot pushed a commit that referenced this pull request Jun 16, 2022
Summary:
Loading and querying file-like object is not possible to use the fallback
mechanism introduced in #2419 because file-like objects are not seekable.

This commit add special case handling to mp3.

For filelike object mp3 input, it was required to pass `format="mp3"`
because libsox did not auto detect the format.

With the transition of mp3 handling from libsox to ffmpeg, the logic
is to let the ffmpeg handle it without waiting for libsox to fail,
if the `format="mp3"`

Note: This is back port of #2477.

Pull Request resolved: #2478

Reviewed By: carolineechen

Differential Revision: D37177123

Pulled By: mthrok

fbshipit-source-id: 997eead01c0ad1f04ffa0daa1039302a75f62b63
mthrok added a commit to mthrok/audio that referenced this pull request Jul 27, 2023
In pytorch#2419, we added ffmpeg as fallback for sox_io backend.
The was a warkaround for solving the issue with libmad removal.

Now that we introduced `backend` argument to I/O functions,
and libsox integration is moved to dynamic binding where users can
use libsox with libmad integration, we do not need the workaround.

This commit is based on reverting pytorch#2416 (fd7ace1).
mthrok added a commit to mthrok/audio that referenced this pull request Jul 27, 2023
In pytorch#2419, we added ffmpeg as fallback for sox_io backend.
The was a warkaround for solving the issue with libmad removal.

Now that we introduced `backend` argument to I/O functions,
and libsox integration is moved to dynamic binding where users can
use libsox with libmad integration, we do not need the workaround.

This commit is based on reverting pytorch#2416 (fd7ace1).
mthrok added a commit to mthrok/audio that referenced this pull request Jul 28, 2023
In pytorch#2419, we added ffmpeg as fallback for sox_io backend.
The was a warkaround for solving the issue with libmad removal.

Now that we introduced `backend` argument to I/O functions,
and libsox integration is moved to dynamic binding where users can
use libsox with libmad integration, we do not need the workaround.

This commit is based on reverting pytorch#2416 (fd7ace1).
mthrok added a commit to mthrok/audio that referenced this pull request Jul 28, 2023
In pytorch#2419, we added ffmpeg as fallback for sox_io backend.
The was a warkaround for solving the issue with libmad removal.

Now that we introduced `backend` argument to I/O functions,
and libsox integration is moved to dynamic binding where users can
use libsox with libmad integration, we do not need the workaround.

This commit is based on reverting pytorch#2416 (fd7ace1).
mthrok added a commit to mthrok/audio that referenced this pull request Jul 28, 2023
In pytorch#2419, we added ffmpeg as fallback for sox_io backend.
The was a warkaround for solving the issue with libmad removal.

Now that we introduced `backend` argument to I/O functions,
and libsox integration is moved to dynamic binding where users can
use libsox with libmad integration, we do not need the workaround.

This commit is based on reverting pytorch#2416 (fd7ace1).
mthrok added a commit to mthrok/audio that referenced this pull request Jul 28, 2023
In pytorch#2419, we added ffmpeg as fallback for sox_io backend.
The was a warkaround for solving the issue with libmad removal.

Now that we introduced `backend` argument to I/O functions,
and libsox integration is moved to dynamic binding where users can
use libsox with libmad integration, we do not need the workaround.

This commit is based on reverting pytorch#2416 (fd7ace1).
mthrok added a commit to mthrok/audio that referenced this pull request Jul 28, 2023
In pytorch#2419, we added ffmpeg as fallback for sox_io backend.
The was a warkaround for solving the issue with libmad removal.

Now that we introduced `backend` argument to I/O functions,
and libsox integration is moved to dynamic binding where users can
use libsox with libmad integration, we do not need the workaround.

This commit is based on reverting pytorch#2416 (fd7ace1).
mthrok added a commit to mthrok/audio that referenced this pull request Jul 28, 2023
In pytorch#2419, we added ffmpeg as fallback for sox_io backend.
The was a warkaround for solving the issue with libmad removal.

Now that we introduced `backend` argument to I/O functions,
and libsox integration is moved to dynamic binding where users can
use libsox with libmad integration, we do not need the workaround.

This commit is based on reverting pytorch#2416 (fd7ace1).
facebook-github-bot pushed a commit that referenced this pull request Jul 28, 2023
Summary:
In #2419, we added ffmpeg as fallback for sox_io backend. The was a warkaround for solving the issue with libmad removal.

Now that we introduced `backend` argument to I/O functions, and libsox integration is moved to dynamic binding where users can use libsox with libmad integration, we do not need the workaround.

This commit is based on reverting #2416 (fd7ace1).

Pull Request resolved: #3516

Reviewed By: huangruizhe

Differential Revision: D47855272

Pulled By: mthrok

fbshipit-source-id: 5af73af7865f6e545ccb052d478e86588ff2a014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants