Vikram Babu Nagineni
Vikram Babu Nagineni

Reputation: 3549

How to add background music to video in html5?

I already have video being played with its own audio. I want to add some background music to existing video. How can I achieve that in HTML5 and javascript?

Should I mix the video and audio data bits and play using one video element <video></video>?

Or

Should I play the video and audio with its own <video></video> and <audio></audio> tags?

Upvotes: 1

Views: 469

Answers (2)

Ihor Lesiv
Ihor Lesiv

Reputation: 34

You should mix audio and your existing video with a video editor (iMovie, Adobe Premiere etc) and after that add video to your website using <video></video> tag.

Upvotes: 1

Quentame
Quentame

Reputation: 355

There is two cases:

  • If the audio you want to add is triggered by a user action, you should add it on a separate audio tag.
  • Otherwise, like background music, you should add the audio track to the video one, it will save bandwidth.

Upvotes: 0

Related Questions