通过WEBRTC流静态视频文件

发布于 2025-01-23 02:06:41 字数 720 浏览 3 评论 0 原文

我要完成的工作是在我的页面音频和视频文件上放置。然后通过webrtc发送它们。我设法使用像这样的Web Audio API使用音频来执行此操作。 HTML:

  <audio id="audio">
    <source src="../assets/outfoxing.mp3" />
  </audio>

JS:

const audioElement = document.getElementById("audio");
const incomingSource = audioContext.createMediaElementSource(audioElement);

const outgoingStream = audioContext.createMediaStreamDestination();
incomingSource.connect(outgoingStream);
const outgoingTrack = outgoingStream.stream.getAudioTracks()[0];
audioElement.play();
await this.sendTransport.produce({ track: outgoingTrack });

对于WebRTC,我正在使用MediaSoup,

现在我想对视频进行同样的操作。但是没有像网络视频API这样的事情,所以我被卡住了。我该如何完成这项任务。

what I am trying to accomplish is to have on my page audio and video file. And then send them through webrtc. I managed to do this with audio using web audio api like this.
HTML:

  <audio id="audio">
    <source src="../assets/outfoxing.mp3" />
  </audio>

JS:

const audioElement = document.getElementById("audio");
const incomingSource = audioContext.createMediaElementSource(audioElement);

const outgoingStream = audioContext.createMediaStreamDestination();
incomingSource.connect(outgoingStream);
const outgoingTrack = outgoingStream.stream.getAudioTracks()[0];
audioElement.play();
await this.sendTransport.produce({ track: outgoingTrack });

For webrtc I am using mediasoup

Now I want to do the same with the video. But there is no such thing like web video api so I am stuck. How can I accomplish this task.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

二手情话 2025-01-30 02:06:41

有一些局限性,但是您可以参考此

它使用

There are some limitations, but you could refer to this sample implementation.

It uses the captureStream() method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文