Back to Top

FFMPEG video and Image conversion with PHP

Updated 20 October 2012

ffmpeg is the best tool for conversion of videos and image(thumbnail) generation and anyone can use this tool with php very easily .suppose that i want to convert my videos in to .flv format and after the conversion we create images from that .flv video so for that i am writing a script using ffmpeg:

$fileToFlv="/var/www/test/input.wmv";
$fileFlv="/var/www/test/test.flv";
$Flvjpg="/var/www/test/test.jpg";
$videoJPGWidthheight = "120x72";

exec("/usr/bin/ffmpeg -i ".$fileToFlv." -ar 22050 -ab 32 -f 
flv -s 320x256 ".$fileFlv);

exec("/usr/bin/ffmpeg -i ".$fileFlv." -vframes 1 -ss 00:00:06 -s 
120x72 -f image2 ".$Flvjpg);

 

i think that the variable are self explanatory but below im exaplaining each and every convention which i used here plz mail me if u ppl got any problem with ffmpeg

************************************
ar- audio rate
##############

(The “-ar 22050” flag sets an audio sample rate of 22050 Hz. It is usually necessary to set a sample rate when encoding flv files because the MP3 encoder only supports rates of 11025, 22050, and 44100 Hz.) That’s the basic idea, but in practical uses you will probably want to take control over more of the quality settings)

Start your headless eCommerce
now.
Find out More

ab -audio bit rate:
###################
elects an audio bit rate of 32 bits per second use “ffmpeg -h” to check

`-f fmt’
####
Force format.

`-i filename’
##############
input file name

`-ss position’
##############
Seek to given time position in seconds. hh:mm:ss[.xxx] syntax is also supported.

`-vframes number’
#################

Set the number of video frames to record.

`-s size’
############

Set frame size. The format is `wxh’ (ffserver default = 160×128, ffmpeg default = same as source).

like :
—-
`sqcif’
128×96
`qcif’
176×144
`cif’
352×288
`4cif’
704×576
`16cif’
1408×1152
`qqvga’
160×120
`qvga’
320×240
`vga’
640×480
`svga’
800×600

`-ss position’
##############
Seek to given time position in seconds. hh:mm:ss[.xxx] syntax is also supported.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


1 comments

  • Azhar
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home