Help FFMPEG Thumb

Started on the old forum in August 2011 · view the original in the archive · old links redirect here

9 replies · 1,073 views · started 15 years ago · 1 min read

4 participants
redrdx Developer · 80 posts #1

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=Sonu&id=4&W=120&H=120&k=20

here is snippet

<?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, $gd, 0, 0, 0, 0, $W, $H, $wn, $hn);
imageGif($new,null,100);

?>

Life On Clicks External image (may be gone) Get More Tricks Add Me On Gtalk ID Rdxmob@gmail.com

subzero Super moderator Fellow · 3,954 posts #2

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.

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

subzero Super moderator Fellow · 3,954 posts #4

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.

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

ba_maram_shiraz Newbie · 6 posts #6

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 😀

Pro Noob Newbie · 3 posts #8

$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"

subzero Super moderator Fellow · 3,954 posts #9

Here is my script i made 5 months ago to help a mate..

<?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); 
?>

 

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

redrdx Developer · 80 posts #10

subzero wrote: Here is my script i made 5 months ago to help a mate..

<?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

Life On Clicks External image (may be gone) Get More Tricks Add Me On Gtalk ID Rdxmob@gmail.com

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close