2

Greetings all,

I have been working to get thumbnail images for a site of mine and have made some fairly decent progress. I have been able to create thumbnails of images locally and those hosted on a remote server as I had hoped.

The issue I am having is that I am unable to do the same for Videos. I have successfully installed each of the following along with their dependencies and confirm they are all working locally:

  1. ffmpeg (and vicariously ffmpeg-PHP and ffmpegthumnailer)
  2. Imagick (currently working for all simple "image" thumbnail creation, local and remote)
  3. mplayer

As of yet I have been unable to find a method that would allow me to capture a thumbnail from my own video files on a remote server. The reason I am trying to connect to a remote video file is because these videos can range from 5MB to 300MB each and I don't desire to copy the entire movie locally just to create a thumbnail.

I had come across one of these that "may" allow capturing an image from a rtmp stream, which I conveniently do have access to ... but nothing fruitful came of it.

Any ideas would be greatly appreciated,

Thank you,

Silver Tiger


Update from Silver Tiger:

Looks like i had an alternative method via a third party. I used Zendcoder to convert the video files on the fly to a standard format that can play on my web project reliably, and as part of thier service, they will automatically create a dynamic thumbnail and upload it to my Amazon S3 along side the converted Video file.

Crisis averted, but in a roundabout way, and not a solution I could provide as a "solution" to anyone else unfortunately.

Silvertiger
  • 1,680
  • 2
  • 19
  • 32
  • Sorry that I am late to the party, but I have recently launched a service to do this that you may find useful and may be cheaper/faster than transcoding your video via Zencoder. https://github.com/Gazler/grabbio-php – Gazler Apr 08 '11 at 15:04
  • it works like this with ffmpeg http://stackoverflow.com/questions/2677317/how-to-read-remote-video-on-amazon-s3-using-ffmpeg – Patrice Gaillard Aug 21 '14 at 11:50

2 Answers2

0

If you have ffmpeg installed it should be quite easy. Try something like this

$movie = 'somefile.avi';  // video file
$time = '00:03:34';       // time where to take the snapshot
$cmd = "ffmpeg -i '{$movie}' -an -ss {$time} -an -r 1 -vframes 1 -y thumb.jpg";

$escCmd = escapeshellcmd($cmd);
system($escCmd);
tlenss
  • 2,609
  • 2
  • 22
  • 26
  • As i stated, local files work fine, but I need to work with remote files (i.e. "www.my_remote_file_server.com/something.avi"). All of the files uploaded by users are placed on a remote server, but I still need to create thumbnails. The movie files never "touch" the server where my web host is. – Silvertiger Mar 27 '11 at 08:58
  • 2
    If you put the `-ss` before the `-i`, it can work to thumbnail remote files quickly. You can use a remote URL for the input $movie. Make sure you are using a recent version of ffmpeg or avconv. – Sam Watkins Aug 06 '15 at 11:29
0

Maybe you could have a script on the remote server to call? This way the thumbnail is generated on the remote server, and then passed back to the front-end server.

The easiest way to do this is to install apache (or whatever you prefer) and host the thumbnail generation scripts on there. Then all you would need to do is call:

$imageData = file_get_contents('http://remotehost/generateThunmb.php?videoid=bleh');
Oliver O'Neill
  • 1,229
  • 6
  • 11
  • Unfortunately the "remote server" is just a cloud repository for the files uploaded by my users. (refer: amazon AWS S3 content hosting service). If i had access to that server system, i would have already implemented a local method there to perform the thumbnail creation. Unfortunately, all i have is access to upload and download from those servers, though I appreciate the feedback. – Silvertiger Mar 27 '11 at 12:44
  • Ah, then sorry. i have no idea. I dont think there is an easy solution for this. The first thing that pops to my mind is to grab part of the video for where you want it, between key frames. And hope that ffmpeg can use that for thumbnail generation. This is a rather hard thing to do, as you would need to parse the header of the video files, and then work out in bytes where the key frames are in the video and then retrieve just that range of bytes. But im going to put out there, i dont class this as a valid answer.. just a crazy idea. – Oliver O'Neill Mar 27 '11 at 12:51
  • I was able to perform a fopen() of remote images and push that to a wrapper for thumbnails, but I have been unable to find an equivalent wrapper for video :) ... I am still looking. Thank you for your input. – Silvertiger Mar 27 '11 at 13:00