moviemasher / moviemasher.js

JavaScript library for realtime, browser-based video and audio editing
Mozilla Public License 2.0
305 stars 62 forks source link

Unable to run moviemasher client-react on my local without docker through packages. #42

Closed GREATAJ closed 1 year ago

GREATAJ commented 1 year ago

Hello, I am unable to run moviemasher client-react on my local without docker through varies required packages.

  1. First I install packages through these commands:-
  1. Then I added these lines of code in my project:- Image20221114140314

  2. Tried to run it but I was getting the below errors. Image2

  3. Then I changed the import path and run again but I was getting another errors as below:- Image3 Image4

There is no proper documentation to run it without docker. Can you please guide me with some documentation or tutorials.

syntropo commented 1 year ago

Thanks for checking out Movie Masher - sorry you're experiencing compilation and runtime issues. Not sure why your editor supplied the path it did, but the import should probably just point to the module like the example in the Client Developer Guide:

import { ApiClient, Masher, MasherDefaultProps } from "@moviemasher/client-react"

The runtime issues are arising because the ApiClient component is being included but the server doesn't seem to be running - the initial request from the component is failing to return a valid JSON payload. If you're just testing out the client side, the easy fix is to simply remove this component to avoid making any requests.

Running the server outside Docker is not documented because it requires certain FFmpeg features that don't come in the default binary supplied by fluent-ffmpeg. Supplying cross-platform binaries through the mechanisms that NPM provides is beyond the scope of Movie Masher since only LINUX is supported by the server at this juncture. Hence, Docker is used during development and testing to provide developers with a standard LINUX environment.

That said, it's still possible to run the server on other platforms if you've got a proper build of FFmpeg. Here's an example ExpressJS application from workspaces/example-express/host/server.js that launches the server on port 8572:

const MovieMasherServer = require("@moviemasher/server-express")

const { Host } = MovieMasherServer
const options = { 
  port: 8572, host: '0.0.0.0', 
  api: { authentication: { type: 'basic' } } 
}
const host = new Host(options)
host.start()

You should be able to switch the port to 8570 and execute this script by whatever means you typically launch ExpressJS applications. Even without a custom FFmpeg build you should be able do everything short of rendering video files.

If you already have a server application that you're trying to incorporate Movie Masher into, you might find it easier to just point the client there and then add support for the APIs. The ApiClient component accepts an endpoint prop object that describes the initial request that's made:

const clientProps = { 
  endpoint: { 
    protocol: 'http',
    host: 'localhost',
    port: 8080,
    prefix: '/api',
  },
  children: <Masher { ...props } />
}
const apiClient = <ApiClient { ...clientProps } />

On the server side, you'll need to add the endpoint you've specified and return an ApiServersResponse, as described in the Server Developer Guide. In this response you can selectively enable other APIs, as well as override their endpoints to point to other parts of your application.

GREATAJ commented 1 year ago

Hello, I still got the same errors after removing and using the same import you shared in the versions 5.1.1 and 5.1.0 :-

import { ApiClient, Masher, MasherDefaultProps } from "@moviemasher/client-react"

And if I changed the import path to this :-

import { ApiClient, Masher, MasherDefaultProps } from "@moviemasher/client-react/esm/client-react"

and then I was able to accessing the components but I was getting compilation errors in the source code which shared earlier. image

When I tried the same in 5.0.6 and 5.0.3 versions and I found that I am able to see Masher in my localhost using the code which I shared earlier only I need to downgraded the respective versions according to the package.json:-

image

Can you please know me how I can access other tier or children components because If I tried to render anything inside the Masher component the code breaks. Please guide me with some documentation or tutorials.

syntropo commented 1 year ago

It's been ages since I tried to bundle anything with webpack - rollup has been tested much more extensively. What does the compiled code actually look like? Does it contain the missing exports or not?

There are so many configuration options that might produce problems like this, it's hard to know where to start. Have you tried compiling with as few optimizations as possible? Perhaps needed exports are actually being tree shaken away?

I probably won't be able to test out compiling with webpack for a week or two. Please feel free to share results of any further testing you're able to do.

syntropo commented 1 year ago

I believe I may have tracked down the problem here, or at least come up with a solution that is working using what seems to be typical TypeScript/Webpack settings...

The problem is in @moviemasher/client-react/package.json where the UMD module path is specified for the browser key. Changing the key to main seems to fix the problem in Webpack.

Could you perhaps make that change to your local copy of the module in node_modules and then test out your build?

GREATAJ commented 1 year ago

Hello @syntropo , I tried the solution you shared but I am unable to run moviemasher client-react on my local without docker through varies required packages. As I previously shared that if I use the below import statement:- import { ApiClient, Masher, MasherDefaultProps } from "@moviemasher/client-react" I found these errors:-

image

And If I use the below import statement:-

import { ApiClient, Masher, MasherDefaultProps } from "@moviemasher/client-react/esm/client-react"

Atleast I can able to access the modules through packages but I faced another complition errors in the source code:-

image

I tried to take pull of the source code of version5.1.1 and tried the script that are in package,json but still not working.

But If I tried same in the version5.0.6 or downgrade versions. It is working fine for me as per the documentation. Please know me correct steps to run moviemasher version5.1.1 through packages or source code with or without docker.

Below are the commands I used to install packages:- npm i @moviemasher/moviemasher.js, npm i @moviemasher/client-react, npm i @moviemasher/theme-default

syntropo commented 1 year ago

Making the change I suggested should have fixed the compilation error. Did you attempt to run webpack right after changing the key from browser to main in node_modules/@moviemasher/client-react/package.json? If it still reported that the package had no exports, could you please share your webpack configuration?

The second error you are getting seems to be a runtime error and not a compilation error. As I explained above, this is because you're not running a server to handle the requests the client is making. For now, I might suggest removing the ApiClient component from your application to avoid making requests altogether.