Skip to content
Advertisement

pytube (python) video stops playing video after few seconds

I have been using pytube to create my youtube video downloader and after the video is done downloading and compiling and i play it, it plays for only a few seconds then just displays a still image while the audio continues in background

These are the functions in file “module.py”

JavaScript

And this is the “main.py” file:

JavaScript

Advertisement

Answer

I tried your code and it downloads video file correctly but problem is when it mixs video and audio.

I think problem it that it writes new video with the same name as original video – probably it doesn’t load old video to memory but it reads it all time from file – and this makes conflict.

I think you should write new video with new (temporary) filename and later rename it to expected name. Or you should download video with temporary name (i.e. video.mp4)


My code which I used for tests

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement