Top 8 mobile optimization hacks for videos

October 4, 2024
10 Nin
Video Education
Jump to
Share
This is some text inside of a div block.

With mobile devices accounting for nearly 80% of all online video traffic, optimizing video content for smaller screens is critical to capturing and retaining your audience’s attention. Mobile viewers often consume videos on the go, in sound-off environments, and during brief moments of downtime, making it extremely important to tailor videos for seamless mobile experiences.

In this blog, we’ll explore eight powerful mobile video optimization hacks that go beyond basic adjustments. From choosing the perfect video orientation to crafting compelling thumbnails, integrating subtitles, and utilizing interactive elements, these strategies will help you not only adapt to the unique needs of mobile viewers but also drive engagement and elevate your content performance.

1. Horizontal vs. vertical video: Which format is better?

The choice between vertical (portrait) and horizontal (landscape) formats has become a pivotal consideration for marketers and content creators. As mobile devices dominate video consumption, understanding the implications of each orientation is crucial for maximizing viewer engagement and satisfaction.

Rise of vertical video in the mobile-first world

Vertical video has surged in popularity, primarily due to the widespread use of smartphones. With 94% of users holding their phones vertically, this format aligns seamlessly with how people naturally consume content on mobile devices. Platforms like TikTok, Instagram, and Snapchat have championed vertical videos, making them a staple in social media marketing strategies. This is reflecting a significant shift in user behavior and preferences.

Advantages of vertical video

  • Immersive Experience: Vertical videos occupy the entire screen when viewed on mobile devices, creating experience that captures viewers' attention effectively. This format minimizes distractions by focusing solely on the content, enhancing viewer engagement.
  • Higher Completion Rates: Studies indicate that vertical videos boast a 90% watch completion rate, significantly higher than their horizontal counterparts. This is particularly important in a today’s world where attention spans are decreasing.
  • Convenience and Accessibility: Users find vertical videos easier to watch without having to rotate their devices. This convenience leads to increased likelihood of engagement, as less effort is required to view the content.
  • Optimized for Social Media: Social media platforms are increasingly designed around vertical video formats.

When deciding whether to use horizontal videos for mobile, it's important to consider the context and audience. Horizontal videos are ideal for cinematic content, such as storytelling, travel vlogs, and professional presentations, where a wider frame enhances the visual experience. They work well for multi-person scenes, providing a broader field of view that captures interactions and movements effectively, making them suitable for sports events or group discussions.

Ways to adjust video orientation based on device or screen size


Using CSS Media Queries for Orientation Detection

CSS media queries allow developers to adjust video layout and styles based on the device's orientation. You can use the orientation media feature in CSS to apply different styles for landscape and portrait modes:

1/* Video styling for portrait mode */
2@media (orientation: portrait) {
3  video {
4    width: 100%;
5    height: auto;
6  }
7}
8
9/* Video styling for landscape mode */
10@media (orientation: landscape) {
11  video {
12    width: 100%;
13    height: 100%;
14  }
15}

While CSS handles static changes, for moredynamic scenarios—such as serving different videos depending on the orientationyou can implement this using JavaScript APIs.

Changing videos with window.matchMedia in JavaScript

JavaScript’s window.matchMedia() method allows developers to programmatically monitor changes in device orientation and screen size. By listening for these changes, you can load or adjust the video’s source dynamically. This is particularly useful for mobile users who frequently rotate their devices between portrait and landscape modes.

Here’s how you can detect the orientation and dynamically switch video sources:

1// Define the video element and video sources for different orientations
2const videoElement = document.getElementById("video-player");
3const portraitVideo = "video-portrait.mp4";
4const landscapeVideo = "video-landscape.mp4";
5
6// Function to switch video source based on orientation
7function setVideoSource() {
8  if (window.matchMedia("(orientation: portrait)").matches) {
9    videoElement.src = portraitVideo;
10  } else {
11    videoElement.src = landscapeVideo;
12  }
13  videoElement.load(); // Reload the video with the new source
14}
15
16// Initial load and orientation detection
17setVideoSource();
18
19// Add event listener to detect orientation changes
20window.addEventListener("resize", setVideoSource);
21In this code:

In this code:

  • We define two different video files: one for portrait mode and one for landscape mode.
  • The setVideoSource() function checks the device orientation using window.matchMedia and changes the video source accordingly.
  • By using the resize event, the function detects any change in orientation and updates the video file dynamically, ensuring an optimal viewing experience for users.

2. Optimizing video thumbnails for mobile

Thumbnails serve as the first impression for viewers. An effective thumbnail can enhance click-through rates and viewer engagement. Whether on YouTube or your own platform, thumbnails perform especially well on mobile devices where screen space is limited.

Without wasting too much time, you can use AI to create thumbnails, simplifying the process compared to traditional methods. AI tools analyze each video frame to identify key moments based on movement, facial expressions, and colors. These algorithms score images based on composition, contrast, and other aesthetic factors to select the best thumbnail.

Netflix takes AI-driven thumbnails even further by personalizing them based on individual viewer preferences. The platform tailors thumbnail images to align with what specific users are likely to respond to, based on their viewing habits. For instance, if a user has a preference for romantic comedies, Netflix might show them a thumbnail from a movie that highlights romantic scenes or familiar actors from that genre.

video thumbnails for mobile

Tools like VEED's AI Thumbnail Maker and Thumbnail AI can help you incorporate similar AI-driven technology into your workflow, enabling you to efficiently produce high-quality thumbnails that effectively capture viewer attention and drive engagement.

3. Subtitles and closed captions for mobile devices

Incorporating subtitles and closed captions has become an essential strategy for engaging viewers and ensuring accessibility. As more people consume content on the go, often in environments with limited audio, subtitles have emerged as a powerful tool for maintaining viewer attention and enhancing overall engagement.

Subtitles and closed captions serve multiple purposes in the context of mobile video optimization:

  • Enabling mute viewing: With the prevalence of auto-play videos on social media platforms, subtitles allow viewers to understand the content without the need for audio. This is particularly important given that 85% of Facebook videos are watched without sound. Subtitles can help retain viewer attention by making videos watchable in noisy environments, such as public transportation or busy offices. Studies show that 80% of people are more likely to watch an entire video when captions are available.
  • Improving accessibility: Closed captions provide an essential service for viewers with hearing impairments, ensuring that everyone can access and comprehend the video's content.
  • Enhancing comprehension: For viewers who speak different languages or have varying levels of proficiency in the video's language, subtitles can aid in understanding the content and improve overall comprehension.

Ways to implementing VTT subtitles and closed captions in HTML5 video players

Adding VTT subtitles to HTML5 videos

HTML5 makes it straightforward to include subtitles or closed captions using the <track> element in your video tag. VTT files are used to define the text that appears at specific times during video playback.

Here’s an example of how to add a VTT file for subtitles in an HTML5 video player:

1<video controls>
2  <source src="video.mp4" type="video/mp4">
3  <!-- Adding English subtitles -->
4  <track label="English" kind="subtitles" srclang="en" src="subtitles_en.vtt" default>
5  <!-- Adding Spanish subtitles -->
6  <track label="Spanish" kind="subtitles" srclang="es" src="subtitles_es.vtt">
7</video>
8

In this code:

  • The <track> element specifies the language of the subtitles (srclang), the kind of track (subtitles, captions, etc.), and the file path (src).
  • The default attribute ensures the English subtitles are displayed by default.
  • Multiple <track> elements can be added to support subtitles in different languages.

The VTT file itself has a simple format where each cue is defined with a start and end time followed by the text to display. Here’s an example:

1WEBVTT
2
300:00:00.000 --> 00:00:05.000
4Welcome to our video!
5
600:00:05.500 --> 00:00:10.500
7In this tutorial, we will cover the basics of video streaming.

Handling multiple languages and dynamic subtitle loading

For global content, it’s essential to offer subtitles in multiple languages. One way to enhance user experience is by dynamically loading subtitles based on the user’s device language settings. JavaScript can be used to detect the user's language and load the appropriate VTT file dynamically.

Here’s how you can implement dynamic subtitle loading:

1// Get the user's language preference
2let userLang = navigator.language || navigator.userLanguage;
3
4// Reference the video element and track elements
5const video = document.getElementById('video-player');
6const track = document.createElement('track');
7
8// Set the correct subtitle track based on user's language
9if (userLang.startsWith('es')) {
10  track.src = 'subtitles_es.vtt';
11  track.srclang = 'es';
12  track.label = 'Spanish';
13} else {
14  track.src = 'subtitles_en.vtt';
15  track.srclang = 'en';
16  track.label = 'English';
17}
18
19// Add track to video
20track.kind = 'subtitles';
21track.default = true; // Set this as the default subtitle track
22video.appendChild(track);
23

In this example:

  • The navigator.language property detects the language settings of the user’s device or browser.
  • Based on the detected language, we dynamically set the correct VTT file (subtitles_en.vtt for English or subtitles_es.vtt for Spanish).
  • The appropriate <track> element is then added to the video player, ensuring that the right subtitles are displayed by default based on the user’s locale.

Subtitle generation with FastPix's API

FastPix simplifies this process with its advanced speech-to-text translation and automated subtitle features, allowing you to effortlessly generate accurate subtitles or closed captions for any video. For more details on how to implement this with FastPix’s API, click here.

4. Enhancing engagement with interactive content

Incorporating interactive elements into video content has emerged as a powerful strategy for enhancing engagement. Interactive videos allow viewers to actively participate in their viewing experience, fostering a deeper connection with the content and encouraging longer watch times.

Types of interactive elements

Clickable links and call-to-action (CTA) buttons: These elements allow viewers to take specific actions, such as visiting a website, signing up for a newsletter, or purchasing a product directly from the video. Effective CTAs can guide viewers through the desired customer journey.

Quizzes and polls: Incorporating quizzes or polls within videos can engage viewers by prompting them to answer questions related to the content. This not only enhances interactivity but also reinforces learning and retention.

Branching scenarios: Branching scenarios enable viewers to make choices that affect the direction of the video narrative. This creates a personalized experience, allowing viewers to explore different outcomes based on their decisions.

Embedded social sharing options: Allowing viewers to share specific moments or clips from the video on social media platforms can increase visibility and encourage audience interaction beyond the initial viewing experience.

Cut Video Cloud Costs by 8X, No Performance Loss

Know more

5. Development considerations to make videos Mobile-friendly

To create mobile-friendly video experiences, developers can implement various coding techniques and strategies that optimize video embedding and enhance user engagement. Below are some practical approaches along with relevant code snippets.

Responsive video embedding

To ensure that embedded YouTube videos are responsive, you can use the following HTML and CSS code. This allows the iframe to adjust its size based on the screen dimensions:

HTML

1<div class="video-container">
2    <iframe src="https://www.youtube.com/embed/VIDEO_ID" frameborder="0" allowfullscreen></iframe>
3</div>
4 
5
6<style>
7.video-container { 
8 position: relative;
9 padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
10 height: 0;
11 overflow: hidden; 
12} 
13.video-container iframe { 
14  position: absolute; 
15  top: 0;
16  left: 0; 
17  width: 100%; 
18  height: 100%; 
19}
20</style>
21

Hiding YouTube Iframes on mobile

You can hide YouTube videos on mobile devices using media queries in your CSS:

CSS

1@media screen and (max-width: 768px) {
2 .video-container { 
3		display: none; /* Hides video container on mobile */
4 	}
5 }

Removing controls and branding

To create a cleaner look for embedded YouTube videos, modify the embed URL by adding specific parameters:

HTML

1<iframe width="560" height="315" 
2        src="https://www.youtube.com/embed/VIDEO_ID?controls=0&modestbranding=1&showinfo=0" 
3        frameborder="0" allowfullscreen>
4</iframe>

controls=0: Hides the video controls.

modestbranding=1: Minimizes YouTube branding.

showinfo=0: Hides the title and uploader information (this parameter may be deprecated).

Lazy loading for performance

Implement lazy loading for your videos to improve page load times:

1<iframe 
2    loading="lazy" src="https://www.youtube.com/embed/VIDEO_ID" 
3    frameborder="0"
4    allowfullscreen>
5</iframe>

6. Optimizing video hosting and delivery

The success of your video content largely depends on how well it is hosted and delivered to viewers, especially in a mobile-first world. As mobile devices become the primary platform for video consumption, optimizing video hosting and delivery is crucial for ensuring seamless playback, quick load times, and an overall positive user experience.

Best practices for optimizing video delivery

To ensure optimal video delivery for mobile users, consider implementing the following best practices:

a) Use adaptive bitrate streaming

Adaptive bitrate streaming adjusts the quality of the video stream in real-time based on the viewer's internet connection speed and device capabilities. Implementing this technology allows viewers with slower connections to still access lower-quality versions of your videos without sacrificing their viewing experience entirely.

b) Optimize video formats

Choose widely supported video formats such as MP4 (H.264 codec) that ensure compatibility across various devices and platforms. Consider using modern formats like AV1 for better compression rates without compromising quality, particularly beneficial for mobile users with limited data plans. You can even use FastPix service which has 35% better compression compared to alternatives.

Netflix and YouTube are leading the adoption of the AV1 video codec, which improves compression efficiency over older codecs like H.264. AV1 enables higher video quality at lower bitrates, reducing buffering and improving playback, especially for mobile users with varying internet speeds. This move supports the growing demand for 4K and HDR content, while also promoting more efficient and sustainable streaming practices.

Netflix and YouTube adopting AV1 video codec

c) Implement preloading techniques

Utilize preloading strategies that allow videos to begin loading before the viewer clicks play, reducing wait times and enhancing user experience. Consider using thumbnail previews to engage viewers while the video loads in the background.

8. Measuring and improving mobile video performance

Video Analytics Platforms: Utilize dedicated video analytics tools such as YouTube Analytics and Facebook Insights for their platform.  You can also use third-party platforms to track comprehensive performance metrics if you want to build your own video centric platform.

One powerful tool to analyze your video performance and optimize for mobile is FastPix's video data platform. This comprehensive analytics tool provides granular insights into how your videos are performing across different devices, platforms, and audience segments.

Bottomline

Optimizing video content for mobile devices is essential as mobile consumption continues to rise. By implementing the strategies discussed in this blog such as choosing the right video orientation, creating engaging thumbnails, incorporating subtitles, and leveraging interactive elements you can significantly enhance viewer engagement and retention.

To further amplify your mobile video performance, consider utilizing FastPix. The platform offers APIs and comprehensive analytics tools that empower developers to create next-gen video experiences effortlessly. FastPix simplifies the complexities of video integration, allowing you to focus on delivering high-quality content while optimizing performance across various devices and platforms.

Try for Free

Enjoyed reading? You might also like

Try FastPix today!

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