GithubHelp home page GithubHelp logo

ffmpeg-ui's Introduction

FFMPEG UI

I'm using this project to learn WASM and improve my Rust.

Dependencies

Rust

Install rust for your OS how you see fit, currently there are no OS requirements.

https://www.rust-lang.org/tools/install

This app is currently developed with the following rust version: rustc 1.59.0 (9d1b2106e 2022-02-23)

Yew

https://yew.rs/ Yew is the frontend framework, it's entirely rust and you probably will not see any .js files in the project.

Follow the install instructions and make sure to add the compile option to rust with:

rustup target add wasm32-unknown-unknown
cargo install trunk

FFmpeg for wasm

ffmpeg is not included in the repo as it libraries can be pretty heavy

Install a container runtime

To make our life easier we build using emsdk image from dockerhub. It's possible to build ffmpeg manualy but it can be painfull.

The commands showcase podman but docker works as well.

Run build

podman build -t ffmpeg-wasm .

FFmpeg is built during the build time, but to get the files into our file system you will need to run the container.

# The default cmd will copy the required files to src/ffmpeg
podman run -v "$(pwd)"/src/ffmpeg/:/out -it ffmpeg-wasm

This should result in a ffmpeg folder inside /src/ffmpeg. We still have more preparations to do.

In the generated ffmpeg folder, the libraries are in /lib/*.a move this folder up: mv src/ffmpeg/ffmpeg/lib src/ffmpeg

Bindgen headers

The bindings are commited in the repo so this can be skipped unless you want to regenerate then.

Then install bindgen:

# Make sure you have the requirements in your system https://rust-lang.github.io/rust-bindgen/requirements.html
cargo install bindgen

Now we need to generate the bindinges for all APIs we wanna use.

# x264 might not work this way as the required system lib is not explicitly included in the original header file.
bindgen src/ffmpeg/x264_wrapper.h -o src/ffmpeg/x264.rs -- -Isrc/ffmpeg/ffmpeg/include 
for lib in 'avcodec' 'avfilter' 'avformat' 'avutil' 'swresample' 'swscale'; do
  bindgen src/ffmpeg/ffmpeg/include/lib$lib/$lib.h -o src/ffmpeg/$lib.rs -- -Isrc/ffmpeg/ffmpeg/include
done

Note that after the bindgen, avlibs will have illegal code for rust ( duplicating variable declaration ), you will have to manually delete then.

Running

Just type: trunk serve and you should be good to go :)

Note for the future

FFmpeg will require SharedArrayBuffer which needs custom headers in the server, trunk still doesn't have a way to set headers so server.rs can be used instead. To use it you will install rust-script:

cargo install rust-script

# might not work under Windows as it depends on the sh hashbang to find rust-script executable.
./server.rs

# In another terminal session
trunk watch

ffmpeg-ui's People

Contributors

yvdlima avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.