H.264 decoder extracted from FFmpeg
Files related to H.264 decoding are extracted from FFmpeg and put in the folder ./ffmpeg-src.
The checkout commit is 2f76157eb05bf63725f96167feda6b2e07501c7e.
Some files may be modified (a little).
Run make
, and you will get the executable h264dec
.
With the tool Emscripten, the C code can also be compiled into JavaScript:
-
Run
emmake make h264dec.html
to get h264dec.html (and its supporting files), which can be open in a browser when served using a web server (e.g., withpython3 -m http.server
). Note that since we can not pass arguments to HTML pages, you should modifymain.c
(see the commented line in the main function) to let the program starts decoding without arguments. -
Run
emmake make h264dec.node.js
to get h264dec.node.js, which can be executed by Node.js:node h264dec.node.js
.
(emmake
comes with Emscripten; make clean
is usually needed before building for another platform.)
In the folder ./javascript, run emmake make
to build Decoder.js, which is used in a JavaScript TS file player demo: https://github.com/shengbinmeng/javascript-ts-player.
-
Compare performance with Broadway's that is based on Android's software H.264 decoder. No big difference maybe, but the latter only supports baseline profile.
-
Optimize JavaScript code generation, e.g., investigate Emscripten flags, use SIMD.
-
Remove unused code. Current extraction is file based. A lot of code in some files are not used by H.264 decoding. However, changing file content will make it harder to sync with FFmpeg version update.
-
Abstract a better interface and implement a better demo player.