10

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)

Ryan
  • 2,650
  • 3
  • 29
  • 43

2 Answers2

7

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

Uku Loskit
  • 40,868
  • 9
  • 92
  • 93
3

The easiest way to do this is to use the operating system's API to take print-screen captures. If you are using windows then I recommend doing it through through AutoHotKey. AutoHotKey provides a very easy scripting language that is higher-level and more intuitive than the Windows API. If you are able to use this software you can probably piece together what you need from one or two sources. For example, here is a thread (with code) for taking a screenshot and saving as a .jpg.

frank
  • 61
  • 2
  • Here is another thread that you would probably find even more useful. http://www.autohotkey.com/forum/topic58291.html – frank Aug 21 '11 at 03:41
  • The question specifies on a server! – Sylverdrag Aug 21 '11 at 03:44
  • 2
    @Sylverdrag So? There are windows servers you know! – frank Aug 21 '11 at 03:53
  • A PHP app on a server and you assume Windows? And what part is going to open the youtube video in a browser, screencapture the window, crop the screencapture to the youtube video, then restore focus to the next app? What if there are several users to the app? It is a server - several users can happen, you know? Your solution is a Rube Golberg machine that will break if anything is just slightly off. As a solution for a private user, fine. As part of a web app workflow running on a server, no F*** way. – Sylverdrag Aug 22 '11 at 17:19