1
내가는 FFmpeg에 대해 물어와 내가 파일을는
을 TXT 할 수는 FFmpeg 및 출력 결과를 함께 간부 기능을 사용
의 ProgressBar 및 코드의 일부를 사용 나는 발견 여기
에<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="es">
<title>AudioXtractor</title>
<body>
<center>
<?php
define('RAPIDLEECH', 'yes');
define('CONFIG_DIR', 'configs/');
require_once('configs/config.php');
define ('TEMPLATE_DIR', 'templates/'.$options['template_used'].'/');
// Include other useful functions
require_once('classes/other.php');
error_reporting(0);
login_check();
include(TEMPLATE_DIR.'header.php');
echo ('<br><br><br><b>AudioXtractor</b>, un complemento <br> que te permite extraer el audio de tus videos.<br><br><br>');
putenv('GDFONTPATH=' . realpath('.')); ?>
<br />
<FORM method="post"><center>
<TABLE>
<td>Movie:
<select name="video">
<?php
$exts=array(".ac3", ".avi", ".f4v", ".flv", ".mkv", ".mov", ".mp4", ".mpg", ".mpeg", ".rmvb", ".srt", ".swf", ".wav", ".wmv");
$ext="";
function vidlist($dir)
{
$results = array();
$handler = opendir($dir);
while ($file = readdir($handler))
{
if (strrchr($file,'.')!="")
{
$ext=strtolower(strrchr($file,'.'));
}
if ($file != '.' && $file != '..' && in_array($ext,$GLOBALS["exts"]))
{
$results[] = $file;
}
}
closedir($handler);
sort($results);
return $results;
}
function Output($command) {
$output = array($command);
exec($command.' 2>&1', $output);
return ($output);
}
$files = vidlist("./files/");
foreach($files as $file)
{
echo '<option value="'.$file.'">'.$file.'</option>';
}
?>
</TABLE>
<br/ >
New MP3's name:
<input type="text" name="nvdo" value="nuevoaudio">
<br/ >
<br />
<br />
<td colspan=2><center><input type=submit style="font-size:16px; font-weight:bold; cursor:pointer;" name="analize" value=Extract /></td>
<tr>
</FORM>
<?php
if ($_POST['video']!="")
$video = 'files/';
$video=array();
$video[0] = $_POST['video'];
if ($_POST['nvdo']!="")
$nvdo = 'files/';
$nvdo=array();
$nvdo[0] = $_POST['nvdo'];
foreach ($video as $vdo)
foreach ($nvdo as $nvd)
if (isset($_POST["analize"])) {
exec("ffmpeg -i files/$vdo -ab 192k files/$nvd.mp3 -y 2> files/$nvd.txt");
$ext=strtolower(strrchr($vdo,'.'));
/////////////////////////////////////////////////////my code //////////////////////////////////////////
$content = @file_get_contents("files/$nvd.txt");
//get duration of source
preg_match("/Duration: (.*?), start:/", $content, $matches);
$rawDuration = $matches[1];
//rawDuration is in 00:00:00.00 format. This converts it to seconds.
$ar = array_reverse(explode(":", $rawDuration));
$duration = floatval($ar[0]);
if (!empty($ar[1])) $duration += intval($ar[1]) * 60;
if (!empty($ar[2])) $duration += intval($ar[2]) * 60 * 60;
//get the time in the file that is already encoded
preg_match_all("/time=(.*?) bitrate/", $content, $matches);
$rawTime = array_pop($matches);
//this is needed if there is more than one match
if (is_array($rawTime)){$rawTime = array_pop($rawTime);}
//rawTime is in 00:00:00.00 format. This converts it to seconds.
$ar = array_reverse(explode(":", $rawTime));
$time = floatval($ar[0]);
if (!empty($ar[1])) $time += intval($ar[1]) * 60;
if (!empty($ar[2])) $time += intval($ar[2]) * 60 * 60;
//calculate the progress
$progress = round(($time/$duration) * 100);
echo '<BR><BR>¡Su video fue convertido correctamente! <BR><BR>Link al archivo:';
echo ' <a href="files/'.$nvd.'.mp3">'.$nvd.'.mp3</a><BR />' . "<br>";
echo "Duration: " . $duration . "<br>";
echo "Current Time: " . $time . "<br>";
echo "Progress: " . $progress . "%" . "<br>";
//////////////////////////////////////my coed //////////////////////////////////////////////
}
?>
<br><br><a href="index.php">Volver al RapidLeech</a>
<br><br><br>Formatos Aceptados: <br><b>.ac3, .avi, .f4v, .flv, .mkv, .mov, .mp3,<br> .mp4, .mpg, .mpeg, .rmvb, .srt, .swf, .wav, .wmv</b>
<br><br>
</center></body></html>
<?php
?>
그래서 나는 그가 나에게 간부 정지 PHP 스크립트에게 몇 가지를 물어 내게
You can't get the progress directly if you are using exec, because the php script is stopped until ffmpeg closes. (Because exec returns the whole execution output)
You should use popen, for being able to get the output from the process in real time (without reading any file) for parse and show the progressbar
Here is a example for get the output:
When you get the progress info from ffmpeg, you can use your code for parse it and show your progressbar
,369을주지 않을
이는 FFmpeg ProgressBar의 좋은 무엇 때문에
<?php
$handle = popen ("ffmpeg.exe -i files/fz.mp4 -ab 192k files/vdf.mp3 2>&1 ", 'r');
$handles = (string)$handle;
$line = "";
while (false !== ($char = fgetc($handle)))
{
if ($char == "\r")
{
// You could now parse the $line for status information.
echo "$line\n";
$line = "";
} else {
$line .= $char;
}
ob_flush();
flush();
}
pclose ($handle);
//get duration of source
preg_match("/Duration: (.*?), start:/", $handles, $matches);
$rawDuration = $matches[1];
//rawDuration is in 00:00:00.00 format. This converts it to seconds.
$ar = array_reverse(explode(":", $rawDuration));
$duration = floatval($ar[0]);
if (!empty($ar[1])) $duration += intval($ar[1]) * 60;
if (!empty($ar[2])) $duration += intval($ar[2]) * 60 * 60;
//get the time in the file that is already encoded
preg_match_all("/time=(.*?) bitrate/", $handles, $matches);
$rawTime = array_pop($matches);
//this is needed if there is more than one match
if (is_array($rawTime)){$rawTime = array_pop($rawTime);}
//rawTime is in 00:00:00.00 format. This converts it to seconds.
$ar = array_reverse(explode(":", $rawTime));
$time = floatval($ar[0]);
if (!empty($ar[1])) $time += intval($ar[1]) * 60;
if (!empty($ar[2])) $time += intval($ar[2]) * 60 * 60;
//calculate the progress
$progress = round(($time/$duration) * 100);
echo '<BR><BR>¡Su video fue convertido correctamente! <BR><BR>Link al archivo:';
echo "Duration: " . $duration . "<br>";
echo "Current Time: " . $time . "<br>";
echo "Progress: " . $progress . "%" . "<br>";
//////////////////////////////////////my coed //////////////////////////////////////////////
?>
난 스탠드에서 그나마 제는 popen 스크립트
이 간부 또는
그렇게 내게주세요는 popen이다는 FFmpeg 실시간에 대한 힌트를 진행 막대
진보 표시 줄에 좋은 점
은 html5 진행률 막대
또는 자바 스크립트 진행 표시 줄
체크 아웃 한 (PHP의는 FFmpeg 변환) : https://github.com/jmalinens/wap4 내가 기억과 관련된 부분을 찾기 위해 노력할 것입니다 나는 당신에게 영감을 줄 것이다 희망 –