我用这个项目结合 Webcodecs API 和 Websocket 实现WEB推流,目前实现了基本的 h264 和 aac 的flv流验证。我对js二进制处理和音视频不太熟悉,所以代码目前比较乱,实现的功能比较简单,后续会优化代码和功能。
I'm using this project to implement Web push streaming combined with Webcodecs API and Websocket. Currently, I've validated the basic h264 and aac FLV streams. As I'm not very familiar with JS binary handling and audio/video, the code is currently a bit messy, and the implemented functionality is quite simple. I will optimize the code and functionality later.
Using NPM, simply install this package using
npm install flv-muxer
This class is used to create a streamer that can be used to generate FLV streams.
const streamer = new FlvStreamer();
-
streamer.addVideoTrack(chunk, metadata)
chunk
: The data to be written to the stream.metadata
: This method writes the given data to the stream.
-
streamer.addAudioTrack(chunk, metadata)
chunk
: The data to be written to the stream.metadata
: This method writes the given data to the stream.
-
streamer.onMediaData(data)
data
: This method is called when there is media data to be written to the stream.
-
streamer.onMetadata(data)
data
: This method is called when there is metadata to be written to the stream.
- Implement basic FLV stream generation.
- Refactoring and optimizing code.
- Implement FLV file generation.
- Introduce a buffer area.