eugeneware / ffmpeg-static

ffmpeg static binaries for Mac OSX and Linux and Windows
GNU General Public License v3.0
1.11k stars 182 forks source link

Update downloadsUrl to prioritize .npmrc variable #126

Closed LZQCN closed 11 months ago

LZQCN commented 1 year ago

This commit updates the downloadsUrl variable to prioritize the value from the .npmrc file if it exists. The updated code checks process.env.npm_config_ffmpeg_binaries_url first and if it's not set, then it falls back to process.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.

derhuerst commented 1 year 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?

LZQCN commented 1 year ago

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.

derhuerst commented 1 year ago

$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:

https://github.com/eugeneware/ffmpeg-static/blob/7407c144d1e7b3ad93c6ef029827051c23c5e094/install.js#L169-L174

luoway commented 1 year ago

https://github.com/eugeneware/ffmpeg-static/blob/7407c144d1e7b3ad93c6ef029827051c23c5e094/install.js#L167-L172

I think .npmrc file is used to configure downloadsUrl, rather than the arch & platform, which should be changed by environment vars.

derhuerst commented 1 year ago

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:

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?

LZQCN commented 1 year ago

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.

derhuerst commented 11 months ago

If you add an entry to .npmrc, it will also be set as an environment variable by npm, which ffmpeg-static then picks up.