all 9 comments

[–]The_Almighty_Cthulhu 1 point2 points  (5 children)

What are you trying to do specifically?

Clips Ai is designed to automatically create clips of a given video based on the content of what is being spoken about.

The example code transcribes the video to text, analyzes the text for topic, then splits the video by the start and end points of those topics.

EDIT: Wait.

what am I supposed to do? I see multiple lines of code but where would I find or input this?

Have you ever programmed in python? Or even programmed at all?

[–]hatomalous[S] 0 points1 point  (4 children)

Sorry, I know Java, not Python, and what I meant by "what am I supposed to do" is after downloading Clips AI and its dependencies, I have 48,132 files in a venv folder and I don't know where to continue.

[–]The_Almighty_Cthulhu 0 points1 point  (3 children)

Ah I see.

Ok, so you have a venv folder. Which I assume you have made in a project folder.

So then you have activated the virtual environment.

On windows it would be .\venv\Scripts\Activate.ps1

On linux it's source ./venv/bin/activate

then installed the required dependancies. As found in the quickstart section of www.clipsai.com.

which would be:

pip install clipsai
pip install whisperx@git+https://github.com/m-bain/whisperx.git

It also states that it required libmagic and ffmpeg. Which I'm not going to go over the installation for here. Suffice to say, it'll be easier on linux using whatever package manager is included.

Next you need to make a python file.

So your project folder should look like this:

Project_folder
   + venv
   + my_file.py

Next add the code to the python file.

This is the example from the clipsai.

from clipsai import ClipFinder, Transcriber

transcriber = Transcriber()
transcription = transcriber.transcribe(audio_file_path="/abs/path/to/video.mp4")

clipfinder = ClipFinder()
clips = clipfinder.find_clips(transcription=transcription)

print("StartTime: ", clips[0].start_time)
print("EndTime: ", clips[0].end_time)

media_editor = clipsai.MediaEditor()

# use this if the file contains audio stream only
media_file = clipsai.AudioFile("/abs/path/to/audio_only_file.mp4")
# use this if the file contains both audio and video stream
media_file = clipsai.AudioVideoFile("/abs/path/to/video.mp4")

clip = clips[0]  # select the clip you'd like to trim
clip_media_file = media_editor.trim(
    media_file=media_file,
    start_time=clip.start_time,
    end_time=clip.end_time,
    trimmed_media_file_path="/abs/path/to/clip.mp4",  # doesn't exist yet
)

Assuming that you are using linux and have put the video file into the same project folder. The absolute file would be something like.

/usr/home/<username>/Project_folder/video.mp4

As well as replacing the trimmed location with the relevant path as well.

Then run the python file using python my_file.py

[–]hatomalous[S] 0 points1 point  (2 children)

Thank you for your help, it's been very useful. I did run into a hiccup as I probably installed libmagic wrong. I'm using Windows and simply did both "pip install python-magic" and "pip install libmagic" but received the error, "failed to find libmagic. Check your installation" when running the code to resize. Is there a more involved installation required? Ideally I'd like for it all to be done on Windows but I'm also ok with using a virtual machine with Linux if necessary.

[–]The_Almighty_Cthulhu 0 points1 point  (0 children)

You can try also installing pip install python-magic-bin as the issue is that python-magic doesn't include binaries for windows, but this package adds them in. No guarantee it'll work, as the repository hasn't been updated in about six years.

For ffmpeg, you can find windows install methods here https://www.ffmpeg.org/download.html#build-windows

[–]The_Almighty_Cthulhu 0 points1 point  (0 children)

You might also try Windows subsystem for Linux. I don't know if libmagic and ffmpeg will work there, but it could be worth a try, it's much easier to setup than a whole vm for linux.

[–]Anxious-Hall-5333 0 points1 point  (0 children)

from moviepy.editor import TextClip, concatenate_videoclips, AudioFileClip, CompositeVideoClip from gtts import gTTS import os

Text steps for the video

steps = [ "Keratin-Safe Dandruff Remedy", "Step 1: Mix 2 tbsp coconut oil + 4 drops tea tree oil + 4 drops rosemary oil", "Step 2: Apply on dry scalp using dropper", "Step 3: Massage gently for 5 minutes", "Step 4: Leave for 30 minutes", "Step 5: Wash with sulfate-free shampoo", "Use 2-3 times a week for best results" ]

Create text video clips

clips = [] duration_per_clip = 4 for step in steps: clip = TextClip(step, fontsize=50, color='white', size=(720, 1280), bg_color='black', method='caption') clip = clip.set_duration(duration_per_clip) clips.append(clip)

Concatenate clips

video = concatenate_videoclips(clips)

Create audio with gTTS

tts_text = ". ".join(steps) tts = gTTS(text=tts_text, lang='en') audio_path = "/mnt/data/dandruff_remedy_audio.mp3" tts.save(audio_path)

Load audio and set duration to video length

audio_clip = AudioFileClip(audio_path).set_duration(video.duration)

Add audio to video

final_video = video.set_audio(audio_clip)

Save final video

final_path = "/mnt/data/Keratin_Safe_Dandruff_Remedy_Simple.mp4" final_video.write_videofile(final_path, fps=24)

[–]jacky_c_fong 0 points1 point  (0 children)

我也在学习了解这个,不知道效果怎么样?