Closed LZQCN closed 11 months ago
Thanks for the contribution!
Can you tell me about the use case? Why is passing in $FFMPEG_BINARIES_URL
/$FFPROBE_BINARIES_URL
not an option for you?
Thank you for reviewing this PR.
In my project, there are team members from China who have restricted access to GitHub and are using different operating systems. In order to install dependencies, we need to set the $FFPROBE_BINARIES_URL before running npm install to ensure that FFMPEG binaries can be downloaded from a mirror site. However, writing complex scripts to handle environment variable settings for each system is a time-consuming task.
To optimize this process, I have used the .npmrc file to easily configure the FFPROBE_BINARIES_URL option. This approach is simpler and customizable, allowing for easy configuration of the download URL for ffmpeg binaries.
$FFMPEG_BINARIES_URL
/$FFROBE_BINARIES_URL
are agnostic to the OS & CPU architecture because they are only base URLs that a release tag & filename get appended to:
I think .npmrc
file is used to configure downloadsUrl
, rather than the arch & platform, which should be changed by environment vars.
I think there's some confusion here.
ffmpeg-static
is written so that the (base) URL, which the actual binary download URLs get computed from, is configurable using the $FFMPEG_BINARIES_URL
environment variable. Then, the release (e.g. b6.0
, but also customisable via $FFMPEG_BINARY_RELEASE
) as well as the architecture- and platform-specific file name (e.g. ffmpeg-linux-x64.gz
) get appended. This file is then being downloaded.
process.env.npm_config_*
might be set by different tools/places:
npm_config_arch
& npm_config_platform
]() to let npm packages build itself for the intended target platform. This convention seems to have become the de-facto standard to cross-platform builds in the npm packages ecosystem; For example, the well-known sharp package also uses them.npm_config_*
can also be set by passing CLI flags to npm scripts (e.g. npm install --foo=bar
).foo=bar
in ~/.npmrc
, it will appear as process.env.npm_config_foo
in the install script.This means that, when installing ffmpeg-static
(or ffprobe-static
, see #19), you have lots of options to configure the downloads (base) URL, the ffmpeg binary release, and the CPU architecture & platform/OS.
Is this PR's intention to allow permanently changing (system-wide) ffmpeg-static
's downloads (base) URL using .npmrc
?
I apologize for any misunderstanding caused by the translation software, as my English is not very good. The reason I raised this PR is simply because .npmrc is easier to set up than environment variables.
If you add an entry to .npmrc
, it will also be set as an environment variable by npm, which ffmpeg-static
then picks up.
This commit updates the
downloadsUrl
variable to prioritize the value from the.npmrc
file if it exists. The updated code checksprocess.env.npm_config_ffmpeg_binaries_url
first and if it's not set, then it falls back toprocess.env[BINARIES_URL_ENV_VAR]
or the default value if none of the variables are set. This change allows for more flexibility and customization when it comes to configuring the download URL for ffmpeg binaries.