如何更改HTML中视频的音频源? [英] How can I change the Audio Source of a Video in HTML?

查看:203
本文介绍了如何更改HTML中视频的音频源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改以html播放的视频的音轨.这是我的示例代码.

I want to change the audio track of a video that I am playing in html. This is my sample code.

<!DOCTYPE html>
<html>
<head>
    <title>Video</title>
</head>
<body>
<video controls playsinline autoplay muted loop>
  <source src="video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</body>
</html>

在同一文件夹中,我有一个audio.mp3.我不想静音该视频并添加隐藏的播放器并单独播放两者,基本上我想更改音频源.如果有人这样做,请引导我或让我知道我应该朝哪个方向搜索?谢谢.

Inside the same folder, I have an audio.mp3. I don't want to mute this video and append a hidden player and play both separately, basically I want to change the audio source. If anyone has done it, please guide me or let me know in which direction should I search? Thanks.

推荐答案

我认为您不能仅在视频标签中更改音频的来源.

I don't think that you can change the source of the audio only in your video tag.

所以,是的,将视频静音并隐藏音频是最简单的解决方案.

So yes, the hack of having the video muted and a hidden audio would probably be the simplest solution.

最好的办法肯定是在服务器端使用您想要的视频音频源来重建视频.

The best one would certainly be to rebuild your video, server-side, using the audio source you want for that video.

为此,我将使用ffmpeg: https://superuser.com/questions/1137612/ffmpeg-replace-audio-in-video

I'd use ffmpeg for that : https://superuser.com/questions/1137612/ffmpeg-replace-audio-in-video

这篇关于如何更改HTML中视频的音频源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆