Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow encoding of video #5

Open
hunterhogan opened this issue Sep 22, 2023 · 2 comments
Open

Slow encoding of video #5

hunterhogan opened this issue Sep 22, 2023 · 2 comments

Comments

@hunterhogan
Copy link

video_generator.py creates the video using write_videofile(), which requires re-encoding the entire video. Furthermore, I think this code is recursively concatenating the video clip one clip at a time, which is inefficient, to say the least.

#Generating Stock Video 
    if (stockclip.duration < final_audio.duration):
        while (stockclip.duration < final_audio.duration):
            stockclip=concatenate_videoclips([stockclip,stockclip])

Since the video files are merely concatenated, it would be much faster to stream copy the files. I don't know how to write the command using moviepy but I know the command for FFmpeg. The following command should work for videos without the introduction. The FFmpeg wiki has an excellent explanation of concatenation. (To make it easier to read, it is split across multiple lines, but it should all be on one line.)

ffmpeg
-hide_banner 
-loglevel quiet
-an -stream_loop -1 -t final_audio.duration -i "stockclip"
-i "final_audio"
-codec:video copy 
"FinalPath"
@iamDyeus
Copy link
Member

Yeah, am Aware that the video encoding is slow. When I first started the project, I didn't focus on efficiency. If it worked, I left it. It's great that you understood the code. Lately, I've been rewriting the entire code for better performance. I've also integrated Eleven Labs Speech for better text-to-speech. Honestly, even I found my own initial code a bit tricky to follow!

@iamDyeus
Copy link
Member

Also, I'll make sure to enhance the video encoding in the upcoming commit, which I plan to make by the end of next month. Thanks for pointing out the FFMPEG command and resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants