Code: Select all
-subfont-text-scale 3.3
Code: Select all
-subfont-text-scale 3.3
Code: Select all
<?php
$dir = './'; // set to current folder
if ($handle = opendir($dir)) {
while(false!== ($file = readdir($handle))) {
if ( is_file($dir.$file) ){
if (preg_match("'\.(avi)$'", $file) ){
$sub_file = str_ireplace(".avi", ".srt", $dir.$file);
$idx_file = str_ireplace(".avi", ".idx", $dir.$file);
$thumb_file = str_ireplace(".avi", ".jpg", $dir.$file);
$out_file = str_ireplace(".avi", ".mp4", $dir.$file);
flv_convert_get_thumb($dir.$file, $sub_file, $idx_file, $thumb_file, $out_file);
}
else{
continue;
}
}
}
closedir($handle);
}
//flv_convert_get_thumb('input.avi', 'input.srt', 'output.jpg', 'output.ogm');
// code provided and updated by steve of phpsnaps ! thanks
// accepts:
// 1: the input video file
// 2: path to thumb jpg
// 3: path to transcoded mpeg?
function flv_convert_get_thumb($in, $in_sub, $in_idx, $out_thumb, $out_vid){
// get thumbnail
$cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 250 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 '.$out_thumb;
$res = shell_exec($cmd);
// $res is the output of the command
// transcode video
$cmd = 'mencoder '.$in.' -o '.$out_vid.' -sub '.$in_sub.' -subfont-text-scale 3.0 -subpos 99 -idx '.$in_idx.' -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encopts bitrate=500:level_idc=41:bframes=3:frameref=2: nopsnr: nossim: pass=1: threads=auto -oac mp3lame';
$res = shell_exec($cmd);
}
?>
Code: Select all
<?php
$dir = './'; // set to current folder
if ($handle = opendir($dir)) {
while(false!== ($file = readdir($handle))) {
if ( is_file($dir.$file) ){
if (preg_match("'\.(avi)$'", $file) ){
$sub_file = str_ireplace(".avi", ".srt", $dir.$file);
$idx_file = str_ireplace(".avi", ".idx", $dir.$file);
$thumb_file = str_ireplace(".avi", ".jpg", $dir.$file);
$out_file = str_ireplace(".avi", ".mp4", $dir.$file);
flv_convert_get_thumb($dir.$file, $sub_file, $idx_file, $thumb_file, $out_file);
}
else{
continue;
}
}
}
closedir($handle);
}
//flv_convert_get_thumb('input.avi', 'input.srt', 'output.jpg', 'output.ogm');
// code provided and updated by steve of phpsnaps ! thanks
// accepts:
// 1: the input video file
// 2: path to thumb jpg
// 3: path to transcoded mpeg?
function flv_convert_get_thumb($in, $in_sub, $in_idx, $out_thumb, $out_vid){
// get thumbnail
$cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 250 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 '.$out_thumb;
$res = shell_exec($cmd);
// $res is the output of the command
// transcode video
$cmd = 'mencoder '.$in.' -o '.$out_vid.' -sub '.$in_sub.' -subfont-text-scale 3.0 -subpos 99 -idx '.$in_idx.' -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encopts bitrate=500:level_idc=41:bframes=3:frameref=2: nopsnr: nossim: pass=1: threads=auto -oac mp3lame';
$res = shell_exec($cmd);
}
}
// is there way to wait until encoding completes ? so this code starts ?
chdir('$in.avi');
$do = unlink($fileToDel);
if($do=="1"){
echo "The file was encoded successfully. <br> removing original file";
} else { echo "There was an error trying to delete the file."; }
?>
Code: Select all
<?php
$dir = './'; // set to current folder
if ($handle = opendir($dir)) {
while(false!== ($file = readdir($handle))) {
if ( is_file($dir.$file) ){
if (preg_match("'\.(avi)$'", $file) ){
$sub_file = str_ireplace(".avi", ".srt", $dir.$file);
$idx_file = str_ireplace(".avi", ".idx", $dir.$file);
$thumb_file = str_ireplace(".avi", ".jpg", $dir.$file);
$out_file = str_ireplace(".avi", ".mp4", $dir.$file);
flv_convert_get_thumb($dir.$file, $sub_file, $idx_file, $thumb_file, $out_file);
}
else{
continue;
}
}
}
closedir($handle);
}
sleep(5); // wait for few seconds until the mencoder.exe releases the final encoded file
if ($handle = opendir($dir)) {
while(false!== ($file = readdir($handle))) {
if ( is_file($dir.$file) ){
if (preg_match("'\.(avi)$'", $file) ){
$sub_file = str_ireplace(".avi", ".srt", $dir.$file);
$idx_file = str_ireplace(".avi", ".idx", $dir.$file);
deleteFileWithRetry($file);
deleteFileWithRetry($sub_file);
deleteFileWithRetry($idx_file);
}
else{
continue;
}
}
}
closedir($handle);
}
function deleteFileWithRetry($file){
$ret = 0;
$retry = 5; // we retry to delete a file 5 times
while ($ret == 0 && $retry){
$ret = unlink($file);
if ($ret == 0){
sleep(5); // failed to delete -> wait 5 seconds
}
$retry--;
}
if($ret == 1){
echo "The file ". $file . " was encoded successfully. <br> removing original file";
}
else {
echo "There was an error trying to delete the file " . $file;
}
return ret;
}
//flv_convert_get_thumb('input.avi', 'input.srt', 'output.jpg', 'output.ogm');
// code provided and updated by steve of phpsnaps ! thanks
// accepts:
// 1: the input video file
// 2: path to thumb jpg
// 3: path to transcoded mpeg?
function flv_convert_get_thumb($in, $in_sub, $in_idx, $out_thumb, $out_vid){
// get thumbnail
$cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 250 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 '.$out_thumb;
$res = shell_exec($cmd);
// $res is the output of the command
// transcode video
$cmd = 'mencoder '.$in.' -o '.$out_vid.' -sub '.$in_sub.' -subfont-text-scale 3.0 -subpos 99 -idx '.$in_idx.' -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encopts bitrate=500:level_idc=41:bframes=3:frameref=2: nopsnr: nossim: pass=1: threads=auto -oac mp3lame';
$res = shell_exec($cmd);
}
?>
Code: Select all
$cmd = 'mencoder '.$in.' -o './dataStorageflv/.$out_vid.' -sub '.$in_sub.
Code: Select all
$cmd = 'mencoder '.$in.' -o '/var/www/dataStorageflv/.$out_vid.' -sub '.$in_sub.
Code: Select all
$cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 250 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 '/var/www/dataStoragethumbs/.$out_thumb;
but even that not work my testing server is ubuntu 8.04var/www/dataStoragethumbs/$out_thumb
Code: Select all
$cmd = 'mencoder '.$in.' -o /dataStorageflv/' . $out_vid . ' -sub '.$in_sub.
$cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 250 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 /var/www/dataStoragethumbs/' . $out_thumb;
Code: Select all
/var/www/dataStorageflv/'.$out_vid.'
Code: Select all
ffmpeg -i '.$in.' -f mp4 -vcodec -newsubtitle '.$in_sub.' mpeg4 -r 25 -b 560000 -s 610x340 -acodec aac -ac 2 -ab 64 -ar 44100 '.$out_vid.' | flvtool2 -U '.$out_vid.' '.$in.'
Code: Select all
3.7 Subtitle options:
`-scodec codec'
Force subtitle codec ('copy' to copy stream).
`-newsubtitle'
Add a new subtitle stream to the current output stream.
`-slang code'
Set the ISO 639 language code (3 letters) of the current subtitle stream.
`-sn'
Disable subtitle recording.
`-sbsf bitstream_filter'
Bitstream filters available are "mov2textsub", "text2movsub".
ffmpeg -i file.mov -an -vn -sbsf mov2textsub -scodec copy -f rawvideo sub.txt
Code: Select all
$cmd = 'mencoder '.$in.' -o '.$out_vid.' -sub '.$in_sub. -subfont-text-scale 3.0 -subpos 99 -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encop$