Possible to capture still frames from a Youtube video?

Ryan picture Ryan · Aug 21, 2011 · Viewed 13k times · Source

I have a website based in PHP and I'm looking for a way to take a Youtube URL and capture still frames based on a specified interval (for example, capturing still frames every 5 seconds of a 1 minute youtube video)? How could I go about doing this?

I'm looking for general direction (understanding that the solutions may be complex).

Requirements: The solution needs to run on web server (independent of desktop applications)

Answer

Uku Loskit picture Uku Loskit · Aug 21, 2011

This solution should work just fine, although it may not be very stable because AFAIK youtube keeps changing things up and the video location is changed from time to time.

But the author keeps coming up with fixes, so it's good. This requires a Python interpreter though (should be available on any linux anyways these days).

  1. Get youtube-dl. Just download it and chmod +x youtube-dl https://github.com/rg3/youtube-dl

  2. Create a function which takes youtube url and feeds it to youtube-dl.

  3. The resulting video can now be modified with ffmpeg to take snapshots.

Skills required: starting subprocesses from PHP