How to embed videos in Webflow

August 28, 2024
8 Min
Video Engineering
Share
This is some text inside of a div block.

Videos can significantly enhance the user experience on a website by providing engaging, information, and visual content. For developers looking to make their Webflow websites more dynamic, learning how to embed videos effectively is crucial. This step-by-step guide will walk you through the process of embedding videos in Webflow, covering both basic and advanced techniques to ensure your videos are seamlessly integrated into your site.

How to embed videos in Webflow

Preparing for video

When preparing your video for embedding, it's essential to ensure it's optimized for fast loading and good quality. The recommended format is MP4, which offers a good balance between quality and file size. For optimal performance, follow these settings:

  • Resolution: 1080p (1920x1080) for high-quality playback. If you need faster loading times or are targeting mobile users, you can consider 720p (1280x720).
  • Bitrate: Around 5 Mbps for 1080p videos. Adjust this according to the video's content and the expected internet speed of your users.
  • Codec: H.264, which is widely supported and efficient.

By using third-party platforms like FastPix, or other platforms you can upload and manage your videos efficiently. These platforms will generate an iframe (HTML code) that you can embed directly into your Webflow website.

what is iframe

Here’s how you can properly format and use the iframe for video embedding:

1<iframe  
2    src="https://your-video-url.com/embed/video-id"  
3    width="640"  
4    height="360"  
5    frameborder="0"  
6    allow="autoplay; fullscreen; picture-in-picture"  
7    allowfullscreen> 
8</iframe> 

Explanation of the iframe attributes

  • src: This attribute specifies the URL of the video. Replace "https://your-video-url.com/embed/video-id" with the actual URL provided by your video hosting platform.
  • width: Specifies the width of the video player. Adjust the width to fit the design of your webpage. For responsive design, you might use CSS to set the width to 100%.
  • height: Specifies the height of the video player. It should maintain the aspect ratio of your video. Using CSS can help you manage height dynamically.
  • frameborder: This is a legacy attribute that specifies whether or not to show a border around the iframe. Setting it to 0 means no border.
  • allow: This attribute controls which features the iframe can use. "autoplay; fullscreen; picture-in-picture" allows the video to start automatically (if allowed by the browser), use full screen, and enable picture-in-picture mode.
  • allowfullscreen: This attribute allows the video to be played in fullscreen mode.

Embedding a video using Webflow’s video element

Webflow login :   Open your browser and visit webflow.com.

  • To log in: Click on the "Log In" button at the top right corner of the homepage. Enter your email and password, then click "Log In."
  • To create a new account: Click on the "Get Started" or "Sign Up" button. Fill in your details (name, email, and password). Click "Create Account" to get started.

Add a video element:

  • In the left panel, click on the “+” icon to open the elements panel.
  • Drag and drop the Video element onto the desired section of your page.

Enter video URL:

  • Once the Video element is placed, a panel will appear asking for the video URL.
  • Paste the URL from YouTube or your hosted video link.

Adjust video settings

Webflow allows you to set various parameters like aspect ratio, autoplay, loop, and controls. Adjust these settings based on user experience.

Embedding a video using Webflow’s video element

How to add a background video element in Webflow

Implementing a background video in Webflow is straightforward and can greatly enhance your website’s visual appeal. Follow these steps to add a background video to your Webflow project.

Prepare and optimize your video

  • Choose a high-quality, short, looping video that fits your website’s theme.
  • Optimize the video for web use (max size 30MB, ideally under 5MB) and use MP4 format for compatibility.

Add the background video element

  • In the Webflow Designer, navigate to the section where you want the video.
  • Use the left-hand panel to add a new element, select the “Background Video” option, and drag it into the desired section.

Add the background video element

Upload your video

  • Click on the placeholder video to open the settings panel.
  • Click “Replace Video” and upload your video file from your computer.

Customize video settings

  • Adjust settings like looping, mobile playback, and overlays to match your design needs.
  • Ensure readability and visual appeal by tweaking overlay opacity and other settings.

Preview, publish, and test

  • Use the “Preview” button to see how your video looks.
  • If satisfied, click “Publish” to make your changes live.
  • Visit your live site to test loading speed, video quality, and responsiveness across devices.

Embedding a video using custom code

Embedding a video using custom code

Copy embed code: Get the embed code from your video hosting platform. For example, on YouTube, click the Share button under the video and select Embed.

Add an embed element : In Webflow Designer, drag the Embed element from the elements panel to the desired location on your page.

Paste the embed code:

  • In the Embed settings, paste the copied embed code. This can include iframes or custom video players.
  • Modify the code if needed, to set parameters like width, height, autoplay, and mute.

Save and close: Click Save & Close to apply the changes.

Deployment: To see the video is playing or not, you would need to deploy in staging domain or custom domain.

Responsive video embedding code

Ensuring that your videos are responsive is crucial for maintaining a good user experience across all devices. Here’s how to make your embedded videos responsive:

Set video to 100% width:

In the embed code, set the width to 100% to ensure the video scales with its container.

Example:

1<iframe 
2  width="100%" 
3  height="315" 
4  src="https://www.youtube.com/embed/example" 
5  frameborder="0" 
6  allowfullscreen>
7</iframe>

Use Webflow’s responsive settings:

Webflow provides responsive control settings. Use these to adjust the container size and ensure your video scales correctly on mobile, tablet, and desktop.

Aspect ratio boxes:

Use CSS to maintain the aspect ratio. Webflow supports custom CSS, which can be used to create a container that maintains the video’s aspect ratio.

Maintain the video’s aspect ratio using CSS:

1.video-container { 
2  position: relative; 
3  padding-bottom: 56.25%; /* 16:9 aspect ratio */ 
4  height: 0; 
5  overflow: hidden; 
6  max-width: 100%; 
7  background: #000; 
8} 
9.video-container iframe { 
10  position: absolute; 
11  top: 0; 
12  left: 0; 
13  width: 100%; 
14  height: 100%; 
15}

Enhancing video accessibility and SEO

Accessibility and SEO are key considerations for embed videos:

1. Add titles and descriptions: Use the title attribute in the iframe or provide a caption to improve accessibility.

2. Use schema markup: Implement schema markup to give search engines detailed information about your video content. This can help your videos appear in video search results.

Schema example:

1 { 
2  "@context": "http://schema.org", 
3  "@type": "VideoObject", 
4  "name": "Your Video Title", 
5  "description": "A description of your video content.", 
6  "thumbnailUrl": "https://example.com/thumbnail.jpg", 
7  "uploadDate": "2024-08-23", 
8  "contentUrl": "https://example.com/video.mp4", 
9  "embedUrl": "https://www.youtube.com/embed/example"
10} 

How to get iframe using FastPix Dashboard

Steps to sign up, create media, and integrate a video

1. Sign up/Login:

Visit the dashboard.fastpix.io and fill out the required details to create an account or log in if you already have one.

FastPix dashboard create new media

2. Create media:

On the dashboard home page, navigate to the "Media" section and click on “Create Media.” A pop-up will appear, giving you two options: Pull Video and Push Video.

  1. Pull video: Update "input" with your video's URL in the post body editor below, or run the request as-is to view our test video.
  2. Push video: In push video you can upload your own videos from the local device.

Pull and push video create media

3. Upload video:

Click on "Push Video" and select a video from your local device to upload. The system will start processing the video, and it will be in the "Ready" state once     completed.

Media details crated and Ready.

4. Integrate to embed:

    Click on "View," navigate to the "Integrate" tab, and scroll down to find the iframe code. Copy this code and embed it into your Webflow embed element.

iframe copy from the integrate tab.

Apart from dashboard, FastPix provides APIs to integrate videos. Learn more from our step-by-step API documentation.

Testing and optimization

After embedding your videos, it’s essential to test and optimize:

Cross-device testing:

Use Webflow’s preview mode to test how the video appears on different devices. Make adjustments to the layout or settings as needed.

Example:

  • Using Webflow's preview mode:
    • Desktop view: The video looks great, filling the entire width of the screen, and text overlays are easy to read.
    • Tablet view: You notice that the video is still visually appealing, but the text overlaps with a brighter part of the video, making it hard to read.
    • Mobile view: The video appears cropped, cutting off important parts, and the loading time seems longer due to the file size.
  • Adjustments made:
    • Tablet view: You add a semi-transparent background to the text overlays to enhance readability against the video.
    • Mobile view: You replace the background video with a static image of the waves to improve loading times and ensure the important visual elements remain visible.

By previewing and adjusting the content for each device, you ensure that the website offers a consistent and user-friendly experience across all screen sizes.

Page load speed:

Videos can significantly impact page load times. Use tools like Google PageSpeed Insights to measure the impact and optimize video sizes or lazy load videos to improve performance.

Example:

Imagine you’re designing a homepage for a fitness brand using a high-quality video of a fitness class as the background.

  • Initial issue: Using Google PageSpeed Insights, you find that the video significantly slows down the page, especially on mobile devices, leading to high bounce rates.
  • Optimizations:
    • Compress the video: Reduce the video file size from 50MB to 5MB to speed up loading times.
    • Lazy load the video: Implement lazy loading so the video loads only when it's about to be viewed, not immediately.
    • Static image for mobile: Replace the video with a static image for mobile users to improve load speed.
  • Result: These optimizations lead to faster load times, improved PageSpeed Insights scores, and lower bounce rates, enhancing the overall user experience.

Monitor user interaction:

Use analytics tools to track how users interact with your videos. This can provide insights into engagement and help you optimize video content.

Example:

Suppose you’re running a fashion website and use a background video showcasing the latest clothing line on the homepage.

  • Tracking interaction: Using Google Analytics, you set up event tracking to monitor how often users pause, play, or skip the video.
  • Findings: Data shows that most users only watch the first 10 seconds before scrolling down.
  • Optimization: Based on this insight, you shorten the video to highlight key fashion pieces in the first few seconds and add a “Shop Now” button overlay.
  • Result: After making these changes, analytics show increased engagement with the video and higher click-through rates to product pages, leading to more sales.

Conclusion

Embedding videos in your Webflow site is more than just a technical task; it’s an opportunity to create a richer, more engaging experience for your visitors. FastPix stands out as an exceptional tool for video integration, offering a streamlined process that emphasizes ease of use, customization, responsive design, scalability, and cost-effectiveness.  

Using FastPix, you can effortlessly upload your videos and obtain an iframe code that integrates seamlessly into your Webflow project. This approach not only enhances the visual appeal of your site but also ensures that your videos are optimized for performance across all devices.  

To maximize the impact of your video content, consider implementing best practices such as optimizing load times, using high-quality thumbnails, and ensuring responsive design. FastPix simplifies these processes with its in-built features, allowing you to focus on creating compelling content rather than getting bogged down in technical details. Sign up today with $25 free credits to try and experience a hassle-free video embedding solution that will not only enhance your site’s functionality but also engage your audience effectively.

Enjoyed reading? You might also like

Try FastPix today!

FastPix grows with you – from startups to growth stage and beyond.