1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Generating Thumbnail images from FLV files.

Discussion in 'PHP' started by phelixx, Sep 6, 2006.

  1. #1
    I am curious if there is a php script or a program that will allow me to generate a thumbnail either .png or .jpg of the flv file but also so that this flv file doesn't have to be local on my machine. So i can just give it the url of the .flv file and it will generate a thumbnail of this flash file. If anyone knows of a way that this can be done please let me know.

    thanks.
     
    phelixx, Sep 6, 2006 IP
  2. aartiles

    aartiles Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i know it is posible using this tool: ffmpeg, but i am not sure how
    http://gallery.menalto.com/node/57821

    ------------------------------------------
    www.equipo24.com
     
    aartiles, Dec 5, 2007 IP
  3. nicb1977

    nicb1977 Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I somehow used Watermark Master, have remained is happy. Tried?
     
    nicb1977, Jan 29, 2008 IP
  4. James.Blant

    James.Blant Active Member

    Messages:
    250
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #4
    does anyone use php4flv ?
     
    James.Blant, Jul 7, 2008 IP
  5. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #5
    That is fairly simle if you have ffmpeg installed on server

    Include code somewhere in code.

    $ffmpegpath = "/usr/bin/ffmpeg";
    
    	function make_jpg($input, $output, $fromdurasec="01") {
    		global $ffmpegpath;
    		if(!file_exists($input)) return false;
    				
    		$command = "$ffmpegpath -i $input -an -ss 00:00:$fromdurasec -r 1 -vframes 1 -f mjpeg -y $output";
    		
    		@exec( $command, $ret );
    		if(!file_exists($output)) return false;
    		if(filesize($output)==0) return false;
    		return true;
    	}
    Code (markup):

    ffmpeg ath may vary on servers, ask your server team if it is really '/usr/bin/ffmpeg'.


    Usage:

    #extract frame at 00:00:01 as jpeg
    make_jpg("/test.flv", "/test.jpg", "01"); 
    Code (markup):


    What is php4flv ? never heard of it.

    I hope it helps.
     
    Vooler, Jul 7, 2008 IP
  6. James.Blant

    James.Blant Active Member

    Messages:
    250
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #6
    my server does not allow me to excute exec() !
    also how i can check my server for ffmpeg existance ?

    that's a mistak :p
    here is it : http://code.google.com/p/flv4php/
     
    James.Blant, Jul 9, 2008 IP
  7. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #7
    The other way is if you have php_ffmpeg extension installed, that is less resources consuming way of extracting screenshost. You will have to ask your host if they have ffmpeg amongst installed modules.

    regards
     
    Vooler, Jul 9, 2008 IP
  8. killer2021

    killer2021 Peon

    Messages:
    872
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #8
    used this and it works great!
     
    killer2021, Nov 9, 2008 IP
  9. hanushh

    hanushh Peon

    Messages:
    198
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    this script works fine. but how can i modify ths script to make a thumbnail on a fly. i mean i want to use it ths way
    <img src="thumbnail.php?file=video.flv&percentage=60" />
    HTML:
     
    hanushh, Jan 11, 2009 IP
  10. youlikeicecream

    youlikeicecream Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Place the script into a php file called thumbnail.php

    insert a random string generator to create a nice random filename (and also check that it doesn't already exist)

    add a jpg file extension to the random string and use as the output variable for the "make_jpg" function.

    grab and sanitise the GET parameter for 'file' and use as input (create a static variable for the file system path to the flv)

    you might want to grab a url paramter for the timecode to take the thumbnail from or make a static one.

    Once passed in through the make_jpg function set the HTTP Header to reflect that you are going to return image data instead of Hypertext and then print the thumbnail to the screen.

    Job done.

    P.S, almost forgot. Thanks for the code snippet Vooler, really useful :)
     
    Last edited: Jul 7, 2010
    youlikeicecream, Jul 7, 2010 IP