- A macOS computer (the instructions are specific to macOS).
- Basic knowledge of the command line interface.
- A C compiler like GCC or Clang installed on your system (usually pre-installed on macOS).
Emscripten is a toolchain for compiling C and C++ code to WebAssembly (WASM) which can be run in web browsers. Follow these steps to install Emscripten:
-
Install Emscripten SDK (emsdk):
Open a terminal and run the following commands:
git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk install latest ./emsdk activate latest source ./emsdk_env.sh
Next, follow the instructions on console to complete the installation.
emsdk
will ask you to add thesource
command to your shell profile (e.g.,.bash_profile
,.zshrc
, etc.). This ensures that the Emscripten environment is set up every time you open a new terminal window.Note that you must have Python installed on your system to run the
emsdk
commands. -
Verify Installation:
Run
emcc -v
to verify that, it should display the Emscripten version.
Once you have installed Emscripten, you can compile C files to WebAssembly. Here are the specific commands used for different utilities:
-
Applying Filter to Video:
Navigate to the project directory and run:
emcc -o applyFilterToVideo.wasm MovieVerse-Utilities/applyFilterToVideo.c -O3 -s WASM=1
-
Inverting Colors in Video:
Run this command in the project directory:
emcc -o MovieVerse-Utilities/colorInvertingVideo.wasm MovieVerse-Utilities/colorInvertingVideo.c -O3 -s WASM=1 -s EXPORTED_FUNCTIONS='["_processVideoFrame", "_main"]'
-
Redrawing Image:
For resizing and redrawing images, use:
emcc -o MovieVerse-Utilities/redrawImage.wasm MovieVerse-Utilities/redrawImage.c -O3 -s WASM=1 -s EXPORTED_FUNCTIONS='["_resizeImage", "_main"]'
-
Applying Filter to Image:
For applying filters to images, use:
emcc -o MovieVerse-Utilities/imageFilter.wasm MovieVerse-Utilities/imageFilter.c -O3 -s WASM=1 -s EXPORTED_FUNCTIONS='["_applyGrayscaleFilter", "_main"]'
-
Enhance Images:
For enhancing images, use:
emcc -o MovieVerse-Utilities/imageEnhancer.wasm MovieVerse-Utilities/imageEnhancer.c -O3 -s WASM=1 -s EXPORTED_FUNCTIONS='["_enhanceBrightness", "_main"]'
- Ensure the C source files (
applyFilterToVideo.c
,colorInvertingVideo.c
,redrawImage.c
) exist in theutils
folder. - The
-O3
flag is for optimization. - The
-s WASM=1
flag specifies that the output should be a WebAssembly module. - The
-s EXPORTED_FUNCTIONS
flag is optional, used to specify which functions to expose to JavaScript. - Remember to add the newly-cloned
emsdk
folder to.gitignore
!
- If you encounter an error about missing files or directories, verify the paths in the commands.
- For issues related to Emscripten, consult the Emscripten documentation.
- If you have any other questions or concerns, feel free to contact me.
- This directory also contains TypeScript and JavaScript utilities for various tasks. You can explore and use them as needed.
- The utilities are organized into separate files for clarity and ease of use.
- Feel free to modify or extend these utilities to suit your requirements.