This repository is the solution to Pretest #2703.
The solution is split into two repositories-
-
WasmEdge-FFMPEG
Contains Ffmpeg Plugin that acts as a bridge between WasmEdge and Ffmpeg C API. -
ffmpeg-rust
Uses the WasmEdgeFfmpeg plugin built inWasmEdge-FFMPEG
and executes Ffmpeg C API functions.
The wasm function reads the assets/small_bunny_1080p_60fps.mp4
video file and uses the FFmpeg C API to convert the video into grayscale image frames. The frames are generated in assets dir.
Video Info | Value |
---|---|
Video Duration | 2 sec |
Frames Per Second | 60 |
No. of frames generated | 2 * 60 = 120 |
Container Format | mp4 |
Pixel Format | YUV420p |
First, follow the steps in WasmEdge-FFMPEG repository to build the plugin shared library.
To use the FFMPEG Plugin, follow the below steps-
Witc is a compiler which generates rust code for *.wit files.
witc plugin wasmedge_ffmpeg.wit > src/generated.rs
generated.rs file is created in src directory.
Use cargo to build the project into .wasm
cargo build --target wasm32-wasi --release
WASMEDGE_PLUGIN_PATH=/usr/local/lib/wasmedge/ wasmedge --dir ./. target/wasm32-wasi/release/ffmpegRust.wasm
WASMEDGE_PLUGIN_PATH takes the path of the shared plugin created in WasmEdge-FFMPEG.
Result-
The video is split into grayscale images using Ffmpeg C API in assets dir. The image generated is pgm format. Use appropriate image viewer to see the image.
The above image shows the generated.rs file.