Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI --quality option support for environment variables #778

Closed
michaelGregoire opened this issue Jan 15, 2022 · 3 comments
Closed

CLI --quality option support for environment variables #778

michaelGregoire opened this issue Jan 15, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@michaelGregoire
Copy link

michaelGregoire commented Jan 15, 2022

So, I'm adding a couple custom scripts to my package.json to make rendering a little more configurable via environment variables. One of the scripts I added is the following:

"build:frames": "FRAMES=0-1000 QUALITY=50 remotion render --frames=$FRAMES --image-format='jpeg' --quality=$QUALITY src/index.jsx IDENTIFIER out/segment.mp4",

As you can see, I'm making the --frames and --quality configurable via environment variables in the command line. --frames works perfectly. However, --quality complains that the value provided by the environment variable is a string and seems to end up with an empty string.

Error: Quality option must be a number or undefined. Got string ("")

It would be great if the option passed the value through to parseInt() and then only throw the error when the output from parseInt() is NaN.

@michaelGregoire michaelGregoire added the bug Something isn't working label Jan 15, 2022
@michaelGregoire michaelGregoire changed the title CLI option --quality support for environment variables CLI --quality option support for environment variables Jan 15, 2022
@JonnyBurger
Copy link
Member

Hi @michaelGregoire! Thanks for filing the issue.

After some tinkering, I find that this is purely a behavior of the shell / npm scripts and not with Remotion - you cannot define env variables this way. For example:

"scripts": {
	"quality": "QUALITY=50 echo $QUALITY"
}

npm run quality will yield an empty string (this is also why you got this error message).

But what would work is QUALITY=50 npm run update. This probably makes more sense than defining a env variable and then hardcoding it in the same command.

Potentially interesting for you: You may also use the config file and script it with Typescript: https://www.remotion.dev/docs/config#setquality

@michaelGregoire
Copy link
Author

michaelGregoire commented Jan 17, 2022

Thanks @JonnyBurger. It turns out I was doing what I wanted to do initially wrong.

I had started with the following and it seemed to work for FRAMES, but when I added QUALITY, it failed:

"build:frames": "remotion render --frames=${FRAMES:0-100} --image-format='jpeg' --quality=${QUALITY:50} src/index.jsx IDENTIFIER out/segment.mp4",

…so I moved on to what I previously showed you, which as you already know doesn't work:

"build:frames": "FRAMES=0-1000 QUALITY=50 remotion render --frames=$FRAMES --image-format='jpeg' --quality=$QUALITY src/index.jsx IDENTIFIER out/segment.mp4",

So I was misremembering how to do the first method. What I needed to do was the following, which works:

"build:frames": "remotion render --frames=${FRAMES:-0-100} --image-format='jpeg' --quality=${QUALITY:-50} src/index.jsx IDENTIFIER out/segment.mp4",

Now, I can override with environment variables like so:

FRAMES=0-1000 QUALITY=70 npm run build:frames

@JonnyBurger
Copy link
Member

Perfect, glad the problem is resolved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants