Help FFMPEG Thumb

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • redrdx
    replied
    Originally posted by subzero View Post
    Here is my script i made 5 months ago to help a mate..
    Code:
    <?php
    function make($video,$ige){ 
    
    // where ffmpeg is located 
    $ffmpeg = '/usr/local/bin/ffmpeg'; 
    
    //where to save the image 
    $image = "$ige"; 
    
    //time to take screenshot at 
    $interval = 5; 
    
    //screenshot size 
    $size = "100x50"; 
    
    //ffmpeg command 
    $cmd = "$ffmpeg -i $video -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1"; 
    $return = `$cmd`;
    } 
    
    $conf["items_per_page"] = 5;
    $page = $_GET["page"];
    if (!isset($page)) 
    {
    $page = 0;
    } 
    $total = 0; 
    if(!($dp = opendir("files/$_GET[w]"))) die ("Cannot open ./"); 
    $file_array = array(); 
    while ($file = readdir ($dp)) 
    { 
    if(substr($file,0,1) != '.' and $file != "index.php" and $file != "screens" and $file != "modrule.php") 
    { 
    $file_array[] = $file; 
    } 
    } 
    $file_count = count ($file_array); 
    sort ($file_array); 
    
    if ($file_count > 0) 
    { 
    $first_record = $page * $conf["items_per_page"]; 
    $last_record = $first_record + $conf["items_per_page"]; 
    while (list($fileIndexValue, $file_name) = each ($file_array)) 
    { 
    if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record)) 
    { 
    $where = "files/$_GET[w]/$file_name";
    $filename = "files/video/screens/$file_name.jpg"; 
    if (file_exists($filename)){ 
    }else{ 
    $ige = "files/video/screens/$file_name.jpg"; 
    $video = "files/video/$file_name"; 
    make("$video","$ige");
    } 
    echo "<div><img src=\"modrule.php?im=$file_name.jpg\" alt=\"Screen Shots\"/><br/><a href=\"?act=download&f=$_GET[w]&f2=$file_name\">$file_name</a> (". round(filesize($where)/1024,1) . "kb) 
    </div>"; 
    $FIND = "files/$_GET[w]/$file_name";
    $total = $total + filesize($FIND); 
    } 
    } 
    if (($file_count > 0) AND ($page != 0)) 
    { 
    // previous button 
    $prev_page = $page -1; 
    echo "<div> 
    <a href=\"".$_SERVER["PHP_SELF"]."?page=$prev_page&act=$_GET[act]&w=$_GET[w]\">Prev</a> 
    </div>"; 
    } 
    if (($file_count > 0) AND ($last_record < $file_count)) 
    { 
    // next button 
    $next_page = $page + 1; 
    echo "<div>
    <a href=\"".$_SERVER["PHP_SELF"]."?page=$next_page&act=$_GET[act]&w=$_GET[w]\">Next</a> 
    </div>"; 
    } 
    
    echo "<div> Directory: $file_count </div>";
     
    if ($file_count == 1) 
    {
    echo "<div>file";
    }else{
    echo "<div>files";
    } 
    echo " (" . round($total/1024,1) . "kb)</div>"; 
    
     
    }
    closedir($dp); 
    ?>
    pls edit my code that i post on first

    Leave a comment:


  • subzero
    replied
    Here is my script i made 5 months ago to help a mate..
    Code:
    <?php
    function make($video,$ige){ 
    
    // where ffmpeg is located 
    $ffmpeg = '/usr/local/bin/ffmpeg'; 
    
    //where to save the image 
    $image = "$ige"; 
    
    //time to take screenshot at 
    $interval = 5; 
    
    //screenshot size 
    $size = "100x50"; 
    
    //ffmpeg command 
    $cmd = "$ffmpeg -i $video -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1"; 
    $return = `$cmd`;
    } 
    
    $conf["items_per_page"] = 5;
    $page = $_GET["page"];
    if (!isset($page)) 
    {
    $page = 0;
    } 
    $total = 0; 
    if(!($dp = opendir("files/$_GET[w]"))) die ("Cannot open ./"); 
    $file_array = array(); 
    while ($file = readdir ($dp)) 
    { 
    if(substr($file,0,1) != '.' and $file != "index.php" and $file != "screens" and $file != "modrule.php") 
    { 
    $file_array[] = $file; 
    } 
    } 
    $file_count = count ($file_array); 
    sort ($file_array); 
    
    if ($file_count > 0) 
    { 
    $first_record = $page * $conf["items_per_page"]; 
    $last_record = $first_record + $conf["items_per_page"]; 
    while (list($fileIndexValue, $file_name) = each ($file_array)) 
    { 
    if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record)) 
    { 
    $where = "files/$_GET[w]/$file_name";
    $filename = "files/video/screens/$file_name.jpg"; 
    if (file_exists($filename)){ 
    }else{ 
    $ige = "files/video/screens/$file_name.jpg"; 
    $video = "files/video/$file_name"; 
    make("$video","$ige");
    } 
    echo "<div><img src=\"modrule.php?im=$file_name.jpg\" alt=\"Screen Shots\"/><br/><a href=\"?act=download&amp;f=$_GET[w]&amp;f2=$file_name\">$file_name</a> (". round(filesize($where)/1024,1) . "kb) 
    </div>"; 
    $FIND = "files/$_GET[w]/$file_name";
    $total = $total + filesize($FIND); 
    } 
    } 
    if (($file_count > 0) AND ($page != 0)) 
    { 
    // previous button 
    $prev_page = $page -1; 
    echo "<div> 
    <a href=\"".$_SERVER["PHP_SELF"]."?page=$prev_page&amp;act=$_GET[act]&amp;w=$_GET[w]\">Prev</a> 
    </div>"; 
    } 
    if (($file_count > 0) AND ($last_record < $file_count)) 
    { 
    // next button 
    $next_page = $page + 1; 
    echo "<div>
    <a href=\"".$_SERVER["PHP_SELF"]."?page=$next_page&amp;act=$_GET[act]&amp;w=$_GET[w]\">Next</a> 
    </div>"; 
    } 
    
    echo "<div> Directory: $file_count </div>";
     
    if ($file_count == 1) 
    {
    echo "<div>file";
    }else{
    echo "<div>files";
    } 
    echo " (" . round($total/1024,1) . "kb)</div>"; 
    
     
    }
    closedir($dp); 
    ?>

    Leave a comment:


  • Pro Noob
    replied
    $vid_file = "my_video.3gp";
    exec('ffmpeg -i files/videos/'.$vid_file.' -f mjpeg -vframes 1 -s 60x60 -an files/videos/thumbs/'.$vid_file.'.jpg');


    This will get "files/videos/my_video.3gp" and create a thumbnail 60px by 60px and save it at "files/videos/thumbs/my_video.3gp.jpg"

    Leave a comment:


  • redrdx
    replied
    can u share that maded script

    Leave a comment:


  • ba_maram_shiraz
    replied
    i think if you load video for once and get thamb and save it and next time you load image to view , not load video and get thumb again.
    Confirm Post #4 :D

    Leave a comment:


  • redrdx
    replied
    humm great so now m gona to share full script

    Leave a comment:


  • subzero
    replied
    image that needs to load each view

    10 per user from the file you using now loads cpu each opening and closing the ffmpeg system.

    my way is load it once image always there to watch.

    Leave a comment:


  • redrdx
    replied
    i cannot understand pls explain me ???

    Leave a comment:


  • subzero
    replied
    thumbs is working ???

    but i so like making the images that will make less cpu needed as each time site loads images from video it will use cpu think about 100 users looking at videos oh boy say good bye to server speed or server in full.

    Leave a comment:


  • redrdx
    started a topic Help FFMPEG Thumb

    Help FFMPEG Thumb

    hi everyone pls help me to get ffmpeg videos thumbs in a folder my script genrate videos thumb on air like check demo here http://rdxwar.com/t/ffmpeg.php?c=Son...120&H=120&k=20


    here is snippet
    PHP Code:
    <?php

    /**
     * @author [FaNiska]
     * @copyright 2009
     * Загруз центр
     * Предложения, идеи, вопросы и об ошибках писать в icq 65-64-538 или на mobi-m-ru@ya.ru
     */
     
    session_start();
    include 
    'inc/db_connect.php';
    include 
    'inc/function.php';
    include 
    'inc/set.php';
    header('Content-type: image/gif');
    $W intval($_GET['W']);
    $H intval($_GET['H']);
    $kadr intval($_GET['k']);
    $file_info mysql_fetch_array(mysql_query('SELECT `s_name` FROM `'.$table.'` WHERE `id` = '.$id.' LIMIT 1'));


    //echo $file_info['s_name'];
    $mov = new ffmpeg_movie(realpath($file_info['s_name']));
    //$mov = new ffmpeg_movie($pic, false);
    $wn $mov->GetFrameWidth();
    $hn $mov->GetFrameHeight();

    $frame $mov->getFrame($kadr);

    $gd $frame->toGDImage();

    if(!
    $W and !$H)
    {
    $size explode('*',$setup['prev_size']);
    $W round(intval($size[0])); // ширина картинки
    $H round(intval($size[1])); // высота картинки
    }
    $new imageCreateTrueColor($W$H);
    imageCopyResized($new$gd0000$W$H$wn$hn);
    imageGif($new,null,100);


    ?>
Working...
X