#🔒 making my code run faster !

48 messages · Page 1 of 1 (latest)

split yoke
#

im making a script that just extracts audio then add subtitles to a video. using faster-whisper and moviepy.

i did some benchmarking and these are the times,
=== BENCHMARK RESULTS ===
video_render 358.28s
word_extraction 34.11s
subtitle_creation 3.30s
model_init 0.44s
whisper_transcribe 0.44s

the code is below

patent thistleBOT
#

@split yoke

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

#
Available tags

» defaultdict
» dict-get
» dictcomps
» discord-bot-hosting
» docstring
» dotenv
» dunder-methods
» empty-json
» enumerate
» environments
» envs
» equals-true
» except
» exit()
» f-string

#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

split yoke
vivid jacinth
#

are you familiar with ffmpeg? it may be faster to make the subtitles with something like pysubs2, save the subtitles separately and combine them with ffmpeg instead of moviepy

split yoke
#

not fully familar with but i could learn

#

ik moviepy uses ffmpeg so i could just take out the middleman moviepy

#

is there a ffmpeg library?

vivid jacinth
#

there are a few but most/all are just subprocess command builders. I have personally used ffmpeg-python in the past

split yoke
#

do u think i should

#

like can ffmpeg

#

edit videos like moviepy

vivid jacinth
#

yes, probably, with some time and effort
what kinda edits are you thinking about?

split yoke
#

just basic like

#

adding audio

#

and like editing the duration of the clip

#

maybe cropping

vivid jacinth
#

Oh yea, ofc those can be done

split yoke
#

ok

#

alr thank u

vivid jacinth
#

and ffmpeg is one of the most used programs on the planet so there's tons of documentation and examples on how to do all that online

split yoke
#

ok

#

thank u a lot

#

ffmpeg is in C right

#

so should be miles faster

vivid jacinth
#

theres also a ton of assembly and inline asm used in ffmpeg go they're really pulling out every optimization they can

#

they consistently post about new optimizations on social media

split yoke
#

wow alr

#

thanks

#

ima look up the

#

docs

split yoke
#

quick

#

question

#

can

#

ffmpeg

#

create

#

text

vivid jacinth
#

Oop sorry I missed this

#

@split yoke in what way do you mean "create
text"?

#

like bake in subtitles into the video?

#

or add a subtitle file to a video

#

(You can in both scenarios)

split yoke
#

ty @vivid jacinth

#

i found something i could use

patent thistleBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.