2

I have url of a video files and I want to generate the thumbnail each of this video source url.I'm using Django.

My application does this:-

1. Crawl the some webpage
2. Extract all the video link from it.
3. If there are thumbnails, get those thumbnails.
4. if not thumbnails:
    #here I need to generate video thumbnails from the
    #links I extracted in 2nd step.

Is there any way to do this without downloading the complete video and generating thumbnails.

If I download each video, then there will be lot of bandwidth wastage and require lot time.

Thanks

vaibhav1312
  • 863
  • 4
  • 13
  • 31
  • Anyone looking for a Django specific solution take a look at https://stackoverflow.com/a/76044945/9564152 – Eric O. Apr 18 '23 at 13:03

1 Answers1

8

You should try ffmpeg. sudo apt-get install ffmpeg

I haven't tested this solution but I was just interested so I looked around a bit.

ffmpeg -ss 00:03:00 -i Underworld.Awakening.avi -frames:v 1 out1.jpg

This example will produce one image frame (out1.jpg) somewhere around the third minute from the beginning of the movie. The input will be parsed using keyframes, which is very fast. The drawback is that it will also finish the seeking at some keyframe, not necessarily located at specified time (00:03:00), so the seeking will not be as accurate as expected.

Source: Fastest way to extract a specific frame from a video (PHP/ffmpeg/anything)

Another answer claims it's possible to use it via http on remote videos so it may worth a try.

ffmpeg -i "http://subdomain.cloudfront.net/video.mp4" -ss 00:00:10 -vframes 1 -f image2     
"image%03d.jpg"

Source: How to read remote video on Amazon S3 using ffmpeg

Hope it helps. Let us know about results.

Community
  • 1
  • 1
martintrapp
  • 769
  • 6
  • 15
  • How do i call it using subprocess, I mean calling subprocess is easy but i gor command line error.SyntaxError: invalid syntax – vaibhav1312 Dec 19 '14 at 13:36
  • Have you tried to run it in the terminal? I'd start with that first then implement it to django after everything works as expected. – martintrapp Dec 19 '14 at 13:45
  • 1
    However if you want to run the command with subprocess: **subprocess.call('COMMAND LINE HERE', shell=True)** Note, the official Python documentation states a warning about using the shell=True argument. "Invoking the system shell with shell=True can be a security hazard if combined with untrusted input" – martintrapp Dec 19 '14 at 13:50