Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-12-2007, 06:26 PM   #1
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
Free server side video thumbnail generation script

Hey all, today I'm in a sharing mood so here's a little shell script that
automatically scans a user defined folder recursively for video files
and auto extracts a user defined amount of thumbnails from each file
it finds. Thumbnail size, compression, interval are easy controllable and
instructions and comments are added to the source.

This script is for use on a unix server and saves you having to download
the vids to a workstation in order to generate thumbnails in whatever
software and having to re-upload the thumbs manually back to the server.

The thumbnails uses the following naming scheme for the generated thumbnails
foldername_x.jpg where x is the number of thumbnail that is generated by
the script i.e. if you define to extract 2 thumbs for each file...they will be
named: foldername_1.jpg and foldername_2.jpg so it's very easy to see
which thumbnails comes from which video input file.

The script can process any video format as long as the ffmpeg binary
which is used to extract the frames has the codec installed.

ffmpeg is used to extract the raw frame data from the video file which
is stored without any manipulation as a .PNG file and then the ImageMagick
convert tool does the required image manipulation and conversion to JPEG

ffmpeg can do this too but this way the quality of the jpeg thumbnail is
MUCH better than doing it at once using ffmpeg only.

A BIG THANK YOU to GrouchyAdmin who helped me today adding the folder
and file scanning of the script to complete the script today as I urgently
needed it so my content guy could start using it.......but I wasn't able
to finish it today or even this week due to severe lack of time.

If ANYONE is looking for a reliable coder/sysadmin that delivers his work
in a timely fashion and with the result you asked for then look no further
and contact GrouchyAdmin for your job and save yourself from getting
screwed every possible way you can think off which lately seems to be
the hottest trend. I don't vouch for people to avoid getting hassled by
people asking me why the hell I send them somewhere.....but with
Grouchy I'm comfortable enough and not having to worry about that.
In the unlikely event that I turn out to be wrong feel free to contact me
and if your complaint is valid I'll personally make sure that you'll get what
you ordered.......so Grouchy don't even think of dissapointing me......
I know where you bed sleeps and I'm bigger than you

Ok time for the goodies:

part 1 vidscan.sh

Code:
#!/bin/sh

# Author: Hans Waasdorp [email protected]

# To install save script as vidscan.sh, chmod 755 vidscan.sh

# vidscan.sh
# Purpose: scan folder recursively for video files and extract
# user defined amount of jpg thumbnails of userdefined size and
# jpeg compression level.

# server requirements for script to function:
# ffmpeg + required codecs for media formats
# ImageMagick (convert binary)

# usage: ./vidscan.sh /start/path filename_to_look_for.extension

PATH=/bin:/sbin:/usr/bin:/usr/sbin

SCENE=$2

if [ -d "$1" ]; then
  STARTDIR=$1
else
  STARTDIR=`pwd`
fi

# Call thumb script 5 = number of jpg thumbs to extract from video file

find "$STARTDIR" -name "$SCENE" -exec /bin/sh /root/extract.sh {} 5 \;

# end


Part 2 extract.sh

Code:
#!/bin/bash

# Author: Hans Waasdorp [email protected]
# extract.sh

# To install save script as extract.sh, chmod 755 extract.sh

# server requirements for script to function:
# ffmpeg + required codecs for media formats
# ImageMagick (convert binary)

# edit variables to your requirements, don't run this script manually
# this script is called automatically by vidscan.sh

SECOND=1;
if [ "x"$2 == "x" ]; then
  FIN=$SECOND
else
  FIN=$2
fi

# loop until it has captured the number of captures requested
while [ $SECOND -le $FIN ]; do
/usr/bin/ffmpeg -i "$1" -vcodec png -vframes 1 -ss "$SECOND"  -an -f rawvideo -y "./$SECOND.png"

# quality 0 best compression 100 no compression, resize thumb dimension

if [ -s "$SECOND.png" ]
then
   /usr/bin/convert "$SECOND.png" -quality 80 -resize 160x120 "$SECOND.jpg"
   unlink "$SECOND.png"
else
   unlink "$SECOND.png"
   break
fi

# next part saves thumbnail as foldername_1.jpg where 1 is first thumb extracted.

if [ -f "$SECOND.jpg" ]; then
   IFS="|BEER|"
   CURDIR="$1"
   DIR=`dirname "$CURDIR"`
   BASEDIR=`basename "$DIR"`
   mv "$SECOND.jpg" "$DIR"/"$BASEDIR"_"$SECOND.jpg"
   IFS=" "

# next part changes permissions to 777 and sets ownership to mas and groupname to mas

chmod 777 $DIR/*.jpg
chown mas:mas $DIR/*.jpg

fi

SECOND=$[$SECOND+1];

done
Feel free to comment on it, suggest improvements or telling me it sucks

I might use your comments to improve the script if your comments makes
sense......Flames and thrash comments I'll read for entertainment and will
be ignored.......if you can better do it yourself and post your result.....only
if you it's really better I'll gladly admit and use your result myself......

Request for help and/or assistence post them here or email me. When I
have time I'll be more than happy to assist.......

The script comes without any warranty....the use of it I won't take any
liability for damage to your server and/or data check the code before
running it....if it doesn't make any sense to you either ask before you run
it or hope for the best......if you decide to gamble on it......then accept
the consequences if your gamble turns out that you lose......

It's advisable to first test it in a safe folder with a copy of the files you
test it on.....before even thinking to use it on your live data before being
sure it does exactly what you hope/think/guess it will do........
DON'T COME TO ME TO COMPLAIN WHEN WHEN IT FUCKS UP YOUR SHIT!!!
YOU HAVE BEEN WARNED!!!!!!!

so that's out of the way.....I'll finish by saying that it does exactly what I
said it will do......so if you be careful it's very unlikely anything bad will
happen when using it.........if you have any doubts just ask and I'll explain
if it's safe for you to use........

Time to get some sleep now......behave while I'm gone and see you all
my GFY friends tomorrow........I hope some of you can use this as if you
do it saves can save you a LOT of time......I googled to see if there was
anything like this I could use........either I used the wrong terms to find
it which to be honest really got me suprised.......I expected to find dozens
of scripts that would do something similar like this....but I guess I was wrong
or just too stupid to be able to find them.......

Grouchy thanks again......your quick help is very much appreciated
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2007, 06:35 PM   #2
StarkReality
Confirmed User
 
StarkReality's Avatar
 
Join Date: May 2004
Location: 4 8 15 16 23 42
Posts: 4,444
Thanks for posting, going to test this baby...
StarkReality is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2007, 06:40 PM   #3
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
you're welcome......lol the instructions I wrote for it are 5 times more than the actual code
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2007, 06:58 PM   #4
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
Quote:
Originally Posted by ServerGenius View Post
you're welcome......lol the instructions I wrote for it are 5 times more than the actual code
Now if only you had told me what you were trying to accomplish in, oh, a paragraph.

Glad I could help, Hans!
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2007, 09:50 PM   #5
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
shameless bump
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2007, 09:56 PM   #6
SmokeyTheBear
►SouthOfHeaven
 
SmokeyTheBear's Avatar
 
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
good job sg , do you mind if i repost this on my forum . ( with credit of course )
__________________
hatisblack at yahoo.com
SmokeyTheBear is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2007, 09:58 PM   #7
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
Quote:
Originally Posted by ServerGenius View Post
shameless bump
I thought you were going to sleep, man!
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2007, 10:20 PM   #8
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
Quote:
Originally Posted by SmokeyTheBear View Post
good job sg , do you mind if i repost this on my forum . ( with credit of course )
thanks and of course I don't mind feel free to use it as you like
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2007, 10:21 PM   #9
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
Quote:
Originally Posted by GrouchyAdmin View Post
I thought you were going to sleep, man!
lol I just got home......good night now
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-13-2007, 06:54 AM   #10
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
bump for the day crew
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-13-2007, 02:03 PM   #11
cartelcash_roupen
Confirmed User
 
Join Date: Mar 2007
Posts: 110
great job on the script man, this is a very useful tool!
__________________

Cartel Cash - ICQ: 5489287
Niched Gay Partnership Program - Tons of Promo Materials
cartelcash_roupen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2007, 04:10 PM   #12
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
Hey all, I've made a quick update to the script adding some more controlable
features from the command line.....it's still a work in progress though so more
updates will follow.

Current and Future updates of the script can be found and downloaded at:

http://www.sinnerscash.com/vidscan/index.html

Feel free to grab it free of charge and bookmark URL to fetch future updates
when they're available..........or suggest and request new features you'd like to get added........enjoy!
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 02:48 AM   #13
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
after weekend bump
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 04:43 AM   #14
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,382
Quote:
Originally Posted by ServerGenius View Post
bump for the day crew
Nice script, mines a little more basic

Code:
#!/bin/sh

# make life easier 1.0
# script to convert, split and create thumbs for videos

case "$1" in
thumbs)

## this will grab a screen shot 4 seconds in of a flash video

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

## this will convert all the mpegs in a directory to flash video format

convert)
for i in *.mpg; do ffmpeg -i "$i" "`echo $i |sed 's/.mpg$/.flv/'`" ;done
;;

## this split cuts the video from start to 1 minute in

split)
for i in *.mpg; do ffmpeg -i "$i" -vcodec copy -acodec copy -ss 00:00:00 -t 00:01:00 split-$i; done
;;
*)

echo "Usage: `basename $0` {thumbs|convert|split}" >&2
exit 64
;;
esac

exit 0
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 04:47 AM   #15
who
So Fucking Banned
 
Join Date: Aug 2003
Location: ICQ #23642053
Posts: 19,593
This fucked up my server!!! YOU OWE ME $1000 in lost earnings!!!!!! ICQ me you ratbag!!!
















little joke there...
who is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 04:50 AM   #16
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
Quote:
Originally Posted by Fris View Post
Nice script, mines a little more basic

Code:
#!/bin/sh

# make life easier 1.0
# script to convert, split and create thumbs for videos

case "$1" in
thumbs)

## this will grab a screen shot 4 seconds in of a flash video

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

## this will convert all the mpegs in a directory to flash video format

convert)
for i in *.mpg; do ffmpeg -i "$i" "`echo $i |sed 's/.mpg$/.flv/'`" ;done
;;

## this split cuts the video from start to 1 minute in

split)
for i in *.mpg; do ffmpeg -i "$i" -vcodec copy -acodec copy -ss 00:00:00 -t 00:01:00 split-$i; done
;;
*)

echo "Usage: `basename $0` {thumbs|convert|split}" >&2
exit 64
;;
esac

exit 0
Cool script there....good idea....a split/chop feature
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 06:20 AM   #17
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,229
nice!
I was JUST about to write something that does the same thing in php for a project, but I'll give this a shot instead

Thanks!
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 06:26 AM   #18
a1ka1ine
Confirmed User
 
Industry Role:
Join Date: Apr 2002
Posts: 3,387
damn, a useful business thread wtf
a1ka1ine is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 06:48 AM   #19
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
Quote:
Originally Posted by k0nr4d View Post
nice!
I was JUST about to write something that does the same thing in php for a project, but I'll give this a shot instead

Thanks!
php version is on the todolist
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 07:09 AM   #20
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
Quote:
Originally Posted by a1ka1ine View Post
damn, a useful business thread wtf
sorry
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 08:14 AM   #21
Calvinguy
Confirmed User
 
Join Date: Oct 2002
Location: European Union
Posts: 1,752
Almost all servers come with GD together with php. Any reason why you use Imagemagic?
Calvinguy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 08:25 AM   #22
LiveDose
Show Yer Tits!
 
LiveDose's Avatar
 
Industry Role:
Join Date: Feb 2002
Location: Somewhere Out there...
Posts: 25,792
Interesting. Nice thread, thanks.
__________________

Scammer Alert: acer19 acer [email protected] [email protected] Money stolen using PayPal
LiveDose is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 08:13 PM   #23
ServerGenius
Confirmed User
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 9,377
Quote:
Originally Posted by Calvinguy View Post
Almost all servers come with GD together with php. Any reason why you use Imagemagic?
yes coz the quality is much better with ImageMagick than with gd
__________________
| http://www.sinnerscash.com/ | ICQ: 370820 | Skype: SinnersCash | AdultWhosWho |
ServerGenius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 09:43 PM   #24
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
hmm, what do you need a script for? as long as you have ffmpeg installed you can do it with a single shell command...
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 09:46 PM   #25
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
Quote:
Originally Posted by woj View Post
hmm, what do you need a script for? as long as you have ffmpeg installed you can do it with a single shell command...
If you have VirtualDub, you can hit Ctrl-C; and if you read the thread, you can have the reason for the script's existence.
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-17-2007, 10:25 PM   #26
SmokeyTheBear
►SouthOfHeaven
 
SmokeyTheBear's Avatar
 
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
heres a simple dirty php script to take screenshots from a video and turn them into an animated gif

Code:
<?php
// define individual screenshot path

$t1 = "/home/account/public_html/videos/screenshot-1.jpg";
$t2 = "/home/account/public_html/videos/screenshot-2.jpg";
$t3 = "/home/account/public_html/videos/screenshot-3.jpg";
$t4 = "/home/account/public_html/videos/screenshot-4.jpg";

// define movie path
$targetmovie = "/home/account/public_html/videos/example.mpg"; 

//take screenshots

$fop = exec("/usr/local/bin/ffmpeg -i ".$targetmovie." -an -ss 1 -t 00:01:07 -r 1 -y -s qcif -f mjpeg ".$t1); 
echo $fop;
$fop = exec("/usr/local/bin/ffmpeg -i ".$targetmovie." -an -ss 2 -t 00:02:07 -r 1 -y -s qcif -f mjpeg ".$t2); 
echo $fop;
$fop = exec("/usr/local/bin/ffmpeg -i ".$targetmovie." -an -ss 3 -t 00:03:09 -r 1 -y -s qcif -f mjpeg ".$t3); 
echo $fop;
$fop = exec("/usr/local/bin/ffmpeg -i ".$targetmovie." -an -ss 4 -t 00:04:10 -r 1 -y -s qcif -f mjpeg ".$t4); 
echo $fop;

//make animated gif
$will = exec("/usr/bin/convert -delay 3 -loop 0 /home/account/public_html/videos/screenshot*.gif /home/account/public_html/videos/animated.gif");
echo $will;

?>

<img src=http://yoursite.com/videos/animated.gif>
you will need to modify the server path's according to your server settings..
__________________
hatisblack at yahoo.com
SmokeyTheBear is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-18-2007, 04:33 PM   #27
kektex
Confirmed User
 
Industry Role:
Join Date: Mar 2005
Location: elkektex at gmail
Posts: 1,813
this thread delivers...nice
Thanks for these scripts!
kektex is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-12-2009, 09:58 PM   #28
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Update your ffmpeg skills and post some new tricks.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.