0

I want to automate downloading videos from a website and/or ssd. However, if I close this process or quit it during debugging, I get a video which appears to be working, but only for the part of the video that has downloaded.

For example: I am downloading a video of 4 minutes long. I quit the process and only a part was download. This still shows up as the [filename].mp4. When you open the video you can watch the video until 3 minutes or another value less than 4 minutes. You get an error after and the video wont continue

Things I tried

  • Trying to use requests and 'content-length' to check if a video has been downloaded correctly and if not download and overwrite it. (Https://stackoverflow.com/questions/14270698/get-file-size-using-python-requests-while-only-getting-the-header) However I don't think the website returns this information. So this is not an option.

  • The code below. This seems very slow as it takes +- 1 second per video, but works.

from moviepy.editor import *

class testVideo:
    def testVideo(self, path):

        videoIsBad = True
        
        fileDuration = VideoFileClip(path).duration

        try: 
            VideoFileClip(path).get_frame(fileDuration-1)
            videoIsBad = False
        except:
            videoIsBad = True

        return videoIsBad

Questions

  1. Is there a better/faster package than moviepy?
  2. Is there a better way using moviepy, that I have not found yet? (I looked at the docs, but could not find a good option. VideoFileClip(path).is_playing(fileDuration-1) always returned true and was even slower.)
  3. Any other tips are appreciated :)
Pieter
  • 1
  • 1

0 Answers0