hi
i've got a function to convert media-files. the funny thing about it is that it converts the files but doesn't recognize it did. the system- and exec-calls return 0. i execute it in the shell with php phpfile.php and the output of ffmpeg is correct and doesn't show any errors. the line "print_r($tmp)" returns "0"! why??? i just dont get it :-(
i'm using php 4.3.x, centos 4 linux
$docRoot = '/var/www/html/typo3/';
if(!$_GET['rebuild']) {
require_once 'config.php';
require_once 'functions.php';
$db2 = new db();
$db2->connect();
function convertFile($id, $type, $org) {
global $uploadPath, $size;
$audioRate = 32; //kbps
$audioFreq = 11025; //Hz
$fps = 15; //12fps
$kbps = 200; //kbps
$ffmpeg = '-y -s '.$size['video']['w'].'x'.$size['video']['h'].' -r '.$fps.' -b '.$kbps.' -ab '.$audioRate.' -ar '.$audioFreq; //-acodec mp3 -maxrate '.$videoRate.' speedUp motionEstimation -me zero
$ffmpegThumb = '-an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 70x50';
$ffmpegAudio = '-y -acodec mp3 -ab '.$audioRate.' -ar '.$audioFreq;
$magickThumb = '-sample 70x50 -format jpg -quality 30';
$magickImg = '-format jpg -quality 99';
$magickImg = '-resize '.$size['image']['w'].'x'.$size['image']['h'].' -format jpg -quality 91';
if($type == 'image') {
system('convert "'.escapeshellcmd($uploadPath['orgImage'].$org).'" '.$magickThumb.' '.$uploadPath['image'].$uploadPath['thumb'].$id.'.jpg', $tmpThumb);
system('convert "'.escapeshellcmd($uploadPath['orgImage'].$org).'" '.$magickBig.' '.$uploadPath['image'].$uploadPath['big'].$id.'.jpg', $tmpBig);
system('convert "'.escapeshellcmd($uploadPath['orgImage'].$org).'" '.$magickImg.' '.$uploadPath['image'].$id.'.jpg', $tmp);
} elseif($type == 'audio') {
$ffmpegAudio = 'ffmpeg -i "'.escapeshellcmd($uploadPath['orgAudio'].$org).'" '.$ffmpegAudio.' '.$uploadPath['audio'].$id.'.flv';
exec($ffmpegAudio, $tmp);
// $metaData = 'cat '.$uploadPath['audio'].$id.'.flv | flvtool2 -U stdin '.$uploadPath['audio'].$id.'.flv';
// system($metaData, $tmpMeta);
} else {
$ffmpegThumb = escapeshellcmd('ffmpeg -i "'.$uploadPath['orgVideo'].$org.'" '.$ffmpegThumb.' '.$uploadPath['video'].$uploadPath['thumb'].$id.'%d.jpg');
system($ffmpegThumb, $tmpThumb);
system('mv '.$uploadPath['video'].$uploadPath['thumb'].$id.'1.jpg '.$uploadPath['video'].$uploadPath['thumb'].$id.'.jpg');
$ffmpeg = escapeshellcmd('ffmpeg -i "'.$uploadPath['orgVideo'].$org.'" '.$ffmpeg.' '.$uploadPath['video'].$id.'.flv');
system($ffmpeg, $tmp);
$metaData = 'cat '.$uploadPath['video'].$id.'.flv | flvtool2 -U stdin '.$uploadPath['video'].$id.'.flv';
system($metaData, $tmpMeta);
}
echo "\n\n";
print_r($tmp);
echo "\n\n";
return $tmp;
}
//convert new news
$query = 'select '.$GLOBALS['tbl']['media'].'.*,tries,tx_myextfeusers_systemlanguage as idLang,header,txt,email,'.$GLOBALS['tbl']['news'].'.idNews from '.$GLOBALS['tbl']['cron'].' left join '.$GLOBALS['tbl']['news'].' using (idNews) left join '.$GLOBALS['tbl']['media'].' using (idNews) left join '.$GLOBALS['tbl']['user'].' on '.$GLOBALS['tbl']['user'].'.uid='.$GLOBALS['tbl']['news'].'.uid'; //todo take out limit
$db->q($query);
while($db->nr()) {
//mail to uploader and delete in pending
if($db->r['tries'] == 1) {
//mail author
$html = str_replace('#name#', $db->r['name'], str_replace('#header#', $db->r['header'], write('mailNoConvertTxt', $db->r['idLang']))).$db->r['txt'];
sendMail($html, $db->r['email'], write('mailNoConvertSubj', $db->r['idLang']));
//delete entry in pending
$db2->q('delete from '.$GLOBALS['tbl']['cron'].' where idNews='.$db->r['idNews']);
} else {
$success = convertFile($db->r['idMedia'], $db->r['typ'], $db->r['datum'].'-'.$db->r['name']);
//echo $db->r['name'].': '.$success.'<br>';
if($success) {
//mark as next news
$db2->q('update '.$GLOBALS['tbl']['news'].' set typ=0 where idNews='.$db->r['idNews']);
//delete pending entry
$db2->q('delete from '.$GLOBALS['tbl']['cron'].' where idNews='.$db->r['idNews']);
//get categories from news that is affecting next-counter
$db2->q('select idCategory from '.$GLOBALS['tbl']['newsCats'].' where idNews='.$db->r['idNews']);
unset($tmp);
while($db2->nr()) {
$tmp .= ' || '.$_SESSION['catIndex'][$db2->r[0]]['up'];
}
//update next-counter
$db2->q('update '.$GLOBALS['tbl']['counter'].' set cNext=cNext+1 where idLang='.$db->r['idLang'].' && ('.substr($tmp,3).')');
} else
//increment pending entry
$db2->q('update '.$GLOBALS['tbl']['cron'].' set tries=1 where idNews='.$db->r['idNews']);
}
}