Photo by

Create mini clips for long video

Author
Venessa Fabio
Author
Venessa Fabio
·
Dec 5, 2022
·
3 min read

Create video clips automatically from a long video. The following code can be used to create social media posts or to get a short clip of the most important part.

Create a pipeline with the highlights and split by topic skills to determine which segment has the most highlights. Each segment refers to a different topic and is created by the split by topic skill. Additionally, this method gives a headline for each segment and timestamps for the beginnings and ends of segments, allowing you to easily edit the video. This is just one example of how we can help you with your own custom needs.

You can get your own API key here and start experimenting with different pipelines.

{{cta}}

As an example, let's take a look at this YouTube video: "https://www.youtube.com/watch?v=mYD7Y9CXeUw". Based on how many highlights each segment had we can determine the top 3 segments.

```

import oneai

import base64

oneai.api_key = "[YOUR ONEAI API KEY]"

with open("AudioFile.mp3", "rb") as f:

    pipeline = oneai.Pipeline(

        steps = [

            oneai.skills.Transcribe(),

            oneai.skills.Proofread(),

            oneai.skills.SplitByTopic(),

            oneai.skills.Highlights(),

          ]

        )

    Output = pipeline.run(f)

# Split the recording into chapters

chapters = [{"chapter_name":x.data['subheading'],"chapter_start":x.timestamp,"chapter_end":x.timestamp_end,"highlight_count":0} for x in Output.transcription.proofread.segments]

#Find the chapters with the most highlights

for highlight in Output.transcription.proofread.highlights:

    for chapter in chapters:

        if highlight.timestamp >= chapter["chapter_start"]:

            chapter["highlight_count"] += 1

#get the top 3 chapters

top_3 = sorted(chapters, key=lambda x: x['highlight_count'],reverse=True)[:2]

print(top_3)

```

```

[{'chapter_name': 'How I studied the brain',  'chapter_start': datetime.timedelta(seconds=15, microseconds=650000),  'chapter_end': datetime.timedelta(seconds=308, microseconds=690000),  'highlight_count': 56}, {'chapter_name': 'What is your left hemisphere?',  'chapter_start': datetime.timedelta(seconds=309, microseconds=410000),  'chapter_end': datetime.timedelta(seconds=430, microseconds=730000),  'highlight_count': 42}]

```

API isn't your thing? Try this fast & easy clipmaker.

Ask our NLP experts about analyzing videos

TURN YOUR CoNTENT INTO A GPT AGENT

Solely based on your most up-to-date content – websites, PDFs, or internal systems – with built-in fact-checking for enhanced trust.

Read Next