PDA

View Full Version : سوال: سوال در مورد عکس گرفتن از یک فریم خاص از فایل flv بوسیله php



hamed.taran71
پنج شنبه 15 فروردین 1392, 23:35 عصر
خدمت استادان و پیشکسوتان عزیز سلام عرض میکنم.
سوال من اینه که چجوری میتونم با پی اچ پی از فایل ویدئویی flv عکس بگیرم؟ این عکسو بعنوان
پیش نمایش فیلم که مثلا یه لینکه استفاده کنم. خیلی از سایتارو گشتم ولی به نتیجه مطلوبی نرسیدم.
چند نمونه کد دیدم ولی از اونجایی که من مبتدی هستم سر در نیاووردم.
مثلا توی کد زیر که از یه سایت خارجی پیداش کردم نمیدونم قضیه از چه قراره، خود فایل فلش که کد پی اچ پی قراره از یکی از فریماش عکس بگیره اصلا لینکشو نمیبینم، فقط تعدادی پیکسلو توی یه حلقه با پست گرفته و
در آخر تبدیل به عکس شده،
من واقعا گیج شدم، از اساتید محترم خواهشم اینه که یه راهنمایی کامل انجام بدن، چون یه سرچ بزنین میبینین
که جاب قطعی پیدا نمیشه واسش، همه سواله!



error_reporting(1);
/**
* Get the width and height of the destination image
* from the POST variables and convert them into
* integer values
*/
$w = (int)$_POST['width'];
$h = (int)$_POST['height'];
// create the image with desired width and height
$img = imagecreatetruecolor($w, $h);
$img_new = imagecreatetruecolor($w, $h);
// now fill the image with blank color
// do you remember i wont pass the 0xFFFFFF pixels
// from flash?
imagefill($img, 0, 0, 0xFFFFFF);
$rows = 0;
$cols = 0;
// now process every POST variable which
// contains a pixel color
for($rows = 0; $rows < $h; $rows++){
// convert the string into an array of n elements
$c_row = explode(",", $_POST['px' . $rows]);
for($cols = 0; $cols < $w; $cols++){
// get the single pixel color value
$value = $c_row[$cols];
// if value is not empty (empty values are the blank pixels)
if($value != ""){
// get the hexadecimal string (must be 6 chars length)
// so add the missing chars if needed
$hex = $value;
while(strlen($hex) < 6){
$hex = "0" . $hex;
}
// convert value from HEX to RGB
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
// allocate the new color
// N.B. teorically if a color was already allocated
// we dont need to allocate another time
// but this is only an example
$test = imagecolorallocate($img, $r, $g, $b);
// and paste that color into the image
// at the correct position
imagesetpixel($img, $cols, $rows, $test);
}
}
}

imagecopyresized ( $img_new , $img , 0 , 0 , 0 , 0 , 1000 , 600 , $w , $h );
$time = time();
// print out the correct header to the browser
header("Content-type:image/jpeg");
imagejpeg($img_new, "", 90);
imagejpeg($img_new, "../".$_GET['email']."/".$time.".jpg");

mamali-mohammad
پنج شنبه 15 فروردین 1392, 23:45 عصر
باید از ffmpeg استفاده کنی

hamed.taran71
پنج شنبه 15 فروردین 1392, 23:49 عصر
باید از ffmpeg استفاده کنی
میشه یکم بیشتر توضیح بدین، یا اصلا آموزش بدین؟ چون خیلیا دنبالشن ،مرسی:قلب:
تا اونجایی که من میدونم باید این نرم افزار روی سرور نصب بشه!
نمیشه یه چیز ساده تر در حد کد بالا استفاده کرد؟ آقا من هیچی از این ffmpeg نمیدونم، کسی نیس بیشتر راهنمایی کنه؟:متفکر:

WOLF_MEHRDAD
جمعه 16 فروردین 1392, 01:40 صبح
درود بر شما

به نظر من از ffmpeg-php استفاده کنید



$num = 123;
$movie = new ffmpeg_movie("Movie Path);
$movie->getFrame($num);



[CODE]http://ffmpeg-php.sourceforge.net/[
http://ffmpeg-php.sourceforge.net/doc/api
/CODE]

مانا باشید.

hamed.taran71
جمعه 16 فروردین 1392, 13:01 عصر
درود بر شما

به نظر من از ffmpeg-php استفاده کنید



$num = 123;
$movie = new ffmpeg_movie("Movie Path);
$movie->getFrame($num);



[CODE]http://ffmpeg-php.sourceforge.net/[
http://ffmpeg-php.sourceforge.net/doc/api
/CODE]

مانا باشید.
ممنون از نظرتون، ولی همونطور که گفتم من زیاد باهاش آشنایی ندارم، ffmpeg-php که میگین یه کتابخونست یا مثل ffmpeg یه exe است که باید روی سرور نصب شه؟:متفکر:

mamali-mohammad
شنبه 17 فروردین 1392, 00:21 صبح
بله باید روی سرور نصب بشه
به مدیر هاستتون بگید