How to Embed a Video on a Webpage

When you think about embedding video on the pages of your website, you might see yourself copying and pasting long strings of spaghetti code from one page to another. And, once you’ve posted the code, you’re seeing strange errors going off. Don’t worry, embedding video on your webpage is not like this at all. It’s actually quite simple.

With today’s broadband Internet speeds on both desktop and mobile devices, video streaming is more popular and faster than ever. For this reason, and many more, it makes sense to embed video on your webpage. Put it this way, if you’re not using video then your website may get left behind.

While video is highly popular, it takes a load of bandwidth to manage large video files. This is why we recommend hosting video with a third-party service like the ones listed below.

However, from a marketing and user-retention perspective, it’s best to host video on your own dedicated server. That way, you can better control all of your traffic.

Also, if you’re embedding video into WordPress, it’s even easier to embed videos from third-party service. All you’ll need is the URL of the video.

How to Embed Video from YouTube

YouTube makes it very simple to embed videos. All you need to do is find your video and click the “Share” button to get to the embed code.

  1. Go to YouTube to get your video
  2. Click the Share button
  3. Click embed
  4. Copy the embed code into the code of your site

Well done! You now have the raw embed code on your website, and the video will render just as it did in the YouTube preview window.

Embed Video From YouTube to WordPress (Easiest Way)

Before we move on to the other video hosting services, we’ll stop and take a look at how the above process works much faster and easier if you’re using WordPress. With WordPress, you don’t need to get your embed code from YouTube. You can actually just copy and paste the video URL itself.

A YouTube video URL may look something like this
https://www.youtube.com/watch?v=LRcrgXQjdG0
or this:
https://youtu.be/LRcrgXQjdG0

Both of the above URLs will work the same.

  1. Log into your WordPress dashboard
  2. Create a new post or edit an existing one
  3. Paste the URL into the post body (main content area)

You’ll notice the URL is instantly replaced by the video. Easy.

How to Embed Video from the Internet Archive

The Internet archive is a hybrid media and preservation repository, where users may submit as much content as they want. Here, you can upload your own videos and embed them on your website. Or, you can embed content uploaded by others.

  1. Go to the Internet archive home page
  2. Search for or select a video
  3. Click the share button
  4. Paste the embed into your site

Now, the video will render on your page with the all the video controls necessary to play properly.

How to Embed Video from Amazon Web Services (AWS)

As mentioned above, hosting your own video on a dedicated server is best. But if a dedicated server is out of your budget, you can make use of Amazon’s infrastructure to host your videos. Basically, using AWS, we’re going to create an S3 bucket that acts as a sort hard drive in the cloud where we can store our videos publicly.

Create an S3 Bucket For Storing Video

  1. Log into AWS using your Amazon account
  2. Click the Services dropdown
  3. Under Storage click S3
  4. Click Create bucket
  5. Name your bucket and select a region
  6. Click Next to select default configure options
  7. Uncheck Block all public access and click Next
  8. Click Create Bucket after going through options
  9. Select your new bucket to add contents
  10. Click Upload to upload a video
  11. Drag video files into window or click Add files to select the video from your computer
  12. Click Upload on the upload screen
  13. Select the video after the upload completes
  14. Select Permissions tab from the top
  15. Scroll down to the public access section and click the radio button for “Everyone”
  16. Check the box for Read object and click Save

Congratulations! You just uploaded your video and made it publicly available to the web through AWS. In the section below, we’re going to use the object URL to embed the video on a page of your website.

Use HTML5 Video Tag to Embed the Video

The HTML5 standard introduced a new video tag to allow developers to easily drop a video into any HTML page. First, make sure to grab the URL for your video by click the “Object URL” link in AWS. In order to use the video tag, use a code snippet like this instead of the embed codes we used earlier:

<video width="320" height="240" controls>
<source src="paste-the-object-url-here-between-the-quotes" type="video/mp4">
</video>

That’s it! That’s all you need to know to embed videos on your webpages. Be sure to leave a comment below if you have any trouble with these steps.

Thoughts on “How to Embed a Video on a Webpage

  • I want add full movies to my website.. Can anyone help me how do it, because when i add it it does not show in my website. Please help me.

    • What kind of error are you receiving? Some video hosting services like the Internet Archive and YouTube provide an “embed” code that you can use with a simple copy and paste.

  • I have a question – I am looking to embed a video that I made (.wmv format – approx 16 seconds in length) into my website. What I’m looking for it to do is when a person clicks on a video camera hyperlink on my main page, I want the page to of course open up to my “videos for sale” page and when that page opens, I want my embedded video to automatically play, full screen, kind of like as a ‘grand introduction and welcome’ to the “videos for sale” page.  How can I do that? I did copy and paste the code above onto my site, but Internet Explorer blocks it, saying it might be dangerous content, which of course I can override by clicking on the “allow this content” button, but I don’t want my site visitors to have to click on anything to get it to play. And Chrome says they don’t support the plugin to play the .wmv file. Any ideas?

    • How are you building your website? The methods outlined in this article are only a few ways that you can embed video on a website, but it may not work for all websites. Again, it depends on the software you are using to build your website. As far as the additional custom behaviors you want to occur, you will need to find a software for your website or find a developer to code that particular behavior. That may be a better method since these methods now are displaying errors and require additional components to install to view in certain browsers.

  • i want to create a site. where people can upload their videos and i also can upload.

    i tried vidmy it not working.. do you know of any site i can use..

  • i dont really get when you say embed a video in a web site.because i have been trying to insert a video in my site to no avail

     

    • Did you follow the steps above? Were you getting a specific error message? Any additional information you can provide would be greatly appreciated.

  • Hi,

     

    Im currently getting our company website re-designed and i want to add a video to the front of the website so that it automatically plays before you even enter the website. 

    1. is this possible?

    2. how would i do it? 

     

    thank you in advance

     

    Dan 

    • You can add a video to your “home” or index page, then set it to auto load. Here is a possible solution I found via google search .

      Thank you,
      John-Paul

  • I have use the Codes here and I can not the Video to Play at All I am using windows 10

    can you help i am using the WVM format and the mp4 format

  • Hiee,

    I want to put one video that is of mp4 but m not knowing how to put that video.I also used this code

    <embed src=”file.mp4″ width=”700″ height=”480″ loop=”true” pluginspage=”www.apple.com/quicktime” border=”3″ autoplay=”false”></embed>

     

    but nothing is working…one small black screen comes…please tell me how to solve this…..i want to submit my website as soon as possible

     

  • Hi,

     

    I am new to html, i have copied the below code that you have provided into my html page and have changed the “value” fields as per below. I have also placed the video in a sub folder, yet, the video is not playing on my page. can you please advise.

  • Arn,

     

    Thank you kindly for your reply.  It is indeed a sticky problem needing a developer.  Yesterday Josh Holt of http://www.bandvista.com/ which designs websites for rock & roll bands, sent me a list of developers in my area, and that is a start.  What with the Yellow Pages gone the way of dinosaurs, I wasn’t even able to find such a list.

     

    Your website is a treasure trove of invaluable information populated by some really smart folks.  

     

    Keep up the excellent work.

     

    Jock Stender

  • I have q question about using a PHP file to simplify a procedure described below.

     

    I’ve designed a website for people at end-of-life and dementia including Alzheimer’s Disease, with a list of some 1,100 YouTube songs (hymns, gospel music, etc.) that include lyrics which family members can read, and sing, along with their loved ones to bring back memories of these songs.

     

    I’ve used the simple and free VideoDownloader, http://ytddownloader.com/ utility to download some 114 hymns to a folder on my PC, which I then uploaded to an MP4 player that used the outstanding (and free) VLC Media Player,  http://www.videolan.org/vlc/, to play these hymns continuously (“looped”).

     Many visitors to my site will be middle-aged or elderly — and “all thumbs” — and incapable of following the YTDdownloader procedure.

     

     

    Consequently, I would like to automate the procedure by allowing them to peruse the website’s 1,100 YouTube videos, click on those they wish to download, and click “Download all your hymns now” with a progress bar showing the time to wait for download completion.

     

    I’ve been told that PHP coding would be necessary and that it would be as complex as reinventing the wheel – “costing many, many thousands” which I do not have, as this is a volunteer project, free to all visitors, and no obnoxious advertising.

     

    Has anyone done this before?

     

    I’ve written the HTML5 and CSS3 code but this “automation” programming is beyond my capabilities.

     

    Thanks,

    Jock Stender

    Charleston, South Carolina

     

     

    • Hello Jock,

      Sorry for the problem – this is unfortunately a question that you need to ask of a developer. We can probably reference websites that might be similar, but truthfully, they would need to be reviewed to see if they match the criteria you’re saying or not. This is not a simple project, and may require more than a volunteer professional to complete it. It is beyond the scope of this article which is simply to embedding video into webpages. Apologies that we cannot answer your question. If you another question related to this particular article then we would be happy to answer. If you have a question that is not part of this category, please submit it as a question in this section of our support center website.

      If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

  • Hi,

    I am facing problem with video with Enternet explorer hoever it is fine on Crome.

    Please see the link- http://nirmaaninfra.com/demo

    It is running fine on Crome howevr When I am entering the site on different browser its not playing.

    Would request you to please help me in this case.

     

    My Email id is rais@wiztech.net.in

     

    Many Thanks,

     

     

    • The video is loading well in my Firefox browser after taking a few seconds to load. Which video format are you using? You might see some buffering issues with high definition video depending on multiple factors.

  • For me the ideal solution is to use the player Vynch. With this technology you can embedded in your own website a room with video that you can watch synchronized. You can create playlist and share with friends and user! there is also a chat to exchange your impressions..

  • Hi, I wish to display 14 different videos on my page. They are stored on my computer I am using WAMPserver and Localhost. My videos are stored in a folder Tna/Videos and are in wmv format, I was able to use you code above to play one of the videos, I had to save it as a html file and run it independently, it opened in a seperate window, although it wasnt embedded. I changed the values of your code although I dont know what each of them mean. Here is my code

    <object width=”100%” height=”100%”

    type=”video/x-ms-asf” url=”/Tna/eNISAT/LoginTutorial.wmv” data=”/Tna/eNISAT/LoginTutorial.wmv”

    classid=”CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6″>

    <param name=”url” value=”/Tna/eNISAT/LoginTutorial.wmv”>

    <param name=”filename” value=”/Tna/eNISAT/LoginTutorial.wmv”>

    <param name=”autostart” value=”1″>

    <param name=”uiMode” value=”full” />

    <param name=”autosize” value=”1″>

    <param name=”playcount” value=”1″>

    <embed type=”application/x-mplayer2″ src=”/Tna/eNISAT/LoginTutorial.wmv” width=”100%” height=”100%” autostart=”true” showcontrols=”true” pluginspage=”http://www.microsoft.com/Windows/MediaPlayer/”></embed>

    </object>

    My question is how can I display 14 of these, obe for each video and make them embedded.

     

    Thanks

     

    Stephen

    • Hello Stephen,

      I was able to take the code from the tutorial, as well as the code you provided and get it to work fine. I only changed the video path/name to match that of my server. The videos were all embedded and did not open in different pages. I did not test 14, but did test 5 at once. Inserting nine more should act the same. I did not see any errors in the way they behaved. If you can provide a link to one that is not behaving, I may be able to take a quick look.

      Kindest Regards,
      Scott M

    • Hello Zia,

      I would suggest converting the file to MP4 as that file accepted by default n HTML without major work arounds and the file size is generally smaller. However I did find a tutorial on how to do embed AVI in HTML.

      Best Regards,
      TJ Edens

    • Hello ife,

      I’m not quite sure where you are stuck. The article goes over how to upload and then embed the video. What part are you needing assistance with?

      Kindest Regards
      Scott M

    • Hello Lori,

      The browser is trying to use QuickTime to run the video. Chrome does not support QuickTime. Have you tried converting to avi format?

      Kindest Regards,
      Scott M

  • Hi John-Paul

    Here is the page http://www.strp.ca/STRP_Staff.htm.&nbsp; I volunteer for the organization.  I noticed after I posted on In Motion that it was working in IE.  However it takes about 15 seconds to load.  It doesn’t run in Chrome or Safari.  I don’t have Fire Fox.  All help is appreciated !  I realize the entire site needs an overhaul, but I am trying to keep running costs to a minimum for them. 

    Thank you

    Lori Ann

     

    • Hello Lori,

      Thank you for contacting us. Yes, this issue seems related to the video file format being wmv. The easiest option may be to convert it to mp4 as suggested previously.

      There are many free tools available for converting wmv files, such as Convert video to MP4.

      This should allow your file to be played on most browsers.

      If you have any further questions, feel free to post them below.

      Thank you,
      John-Paul

  • I have the wmv code inserted and it plays in the preview pane of my software builder. But when browsing the file on the web I get an error the plug in is not supported.  I ftp the updates to the web.

     

    • Hello Lori,

      Thank you for contacting us. WMV files have known compatibility issues on some browsers, such as Chrome Browser. This may be related to your issue. Converting the format to something more popular such as .mp4 may correct your problem.

      We are happy to help you troubleshoot further, but will need some additional information. Can you provide a link to the site, so I can test?

      Have you tried on other browsers, such as FireFox, Safari, IE, etc.

      Thank you,
      John-Paul

  • I used the first embed code for Adobe Flash and it works perfectly! What code can I insert to play automatically and loop the video? 

    • Hello Tracy,

      If you are using the embed HTML code then you should just need to add the loop=”True” section such as the example below:

      &ltEMBED SRC=”YourDomain/sample.mp3″ LOOP=TRUE&gt

      Best Regards,
      TJ Edens

  • MP4 and webm videos are4 not running on my page .please tell me what i have to do now.Please tell me how can i do this ?

    • Fawad,

      You need to supply us more information about your website before we can help with this issue. If you’re hosting your site with InMotion, then please provide a URL and specific page information where you’re having the problem. Otherwise, if you follow the directions in the article above, you will be able to play the files directly from the website. The files typically need a player if you’re to play them directly from a website. You can also upload the files into a player like Youtube or Vimeo, then get the code and apply to your website.

      If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

  • Thanks for the answer : a trick to circumvent the black screen would be to display a still image that would launch the video when clicking. Is there a possibility to launch the video using Javascript/swfobject.js for example ? I’ve crawled the web without findind a method that fits this good script. Thanks anyway !

  • Good morning,

    the Video Embed with mediaplayer.swf (Flash) just displays a black screen until the person presses play. Is there a possibility to show a still image of the actual video or define an image to be displayed before the person presses play ?

    Thanks in advance.

    • Unfortunately, I am unaware of a solution for this. Also, I highly recommend using a service such as YouTube or Vimeo as there will be additional options there to add a custom thumbnail and typically serves up videos faster.

  • Thanks – this is precisely the information that was missing.  It removes one of the variables when troubleshooting a video that does not play – by knowing the video is in the proper place in the directory structure.

  • Video Embed .mp4 files (Apple Quicktime)

    Your .mp4 video will need to be uploaded to the server in order for you to link to it.”

    Which directory?  The upload location of the file in the directions is curiously absent. 

    • Hello Steve,
      The directory is absent because there is no specific directory to upload it to. Each person designs their site in different ways. Many may have a specific folder to upload the videos to, some will not. Maybe they put all videos in one folder, maybe they organize the content differently. It is a lot like a closet, each person has their own way of storing things. As long as it in the house (root directory of the site), then whichever room or closet it is stored in is up to you.

      Do know, however, that if you have it in a subfolder you will need to add that to the source path. For example, if the video is in your main root, it would appear as in the example:

      SRC=”video.mp4″

      Whereas if it was in a subfolder named ‘videos’ then you need to specify that in the path:

      SRC=”videos/video.mp4″

      Kindest Regards,
      Scott M

  • The mediaplayer.swf is giving me errors on my mp4 file. Says its an unsupport video format. Maybe its not the latest version?

    • The MP4 container can contain various different video encoding methods in which it could potentially be unsupported as this is a bit of an older method to embed files. You may have better luck using a service such as Vimeo or Youtube for embedding your videos.

Leave a Reply