GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   anyone know their way around with ffmpeg? (https://gfy.com/showthread.php?t=906116)

JamesK 05-19-2009 01:36 PM

anyone know their way around with ffmpeg?
 
I need a php file that automatically grabs a screen cap of the first second of a flv video, using ffmpeg. I want to be able to use it in LongTail Video's flash player.

Anyone know how to do this?

JamesK 05-19-2009 01:59 PM

this bitch dropped fast

polish_aristocrat 05-19-2009 02:09 PM

Quote:

Originally Posted by JamesK (Post 15868452)
this bitch dropped fast

that's because only 3.75% of GFY'ers know what you're talking about

stevo 05-19-2009 02:16 PM

Maybe this php file will work for you:
http://sourceforge.net/project/showf...roup_id=122353

ffmpeg-php is an extension for PHP that adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. It has methods for returning frames from movie files as images that can be manipulated using PHP's image functions. This works well for automatically creating thumbnail images from movies. ffmpeg-php is also useful for reporting the duration and bitrate of audio files (mp3, wma...). ffmpeg-php can access many of the video formats supported by ffmpeg (mov, avi, mpg, wmv...)

HorseShit 05-19-2009 02:25 PM

If you're using LongTail I will have to assume you took my advice

JamesK 05-19-2009 02:28 PM

Quote:

Originally Posted by Justin (Post 15868526)
If you're using LongTail I will have to assume you took my advice

Yep, I knew about the player and used it before but with the AdSolution plugin it really does everything I need it to do :thumbsup

Tube Ace 05-19-2009 02:28 PM

http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html

For extracting images from a video:

ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg

This will extract one video frame per second from the video and will output them in files named `foo-001.jpeg', `foo-002.jpeg', etc. Images will be rescaled to fit the new WxH values.

If you want to extract just a limited number of frames, you can use the above command in combination with the -vframes or -t option, or in combination with -ss to start extracting from a certain point in time.

AdultSoftwareSolutions 05-19-2009 02:32 PM

Google is your friend.

fris 05-19-2009 03:20 PM

prob only like 5 lines of code

Killswitch - BANNED FOR LIFE 05-19-2009 03:29 PM

Quote:

Originally Posted by stevo (Post 15868501)
Maybe this php file will work for you:
http://sourceforge.net/project/showf...roup_id=122353

ffmpeg-php is an extension for PHP that adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. It has methods for returning frames from movie files as images that can be manipulated using PHP's image functions. This works well for automatically creating thumbnail images from movies. ffmpeg-php is also useful for reporting the duration and bitrate of audio files (mp3, wma...). ffmpeg-php can access many of the video formats supported by ffmpeg (mov, avi, mpg, wmv...)

:thumbsup:thumbsup:thumbsup

SmokeyTheBear 05-19-2009 03:41 PM

<?php
echo exec("/usr/local/bin/ffmpeg -i /home/account/public_html/video/video.flv -an -ss 1 -t 00:00:01 -r 1 -y -s qcif -f mjpeg /home/account/public_html/snapshot/snapshot.jpg");
?>

Chris 05-19-2009 03:41 PM

i thought this was about the mac program ffmpegX that i use to convert my avi's to mov for my apple tv ;x

SmokeyTheBear 05-19-2009 03:49 PM

Quote:

Originally Posted by SmokeyTheBear (Post 15868710)
<?php
echo exec("/usr/local/bin/ffmpeg -i /home/account/public_html/video/video.flv -an -ss 1 -t 00:00:01 -r 1 -y -s qcif -f mjpeg /home/account/public_html/snapshot/snapshot.jpg");
?>

if you want to do every flv in a directory at once try this
<?php
foreach (glob("*.flv") as $filename) {
echo exec("/usr/local/bin/ffmpeg -i /home/account/public_html/video/$filename -an -ss 1 -t 00:00:01 -r 1 -y -s qcif -f mjpeg /home/account/public_html/snapshot/$filename.jpg");

}

?>

drop the php file in the folder with the flv's

p.s. change the paths to your paths of course

SmokeyTheBear 05-19-2009 03:51 PM

Quote:

Originally Posted by Chris (Post 15868711)
i thought this was about the mac program ffmpegX that i use to convert my avi's to mov for my apple tv ;x

ffmpegx includes ffmpeg so yes

fris 05-19-2009 03:52 PM

Quote:

Originally Posted by JamesK (Post 15868353)
I need a php file that automatically grabs a screen cap of the first second of a flv video, using ffmpeg. I want to be able to use it in LongTail Video's flash player.

Anyone know how to do this?

this is really rough, prob could be done better but.

Code:

<?
$video = $_GET['f'];
$movie = new ffmpeg_movie($video, false);
$frames = $movie->getFrameCount();
$frame = $movie->getFrame(50);
$im = $frame->toGDImage();
imagejpeg($im,"$video.jpg");
imagedestroy($im);
header("Content-type:image/jpeg");
readfile("$video.jpg");
?>

then call it via a flashvar

Code:

so.addVariable("image", "imgflv.php?f=video.flv");
you get the idea.

fris 05-19-2009 03:59 PM

Quote:

Originally Posted by SmokeyTheBear (Post 15868730)
if you want to do every flv in a directory at once try this
<?php
foreach (glob("*.flv") as $filename) {
echo exec("/usr/local/bin/ffmpeg -i /home/account/public_html/video/$filename -an -ss 1 -t 00:00:01 -r 1 -y -s qcif -f mjpeg /home/account/public_html/snapshot/$filename.jpg");

}

?>

drop the php file in the folder with the flv's

p.s. change the paths to your paths of course

he wants it to do it via the flash player, that will do a directory.

plus you could do it easier via a shell script

Code:

for i in *.flv; do ffmpeg -an -y -t 00:00:01 -i "$i" -f image2 "`echo $i |sed 's/.flv$/.jpg/'`" ;done

Chris 05-19-2009 04:02 PM

this thread gave me a headache but i keep staring at fris' avatar


mmmmmmm

Killswitch - BANNED FOR LIFE 05-19-2009 04:35 PM

Quote:

Originally Posted by fris (Post 15868741)
this is really rough, prob could be done better but.

Code:

<?
$movie = new ffmpeg_movie($_GET['f'], false);
$frame = $movie->getFrame(50);
$im = $frame->toGDImage();
header('Content-type:image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>

then call it via a flashvar

Code:

so.addVariable("image", "imgflv.php?f=video.flv");
you get the idea.

I cleaned it up for you. :thumbsup

JamesK 05-20-2009 01:22 AM

Wow, thanks a lot guys! Didn't expect so much input.

I'll test it out asap and let you know if it worked and share the whole solution.

JamesK 05-20-2009 02:57 AM

Ok sweet it works like a charm! Here's a recap of the whole situation & solution for those with the same problem:

Since LongTail's FLV player does not automaticallly create a preview on the actual video page I had two choices, either enable autoplay so no preview is required, or use a little ffmpeg php script to make a screen cap of the video. The second seemed like a better option to save a lot of bandwidth (it's still user friendly since he only has to click a big ass play button to start the video).

I installed FFMPEG and FFMPEG-PHP (not sure if I needed both but whatever they're both on my server here now. Here are the tutorials for Linux:

FFMPEG tutorial: http://www.mysql-apache-php.com/ffmpeg-install.htm
FFMPEG-PHP tutorial: http://ffmpeg-php.sourceforge.net/

I made a PHP file (thanks Fris & Killswitch) called imgpreview.php and added this code to it.

Code:

<?
$movie = new ffmpeg_movie($_GET['f'], false);
$frame = $movie->getFrame(50);
$im = $frame->toGDImage();
header('Content-type:image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>

And added image=imgpreview.php?f=videofile.flv to the flashvars. If you're using TubeAce like me, you should replace videofile.flv to {video_file} and you're set!

Thanks again guys.

wizzart 05-20-2009 06:35 AM

Anytime ;)

wizzart 05-20-2009 06:35 AM

LoL LoL

nation-x 05-20-2009 06:55 AM

Code:

function grabScreen($clip, $thumb, $dimensions) {
    //$dimensions should be in WxH format
    //$thumb should contain the full path to the image you want created
    $screengrab = "/usr/local/bin/ffmpeg -y -i '{$clip}' -f mjpeg -ss 10 -vframes 1 -s {$dimensions} -an '{$thumb}'";
    @system($screengrab);
}


CaptainHowdy 05-20-2009 07:04 AM

Smokey hitted it...

fris 05-20-2009 07:37 AM

Quote:

Originally Posted by nation-x (Post 15870594)
Code:

function grabScreen($clip, $thumb, $dimensions) {
    //$dimensions should be in WxH format
    //$thumb should contain the full path to the image you want created
    $screengrab = "/usr/local/bin/ffmpeg -y -i '{$clip}' -f mjpeg -ss 10 -vframes 1 -s {$dimensions} -an '{$thumb}'";
    @system($screengrab);
}


whats the difference between using ffmpeg executable and the php module?

Killswitch - BANNED FOR LIFE 05-20-2009 08:08 AM

Quote:

Originally Posted by JamesK (Post 15869970)
Ok sweet it works like a charm! Here's a recap of the whole situation & solution for those with the same problem:

Since LongTail's FLV player does not automaticallly create a preview on the actual video page I had two choices, either enable autoplay so no preview is required, or use a little ffmpeg php script to make a screen cap of the video. The second seemed like a better option to save a lot of bandwidth (it's still user friendly since he only has to click a big ass play button to start the video).

I installed FFMPEG and FFMPEG-PHP (not sure if I needed both but whatever they're both on my server here now. Here are the tutorials for Linux:

FFMPEG tutorial: http://www.mysql-apache-php.com/ffmpeg-install.htm
FFMPEG-PHP tutorial: http://ffmpeg-php.sourceforge.net/

I made a PHP file (thanks Fris & Killswitch) called imgpreview.php and added this code to it.

Code:

<?
$movie = new ffmpeg_movie($_GET['f'], false);
$frame = $movie->getFrame(50);
$im = $frame->toGDImage();
header('Content-type:image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>

And added image=imgpreview.php?f=videofile.flv to the flashvars. If you're using TubeAce like me, you should replace videofile.flv to {video_file} and you're set!

Thanks again guys.

If you wanna make it more random, say just a random frame from the video, you can do this...

Code:

<?
$movie = new ffmpeg_movie($_GET['f'], false);
$frame = $movie->getFrame(rand(1, getFrameCount());
$im = $frame->toGDImage();
header('Content-type:image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>

:thumbsup

SmokeyTheBear 05-20-2009 08:34 AM

guess i misunderstood the question, sorry i attempted to help you. i'll just keep me trap shut next time :winkwink:

JamesK 05-21-2009 10:30 AM

Quote:

Originally Posted by Killswitch (Post 15870921)
If you wanna make it more random, say just a random frame from the video, you can do this...

Code:

<?
$movie = new ffmpeg_movie($_GET['f'], false);
$frame = $movie->getFrame(rand(1, getFrameCount());
$im = $frame->toGDImage();
header('Content-type:image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>

:thumbsup

Thanks bud, that'll come in handy :thumbsup

Quote:

Originally Posted by SmokeyTheBear (Post 15871019)
i'll just keep me trap shut next time :winkwink:

Please don't, I love you too :winkwink:


All times are GMT -7. The time now is 02:31 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123