C'est sur ma Ubuntu Feisty Studio que j'ai fait les conversions wmv--> flv.
Installation des Win32 Codecs sous Ubuntu Studio
Il me manquait les win32codecs. Pour les installer, il suffit de suivre les directives de
http://doc.ubuntu-fr.org/w32codecs. Ce qui donne donc pour l'installation:
cd
wget http://www1.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
mkdir /usr/lib/win32
tar xvjf essential-20061022.tar.bz2
cp essential-20061022/* /usr/lib/win32/
Encodage en flv
Pour encoder des fichiers flv:
for i in *.wmv;
do video=$(basename ${i} .wmv);
mencoder $i -forceidx -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -of lavf \
-oac mp3lame -lameopts abr:br=56 -srate 22050 -ovc lavc -lavcopts \
vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=320:240 -o flv/${video}.flv; \
done
La ligne
video=$(basename ${i} .wmv);
est super pratique car elle permet de récupérer le nom d'un fichier sans le suffixe de l'extension. Au moins maintenant j'ai le son avec la vidéo
Le lecteur Flash flv-player
Les lecteurs Fash ne manquent pas sur internet. Un que j'ai de suite adopté c'est flv-player dont le site est
http://flv-player.net/players/maxi/generator/ qui est très bien car il fourni un générateur de code qu'il suffti ensuite de copier dans son blog
Générerdes imagettes du film
Il faut avoir php compilé avec l'extension ffmpeg-php. Le script suivant que l'on invoque en ligne de commande par
php -q test_ffmepg.php
est disponible dans les sources de ffmpeg-php
Je l'ai un peu arrangé à  ma sauce histoire d'avoir 12 images en sortie. SOn contenu est le suivant
<?
/*
* This test script is not part of the automatic regression tests. It serves
* as a simple manual test script and an example of the syntax for calling
* the ffmpeg-php functions
*
* To run it from the command line type 'php -q ffmpeg_test.php 'or from a
* browser * copy this file into your web root and point your browser at it.
*/
$extension = "php_ffmpeg";
$extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
$extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
// load extension
//if (!extension_loaded($extension)) {
// dl($extension_soname) or die("Can't load extension $extension_fullname\n");
//}
if ( extension_loaded('ffmpeg') != 1)
{
switch (PHP_OS)
{
case "WINNT": $php_suffix = ".dll";
break;
default: $php_suffix = ".so";
break;
}
dl("ffmpeg.".PHP_SHLIB_SUFFIX);
}
if (php_sapi_name() != 'cgi') {
echo '<pre>';
}
printf("ffmpeg-php version string: %s\n", FFMPEG_PHP_VERSION_STRING);
printf("libavcodec build number: %d\n", LIBAVCODEC_BUILD_NUMBER);
printf("libavcodec version number: %d\n", LIBAVCODEC_VERSION_NUMBER);
printf("libavcodec build number: %d\n", LIBAVCODEC_BUILD_NUMBER);
print_class_methods("ffmpeg_movie");
print_class_methods("ffmpeg_frame");
print_class_methods("ffmpeg_animated_gif");
// get an array for movies from the test media directory
$movies = getDirFiles('/var/www/videos/jana/videos');//dirname(__FILE__) . '/tests/test_media');
echo "--------------------\n\n";
foreach($movies as $movie) {
$mov = new ffmpeg_movie($movie);
printf("file name = %s\n", $mov->getFileName());
printf("duration = %s seconds\n", $mov->getDuration());
printf("frame count = %s\n", $mov->getFrameCount());
printf("frame rate = %0.3f fps\n", $mov->getFrameRate());
printf("comment = %s\n", $mov->getComment());
printf("title = %s\n", $mov->getTitle());
printf("author = %s\n", $mov->getAuthor());
printf("copyright = %s\n", $mov->getCopyright());
printf("get bit rate = %d\n", $mov->getBitRate());
printf("has audio = %s\n", $mov->hasAudio() == 0 ? 'No' : 'Yes');
if ($mov->hasAudio()) {
printf("get audio codec = %s\n", $mov->getAudioCodec());
printf("get audio bit rate = %d\n", $mov->getAudioBitRate());
printf("get audio sample rate = %d \n", $mov->getAudioSampleRate());
printf("get audio channels = %s\n", $mov->getAudioChannels());
}
printf("has video = %s\n", $mov->hasVideo() == 0 ? 'No' : 'Yes');
if ($mov->hasVideo()) {
printf("frame height = %d pixels\n", $mov->getFrameHeight());
printf("frame width = %d pixels\n", $mov->getFrameWidth());
printf("get video codec = %s\n", $mov->getVideoCodec());
printf("get video bit rate = %d\n", $mov->getVideoBitRate());
printf("get pixel format = %s\n", $mov->getPixelFormat());
printf("get pixel aspect ratio = %s\n", $mov->getPixelAspectRatio());
printf("get frame = %s\n", is_object($mov->getFrame(10)) ? 'true' : 'false');
printf("get frame number = %d\n", $mov->getFrameNumber());
}
$duration =intval( $mov->getFrameCount()/12.0);
for($IterFrame=1;$IterFrame<13;$IterFrame++){
$frame = $duration * $IterFrame;
$filename = $mov->getFileName();
$imgfilename = dirname($filename)."/../images_max/".str_replace(".flv","_".$IterFrame."_.png",basename($filename));
$ff_frame = $mov->getFrame($frame);
if ($ff_frame) {
$gd_image = $ff_frame->toGDImage();
if ($gd_image) {
$imgtmp = $imgfilename."tmp";
printf("Génération de l'image = %s...", $imgfilename);
imagepng($gd_image,$imgtmp);
resize_png($imgtmp, $imgfilename,184,144);
imagedestroy($gd_image);
printf("...[OK]\n");
unlink($imgtmp);
}
}
}
echo "\n--------------------\n\n";
}
if (php_sapi_name() != 'cgi') {
echo '</pre>';
}
/* FUNCTIONS */
function print_class_methods($class) {
echo "\nMethods available in class '$class':\n";
$methods = get_class_methods($class);
if (is_array($methods)) {
foreach($methods as $method) {
echo $method . "\n";
}
} else {
echo "No Methods Defined\n";
}
}
function getDirFiles($dirPath)
{
if ($handle = opendir($dirPath))
{
while (false !== ($file = readdir($handle))) {
$fullpath = $dirPath . '/' . $file;
if (!is_dir($fullpath) && $file != "CVS" && $file != "." && $file != "..")
$filesArr[] = trim($fullpath);
}
closedir($handle);
}
return $filesArr;
}
function resize_png($src,$dst,$dstw,$dsth) {
list($width, $height, $type, $attr) = getimagesize($src);
$im = imagecreatefrompng($src);
$tim = imagecreatetruecolor($dstw,$dsth);
imagecopyresampled($tim,$im,0,0,0,0,$dstw,$dsth,$width,$height);
// $tim = ImageTrueColorToPalette2($tim,false,255);
imagepng($tim,$dst);
}
?>