Skip to content

changhaitravis/bandwidth-hero-proxy-gcf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

175 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bandwidth Hero Data Compression Service

NSP Status

This data compression service is used by Bandwidth Hero browser extension. It compresses given image to low-res WebP or JPEG image. Optionally it also converts image to greyscale to save even more data.

It downloads original image and transforms it with Sharp on the fly without saving images on disk.

This is NOT an anonymizing proxy — it downloads images on user's behalf, passing cookies and user's IP address through to the origin host.

Deployment

Google Cloud Functions

ENVIRONMENT_VARIABLES

MIN_COMPRESS_LENGTH=2048 Default=2048 (minimum byte length for an image to be compressible; default 2048 ~2kB)

DISABLE_ANIMATED=1 (Disable small apng passthrough and animated GIF to animated webp conversion (uses temp dir; Can also be "true")

VIDEO_QUALITY_MULTIPLIER Default=10 (The Integer to multiply the 20-80 Quality value (l param) by to get the target video bitrate in kbps. For example, if multiplier is set to 10. Low(20) sets a target bitrate of 200kbps)

AUDIO_QUALITY_MULTIPLIER Default=2 (The Integer to multiply the 20-80 Quality value (l param) by to get the target video bitrate in kbps. For example, if multiplier is set to 2. Low(20) sets a target bitrate of 40kbps)

MEDIA_TIMEOUT Default=7200 (Set the timeout in seconds for outputted Audio and Video streams)

VIDEO_HEIGHT_THRES Default=360 (Set the maximum video height threshold in Pixels. 480 becomes 480p, etc)

VIDEO_WEBM_CPU_USED Default=7 (Read more about this here)

Options to set when deploying to google cloud

  • Memory Allocated: between 256MB - 512MB recommended
  • Runtime: NodeJS 14+ (Sharp doesn't build on Node 6 default)
  • Function to Execute: bandwidthHeroProxy

Development

node ./express-wrapper.js

About

⚡ Proxy that compresses images to low-resolution. Adapted to be Hosted on Google-Cloud-Functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 99.9%
  • Procfile 0.1%