0

I am trying to upload videos made using moviepy to YouTube but when i finally upload them, i can't play them. The video playback stops at 6 seconds. (e.g. https://www.youtube.com/watch?v=CLSWs63ygH0).

I've tried changing the audio codec from mp3 to acc and i've tried changing the video extensions and codecs. I tried .mp4 (mpeg4 and libx264) and .webm but nothing seems to change :(

The videos are pretty long, i know, but if I make the video using a video editing tool, everything works. I'm not sure what is the difference between making a video using a video editor and moviepy. The thing is that exporting a video with a video editor takes x20 the time that exporting with moviepy takes.

My code:

from moviepy.editor import *
from cairosvg import svg2png
import wget

base_url="/Users/Nicolas/Desktop/Programacion/AUDIOLIBROS/Descarga_Libros/libros/pagina_1/"

filename="a-a-milne_the-red-house-mystery_advanced.mp3"
name=filename.replace("_advanced.mp3", "")


myclip = ImageClip(base_url+f"cover-a-a-milne_the-red-house-mystery-min.png")

audioclip = AudioFileClip(base_url+f"{name}_advanced.mp3").subclip((1,13), None)
myclip.set_duration(5).set_audio(audioclip).write_videofile(base_url+f"{name}_advanced.webm", fps=29.97)

EDIT: The video visibility is know set to "hidden" so you can actually get to the video using the link provided.

  • FYI [the video you shared us](https://www.youtube.com/watch?v=CLSWs63ygH0) has its visibility set to private. – Benjamin Loison Jul 04 '22 at 20:45
  • "exporting a video with a video editor takes x20 the time".... this is explained by the fact that `moviepy` crops at 6 seconds or are you comparing like for like ? – D.L Jul 04 '22 at 20:55
  • @BenjaminLoison You can know watch the video :) sorry for that – Nicolás Bermell Jul 08 '22 at 02:28
  • @D.L I'm comparing the two methods. – Nicolás Bermell Jul 08 '22 at 02:29
  • @D.L I don't use MoviePy (or even Python) but do you think that last line with `myclip.set_duration(5)` is effing things up here? I wonder if that `5` seconds number is connected to the asker's _"The video playback stops at 6 seconds."_ (where that stop value might have some rounding up, as done by the asker's media player/tool)... – VC.One Jul 10 '22 at 11:06

1 Answers1

0

According to MoviePy's documentation on creating and exporting video clips(https://zulko.github.io/moviepy/getting_started/videoclips.html), the duration of the clip has to be set manually and on your code, that line myclip.set_duration(5) does exactly that. You have set the duration to 5 seconds. code from the official documentation