[external/FFmpegFD] Fix ffmpeg detection with --ffmpeg-location ...
(etc)
#32741
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Boilerplate: own code/bug fix
Please follow the guide below
x
into all the boxes [ ] relevant to your pull request (like that [x])Before submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
The ffmpeg downloader
FFmpegFD
depends on the corresponding post-processorFFmpegPostProcessor
. The availability of a downloader is a class property, while the availability of a post-processor is an instance property. Due to a combination of code issues, a viable ffmpeg installation might not be found for downloading when a custom location was specified with--ffmpeg-location ...
or its API equivalent, as in #32735.This PR fixes the issue by splitting the availability computation:
FFmpegPostProcessor
class (normally guaranteed)Previously the first step would always fail with a custom ffmpeg location not on the
PATH
; even if it had succeeded, the instance-based availability check would fail because the associated post-processor was constructed using the object itself rather than its parentYoutubeDL
.Summary of changes:
compat_contextlib_suppress
is added to allow thewith suppress(exceptions) ...
syntax to be used across Py2/3,. and applied in the utils modulecompat_subprocess_Popen
is added so that Popen() is a context manager across Py2/3FFmpegPostProcessor
is simplifiedFFmpegFD
is reworked as above with a more relevant error message.