5


I'm working on a video sharing website where people can upload their own videos and I want the most recent uploads to be shown on the index page, but not as videos but thumbnails, so that when you click on the thumbnail you get to the video page. You guys all know how youtube's index looks/works -- that's what I'm trying to simulate.

I read about ffmpeg but it seems to me it would only work if you have ffmpeg installed on your computer. I want this to be an automated process though without the user having to first install something on their pc.
Is there a way I can code this? Or do i have to use some kind of framework or CMS? Could this problem be solved by simply getting ffmpeg hosting (example)?
If there is no manual way to do this in php, is there way using python?

Fyi, my website is written in php and i use jwplayer to stream the videos.
Please note that I want to get a thumbnail from a video that's been uploaded on my server and not a youtube or vimeo thumbnail.

user3041398
  • 81
  • 2
  • 8
  • Seems to me like you have misunderstood something. ffmpeg needs to be installed on the server where the videos are uploaded to. When the user uploads a video you probably create an entry in a database and move the file somewhere. During this process you would also call ffmpeg to create a thumbnail for the video, no need for the user to have anything installed. – Jesper Blaase Nov 27 '13 at 11:19
  • Ah, thank you! Is it possible to install ffmpeg on a shared hosting server? – user3041398 Nov 27 '13 at 11:39
  • That entirely depends on the provider, but i would not count on it unless its something the specifically provide. – Jesper Blaase Nov 27 '13 at 11:59
  • A lot of shared hosts don't allow for it. – emaxsaun Nov 27 '13 at 15:17
  • You could simply [download a static binary of ffmpeg](http://ffmpeg.org/download.html#LinuxBuilds) (no need to install). – llogan Nov 27 '13 at 18:20
  • How does the static binary work? – user3041398 Nov 28 '13 at 11:55

1 Answers1

4

I have worked on this kind of issue and I am sure that user don't need ffmpeg on there pc instead you need a server which has ffmpeg installed.

To create thumbnail from video try the code below.

<?php
 $video = 'path/to/video.flv';
 $thumbnail = 'path/to/thumbnail.jpg';
 shell_exec("ffmpeg -i $video -deinterlace -an -ss 1 -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg $thumbnail 2>&1");
 ?>
Ram Sharma
  • 8,676
  • 7
  • 43
  • 56
  • 2
    If you want to seek into the video stream instead of grabbing the first "second", just add `-ss 00:10:00.1` (for instance) before the `-i` option. – Josh M. Sep 21 '14 at 19:26