RedditVideoMakerBot icon indicating copy to clipboard operation
RedditVideoMakerBot copied to clipboard

Ending of the video is buggy for me.

Open mlvps opened this issue 4 years ago • 25 comments

Here is an example. Look at the ending:

https://user-images.githubusercontent.com/65528389/171937326-28e00a67-3fc2-4bf3-acd4-bb8dc4ee77fb.mp4

Anyone got an idea how to fix it?

mlvps avatar Jun 03 '22 19:06 mlvps

Does this happen on every video you generate? Or was it just this one?

arjun-dureja avatar Jun 03 '22 20:06 arjun-dureja

It seems to happen every so often. I've had it on a few of mine too

callumio avatar Jun 03 '22 20:06 callumio

Does this happen on every video you generate? Or was it just this one?

happens almost every time for me. It seems that some videos are worse than others tho

mlvps avatar Jun 03 '22 20:06 mlvps

Do you mind sending the full video? I need more context on this issue.

uberBuilder24 avatar Jun 03 '22 20:06 uberBuilder24

Do you mind sending the full video? I need more context on this issue.

the video was too big for github thats why I didnt upload the full video. I will try to compress it tho hold on

mlvps avatar Jun 03 '22 20:06 mlvps

Can you do Dropbox or Drive?

uberBuilder24 avatar Jun 03 '22 20:06 uberBuilder24

happens almost every time for me. It seems that some videos are worse than others tho

Does this also happen when you use the female voice?

arjun-dureja avatar Jun 03 '22 20:06 arjun-dureja

happens almost every time for me. It seems that some videos are worse than others tho

Does this also happen when you use the female voice?

It happens regardless, I was able to fix it on my end, but I need more context to see if it's the same issue.

uberBuilder24 avatar Jun 03 '22 20:06 uberBuilder24

happens almost every time for me. It seems that some videos are worse than others tho

Does this also happen when you use the female voice?

It happens regardless, I was able to fix it on my end, but I need more context to see if it's the same issue.

https://user-images.githubusercontent.com/65528389/171948410-d485915d-4144-4e03-96c0-4f233f221c31.mp4

here is the compressed video. it isnt the exact same vid because it got replaced, but its the same reddit post.

mlvps avatar Jun 03 '22 20:06 mlvps

In final_video.py, replace:

final = CompositeVideoClip([background_clip, image_concat])
final.write_videofile(
    "assets/final_video.mp4", fps=30, audio_codec="aac", audio_bitrate="192k"
)

With:

final = CompositeVideoClip([background_clip, image_concat])
final.write_videofile("assets/final_clip.mp4", fps=30, audio_codec="aac", audio_bitrate="192k")
ffmpeg_extract_subclip("assets/final_clip.mp4", 0, length, targetname="assets/final_video.mp4")
os.remove("assets/final_clip.mp4")

And add to the top of your file: from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip.

uberBuilder24 avatar Jun 03 '22 20:06 uberBuilder24

Thanks! it says "length" isnt defined tho

mlvps avatar Jun 03 '22 20:06 mlvps

Oh, yeah. So replace def make_final_video(number_of_clips): with def make_final_video(number_of_clips, length): and in main.py, replace final_video = make_final_video(number_of_comments) with final_video = make_final_video(number_of_comments, length).

uberBuilder24 avatar Jun 03 '22 20:06 uberBuilder24

Seems to work! Thank you so much!! I sometimes get this error tho, do you know what it means or how to fix it?

Traceback (most recent call last): File "C:\Users\User\Desktop\RedditVideoMakerBot-master\main.py", line 19, in <module> length, number_of_comments = save_text_to_mp3(reddit_object) File "C:\Users\User\Desktop\RedditVideoMakerBot-master\video_creation\voices.py", line 46, in save_text_to_mp3 length += MP3(f"assets/mp3/{idx}.mp3").info.length File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\mutagen\_file.py", line 48, in __init__ self.load(*args, **kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\mutagen\_util.py", line 156, in wrapper return func(self, h, *args, **kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\mutagen\id3\_file.py", line 421, in load self.info = self._Info(fileobj, offset) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\mutagen\_util.py", line 185, in wrapper return func(*args, **kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\mutagen\mp3\__init__.py", line 402, in __init__ raise HeaderNotFoundError("can't sync to MPEG frame") mutagen.mp3.HeaderNotFoundError: can't sync to MPEG frame

I think I got it a couple of times before as well, but I dont know what it means. It seems as if it happens to some specific reddit posts tho. (it isnt just random)

mlvps avatar Jun 03 '22 20:06 mlvps

I have never gotten that error before... mind trying with another Reddit thread and seeing if that works?

uberBuilder24 avatar Jun 03 '22 21:06 uberBuilder24

A lot of people using the male voice are getting that error. We're still trying to come up with a solution https://github.com/elebumm/RedditVideoMakerBot/pull/92

arjun-dureja avatar Jun 03 '22 21:06 arjun-dureja

Yeah, I see that. I got that problem once, reran it, and it worked fine.

uberBuilder24 avatar Jun 03 '22 21:06 uberBuilder24

A lot of people using the male voice are getting that error. We're still trying to come up with a solution #92

interesting, thanks for the help! Ill try to find a solution

mlvps avatar Jun 03 '22 21:06 mlvps

video_creation\voices.py", line 46, in save_text_to_mp3 length += MP3(f"assets/mp3/{idx}.mp3").info.length

As the error mentions, there is an issue getting the mp3 length. My solution was to switch from Mutagen MP3 to pydub AudioSegment

from pydub import AudioSegment

audio = AudioSegment.from_file("assets/{}/mp3/title.mp3".format(path)) length += audio.duration_seconds

Source: https://github.com/jiaaro/pydub

Verywelldone avatar Jun 04 '22 07:06 Verywelldone

There should be a PR fixing this.

alhassanv avatar Jun 04 '22 10:06 alhassanv

video_creation\voices.py", line 46, in save_text_to_mp3 length += MP3(f"assets/mp3/{idx}.mp3").info.length

As the error mentions, there is an issue getting the mp3 length. My solution was to switch from Mutagen MP3 to pydub AudioSegment

from pydub import AudioSegment

audio = AudioSegment.from_file("assets/{}/mp3/title.mp3".format(path)) length += audio.duration_seconds

Source: https://github.com/jiaaro/pydub

"path" is not defined

mlvps avatar Jun 04 '22 15:06 mlvps