Have PHP create a thumbnail preview of flv file?

Discussion in 'PHP' started by wwwbryan, Apr 3, 2011.

  1. #1
    Is that possible to do without ffmpeg? I need it to work on most servers. I have tried php4flv but I get nothing but errors when I try it on php4 or php5.
     
    wwwbryan, Apr 3, 2011 IP
  2. ngcoders

    ngcoders Active Member

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #2
    Then you will need to parse the flv video data and make a thumbnail for it , haven't seen such a script yet, should not be easy either.

    Most hosting have a ffmpeg now , so you should not be worried. Also flv is just a container their might be different video formats in their requiring different set of coding.

    Not easy if you are thinking of writing one , else use ffmpeg ... just one line of code.
     
    ngcoders, Apr 4, 2011 IP
  3. JoelLarson

    JoelLarson Peon

    Messages:
    61
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Using ffmpeg (and not every doing this in my life nor testing it), I'd figure it to work in this fashion based on the docs:

    <?php
    
    // Set the media as a ffmeg_movie object instance.
    $movie = new ffmpeg_movie('/path/to/media');
    
    // Count the total frames in the media object.
    $total_frames = $movie->getFrameCount();
    
    // Get a random frame from the media (which returns a ffmpeg_frame object)
    $frame = $movie->getFrame(mt_rand(1, $total_frames));
    
    // Have the ffmpeg_frame object return it as a truecolor GD image.
    $frame->toGDImage();
    PHP:
     
    JoelLarson, Apr 4, 2011 IP