mirror of https://github.com/yt-dlp/yt-dlp.git
[ffmpeg] Set `ffmpeg_location` in a contextvar
Fixes #2191 for the CLI, but not when used through the API
This commit is contained in:
parent
c646d76f67
commit
6a7d3a0a09
|
@ -19,6 +19,7 @@ from .extractor.adobepass import MSO_INFO
|
||||||
from .extractor.common import InfoExtractor
|
from .extractor.common import InfoExtractor
|
||||||
from .options import parseOpts
|
from .options import parseOpts
|
||||||
from .postprocessor import (
|
from .postprocessor import (
|
||||||
|
FFmpegPostProcessor,
|
||||||
FFmpegExtractAudioPP,
|
FFmpegExtractAudioPP,
|
||||||
FFmpegSubtitlesConvertorPP,
|
FFmpegSubtitlesConvertorPP,
|
||||||
FFmpegThumbnailsConvertorPP,
|
FFmpegThumbnailsConvertorPP,
|
||||||
|
@ -899,6 +900,11 @@ def _real_main(argv=None):
|
||||||
if print_extractor_information(opts, all_urls):
|
if print_extractor_information(opts, all_urls):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# We may need ffmpeg_location without having access to the YoutubeDL instance
|
||||||
|
# See https://github.com/yt-dlp/yt-dlp/issues/2191
|
||||||
|
if opts.ffmpeg_location:
|
||||||
|
FFmpegPostProcessor._ffmpeg_location.set(opts.ffmpeg_location)
|
||||||
|
|
||||||
with YoutubeDL(ydl_opts) as ydl:
|
with YoutubeDL(ydl_opts) as ydl:
|
||||||
pre_process = opts.update_self or opts.rm_cachedir
|
pre_process = opts.update_self or opts.rm_cachedir
|
||||||
actual_use = all_urls or opts.load_info_filename
|
actual_use = all_urls or opts.load_info_filename
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import collections
|
import collections
|
||||||
|
import contextvars
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -81,6 +82,8 @@ class FFmpegPostProcessorError(PostProcessingError):
|
||||||
|
|
||||||
|
|
||||||
class FFmpegPostProcessor(PostProcessor):
|
class FFmpegPostProcessor(PostProcessor):
|
||||||
|
_ffmpeg_location = contextvars.ContextVar('ffmpeg_location', default=None)
|
||||||
|
|
||||||
def __init__(self, downloader=None):
|
def __init__(self, downloader=None):
|
||||||
PostProcessor.__init__(self, downloader)
|
PostProcessor.__init__(self, downloader)
|
||||||
self._prefer_ffmpeg = self.get_param('prefer_ffmpeg', True)
|
self._prefer_ffmpeg = self.get_param('prefer_ffmpeg', True)
|
||||||
|
@ -100,7 +103,7 @@ class FFmpegPostProcessor(PostProcessor):
|
||||||
def _determine_executables(self):
|
def _determine_executables(self):
|
||||||
programs = [*self._ffmpeg_to_avconv.keys(), *self._ffmpeg_to_avconv.values()]
|
programs = [*self._ffmpeg_to_avconv.keys(), *self._ffmpeg_to_avconv.values()]
|
||||||
|
|
||||||
location = self.get_param('ffmpeg_location')
|
location = self.get_param('ffmpeg_location', self._ffmpeg_location.get())
|
||||||
if location is None:
|
if location is None:
|
||||||
return {p: p for p in programs}
|
return {p: p for p in programs}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue