goldvideo / h265player

一套完整的Web版H.265播放器解决方案,非常适合学习交流和实际应用。基于JS码流解封装、WebAssembly(FFmpeg)视频解码,利用Canvas画布投影、AudioContext播放音频。
https://goldvideo.github.io/h265player/
1.53k stars 298 forks source link

decoder_wasm 编译的libffmpeg.js在这边不能通用吧。 #46

Closed fzw2408 closed 3 years ago

fzw2408 commented 3 years ago

作者你好,这个项目单纯的只支持h265.有没有 同时支持h264 h265 的lib库,h265player的lib库会不会开源出啦?

snxly commented 3 years ago

参考 decoder_wasm 的 readme

进入代码目录,根据需要,以下命令三选一执行:

./build_decoder_264.sh //支持解码 H.264 ./build_decoder_265.sh //支持解码 H.265 ./build_decoder_264_265.sh //支持解码 H.264 和 H.265

snxly commented 3 years ago

如果需要播放H264的码流,需要在初始化decoder的时候指定编码格式 https://github.com/goldvideo/h265player/blob/master/src/decode/FFmpegDecode.js#L42 Module._openDecoder(0, videoCallback, 1) // 0 - H.264, 1 - H.265, 默认是H.265

https://github.com/goldvideo/decoder_wasm#33-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8 var codecType = 1; // 0 - H.264, 1 - H.265 var ret = Module._openDecoder(codecType, videoCallback, LOG_LEVEL_WASM)

fzw2408 commented 3 years ago

got it !非常感谢 anxly 小结一下:
1.decode_wasm 解码器编译出来的 wasm文件是可以用的。 libffmpeg_264_265.wasm

  1. var codecType = 1; // 0 - H.264, 1 - H.265 var ret = Module._openDecoder(codecType, videoCallback, LOG_LEVEL_WASM) 3.h265player 中改成h264player

    https://github.com/goldvideo/h265player/blob/master/src/demux/TsDemux.js

    tsDemuxed(data) { let streamType = data.stream_type let pes = data.pes || {} switch (streamType) {
    case 27: //h264 this.videoQueue(pes) break
    case 36: // 265 this.videoQueue(pes) break case 3: case 15: case 17: pes.PTS = Math.round(pes.PTS AV_TIME_BASE_Q 1000) this.maxAudioPTS = Math.max(pes.PTS, this.maxAudioPTS) this.audioQueue(pes) break default: break }