S
SolidJS2mo ago
Ximaz

pnpm and ffmpeg-static

Hi folks ! I am having an issue with node_modules-installed binaries. I am using ffmpeg-static and fluent-ffmpeg to do audio conversion with the SolidStart framework. When building my application with vinxi build, it seem to copy my root node_modules inside .output/server/node_modules, with everything, excepted the ffmpeg binary that I downloaded through the pnpm install command. Is there any workaround in order to get the ffmpeg copoied into it ? Or to get the actual path of ffmpeg binary ? Because the relative path I get from the ffmpeg-static module once ran contains the .output/server part, which is false. I could just remove that section from the path, but it looks like a dirty hack to get around this issue. Any thoughts ?
9 Replies
TaQuanMinhLong
TaQuanMinhLong2mo ago
If I have to deal with a binary, I'll just make it available at the os level, like if it's docker, then copy to the bin-folder that the docket image expected, or self-defined with PATH env, or if it's your own vps, just let it stay anywhere as what specified in the PATH env If you're running dev only, then you can put the binary somewhere in your computer and set a static ENV like FFMPEG_BIN so the app can know where to access
Ximaz
XimazOP2mo ago
I mean, that is also a hacky-way to me to include the binary at the OS-level… I could do it via Docker, yes, but what happens when someone won’t run the projet using Docker ? Like a dev environment, and they don’t want ffmpeg to be installed ? In that configuration, with vinxi dev command, it’s not an issue, as the server runs at the project’s root level, not in .output/server folder, which lets the server find the ffmpeg static binary correctly. But then vinxi start, for prod, won’t work as expected because of that. the thing I dont understand is why .output/server will copy the node_modules, but not the binary of ffmpeg which is in the node_modules too. It seems to choose whether or not to pick certain files. Surely, there is a way to adjust the filters, right ?
TaQuanMinhLong
TaQuanMinhLong2mo ago
is putting it else where on the project ok? just make your own path FFMPEG_BIN=($CWD)/path/to/bin
Ximaz
XimazOP2mo ago
I don't know if I can specify to ffmpeg-static where to place the binary… I could do that on a Dockerfile, but what about dev env ?
TaQuanMinhLong
TaQuanMinhLong2mo ago
It depends on your shell Or you can just load it from your local .env file For example, Your project is at /home/you/your-project Then put your binary somewhere within it like .bin/ffmpeg Then specify inside the .env file FFMPEG_BIN=/home/you/your-project/.bin/ffmpeg then load the .env file when running your dev server Access the path with process.env.FFMPEG_BIN
Ximaz
XimazOP2mo ago
The thing is taht ffmpeg-static installs the ffmpeg binary to a node_modules folder. I am using pnpm to manage packages, but then the path contains some package versioning in the name, etc... So it may change, It's quite unstable and I don't think that, when installing ffmpeg using the ffmpeg-static package, I can specify a path to which the binary should be placed. I should crawl though the folders to find it. I could use the findcommand may be ? It might be able to retrieve the path for ffmpeg-static binary. I will try it, thanks for your time.
TaQuanMinhLong
TaQuanMinhLong2mo ago
It's just kinda weird when it said static but it isn't :confusednick: I think what you need to consider is that "does ffmpeg-fluent need ffmpeg-static, or what it needs is just the path-to-ffmpeg-binary" pnpm is just a tool, not a forceful way of how things should be executed
Ximaz
XimazOP2mo ago
It's the second option, yet I don't want to depend on whether or not the env test has ffmpeg installed. I could instll it via Dockerfile, but well, I wouldn't like to install ffmpeg on my PC.
TaQuanMinhLong
TaQuanMinhLong2mo ago
Just put it to gitignore and have a simple script to download it and setup Using pnpm is also the same, except it is placed in the node_modules folder
Want results from more Discord servers?
Add your server