Logo

dev-resources.site

for different kinds of informations.

Skipping to the Good Parts: Implementing Netflix's Skip Intro Feature with Python Video Processing

Published at
2/5/2023
Categories
netflix
python
video
programming
Author
jahwi
Categories
4 categories in total
netflix
open
python
open
video
open
programming
open
Author
5 person written this
jahwi
open
Skipping to the Good Parts: Implementing Netflix's Skip Intro Feature with Python Video Processing

Netflix’s Skip Intro feature is about as iconic as the service itself, allowing subscribers to skip past intro and outro portions of tv shows. Since then, other streaming services have adopted this feature, making it a staple of the streaming world.

Recently, I began thinking about implementing this feature and this led me to make a small library to find similar portions in videos. It does this by hashing videos into frames, hashing these frames, and comparing similar frames between each comparison video and a reference video.

I decided to test this library on my favourite recently-cancelled Netflix show, Inside Job:


# Import the library
from similar_vid.similar_secs import Similar, save

# Load the file paths
file1 = "videos//inside_job//01.mkv"
file2 = "videos//inside_job//02.mkv"
file3 = "videos//inside_job//03.mkv"
file4 = "videos//inside_job//04.mkv"
file5 = "videos//inside_job//05.mkv"


if __name__ == "__main__":
    # Hash the videos
    inside_job = Similar(ref=file1, comp_arr = [file2, file3, file4, file5])

    # Match the videos
    inside_job.match(threshold=15)

    for match in inside_job.matches:
        print(match)

    # use the library's save function to save class fields as JSON for further use
    save(inside_job.matches, "outs//matches.json")
Enter fullscreen mode Exit fullscreen mode

In the above, we import the Similar class from my similar-vid library and pass it the reference video and an array of comparison videos. We then use the match method to speficy that we only want matches that are at least 15 seconds long. The library then hashes and matches the videos as such:

Screenshot of console output showing the library matching frames between videos

Description: A screenshot of the console showing the hashing and matching process.

These hashes are then stored in the matches field of the class instance as a list of dictionaries. Below that, we print the matches and use the library’s save method to save the matches to a json file:

A screenshot of the console showing the matching frames.

The returned arrays of the “matches” key, if any, are the beginning and ending matching seconds of the comparison video, respectively.

We can then pass this as context to the frontend. Using Javascript to modify the video’s currentTime property, we can skip the intro portion:

Screenshot video showing implementing the Skip Intro feature implemented in the frontend

As can be seen in the above gif, the Skip Intro button appears over the intro portion.

The similar_vid library can be found here: https://github.com/jahwi/similar-vid

Thanks for reading.

netflix Article's
30 articles in total
Favicon
How to Develop an OTT App like Netflix?
Favicon
Netflix Thailand: การผสมผสานเทคโนโลยี วัฒนธรรม และนวัตกรรมในออฟฟิศ
Favicon
Prime Video vs. Netflix: Which Streaming Service is Best for 2025?
Favicon
Use a proxy to unblock videos on YouTube or other sites
Favicon
🚀 Netflix's Secret Sauce: How AWS Streams Your Binge-Worthy Shows to 231 Million Couch Potatoes 🍿
Favicon
Video Streaming for Fitness: A Powerful Tool with Mogi I/O’s OTT Streaming Solution
Favicon
On Stealing People's Attention
Favicon
Unraveling the Enigmatic Thriller: Can This Breakout Netflix Whodunit Justify Its Sudden Popularity?
Favicon
How to Save on Netflix: A Global Subscription Hack
Favicon
How to Download Netflix Movies on MacBook for Offline Viewing
Favicon
Usando Consultas de Percolação do Elasticsearch, Netflix Aperfeiçoa Buscas Reversas Eficientemente
Favicon
Documentário que todo Profissional de TI deve Ver: O Dilema da Redes (2020).
Favicon
Building Netflix Clone with NextJs 13.4: Part 1
Favicon
Architectural Battle: Monolith vs. Microservices - A Netflix Story
Favicon
🚀The Netflix DevSecOps Project 🚀
Favicon
Unleashing the Power of Microservices: A Deep Dive into Their Importance and the Netflix Breakdown
Favicon
Unlocking Success: Netflix's Shift to AWS - A Hosting Reviews Perspective
Favicon
End to End Netflix data analytics and recommendation system project using Microsoft Azure tools
Favicon
Netflix Việt Nam chính thức tiến hành xác minh thiết bị thuộc hộ gia đình
Favicon
Netflix's DevOps Journey: From DVD Rentals to Global Streaming Dominance
Favicon
Netflix UI Clone
Favicon
Netflix UI Clone
Favicon
Skipping to the Good Parts: Implementing Netflix's Skip Intro Feature with Python Video Processing
Favicon
Simian Army - Netflix - Disaster Recovery - AWS
Favicon
Pure CSS Logo: Netflix
Favicon
Cara jualan Netflix di Shopee
Favicon
Making a Microservice More Resilient Against Downstream Failure
Favicon
GraphQL Using Netflix’s DGS Framework & Spring-Boot (Schema-First Approach)
Favicon
Use Netflix To Easily Improve Your Design Skills
Favicon
Streaming Service like Netflix: How to Make a Breakthrough

Featured ones: