Yahweasel / libav.js

This is a compilation of the libraries associated with handling audio and video in ffmpeg—libavformat, libavcodec, libavfilter, libavutil, libswresample, and libswscale—for emscripten, and thus the web.
288 stars 18 forks source link

HLS Protocol not working #24

Closed Luke-HSKim closed 12 months ago

Luke-HSKim commented 1 year ago

I tried to build by adding following options to ffmpeg-config.txt, but it didn't work as I tried with PC libavformat.a. --enable-network --enable-protocol=tcp --enable-protocol=http --enable-protocol=hls

libav.ff_init_demuxer_file("http://url_to_hls/hls.m3u8")

Any idea to make it works?

In addition, can you advise me how to debug libav.wasm part directly?

Thank you in advance!

Yahweasel commented 1 year ago

Unfortunately, "from scratch" is the answer. The web's network stack is totally unrelated to JavaScript's network stack, so when you enable networking in ffmpeg's config, it's just getting a stub. The way to achieve HLS directly in libav.js would be to rewrite ffmpeg's http (and https) protocol handlers from the ground up to use the fetch function. This is doable, but would be a lot of work, and may not even get the result you want due to same-origin policies.

In terms of debugging the WASM part, I don't normally compile with -g3 because it makes the binaries outlandishly large, but that's what you want. Use the .dbg.js version (note: new in an upcoming release, so not in the release build), and if you need deeper information (symbol names), rebuild with -g3.