Я написал всю систему на PHP и bash на сервере, чтобы конвертировать и передавать видео в HTML5 на моем VPS. Преобразование выполняется с помощью ffmpeg в фоновом режиме, и содержимое выводится на block.txt.
Посмотрев следующие сообщения:
Может ли ffmpeg показать индикатор выполнения?
и
индикатор прогресса ffmpeg для кодирования видео
среди других, я не могу найти рабочий пример.
Мне нужно захватить текущий кодированный прогресс в процентах.
Первое сообщение, которое я связал выше, дает:
$log = @file_get_contents('block.txt');
preg_match("/Duration:([^,]+)/", $log, $matches);
list($hours,$minutes,$seconds,$mili) = split(":",$matches[1]);
$seconds = (($hours * 3600) + ($minutes * 60) + $seconds);
$seconds = round($seconds);
$page = join("",file("$txt"));
$kw = explode("time=", $page);
$last = array_pop($kw);
$values = explode(' ', $last);
$curTime = round($values[0]);
$percent_extracted = round((($curTime * 100)/($seconds)));
echo $percent_extracted;
Переменная $percent_extracted echoes zero, и поскольку математика не моя сильная сторона, я действительно не знаю, как продвигаться здесь.
Здесь одна строка из файла ffmpeg из файла block.txt(если это полезно)
время = 00: 19: 25,16 бит бит = 823,0 Кбит/с кадр = 27963 fps = 7 q = 0.0 размер = 117085kB time = 00: 19: 25,33 bitrate = 823.1kbits/s frame = 27967 fps = 7 q = 0.0 size = 117085kB time = 00: 19: 25.49 bitrate = 823.0kbits/s frame = 27971 fps = 7 q = 0.0 size = 117126kB
Пожалуйста, помогите мне вывести этот процент, как только закончите, я могу создать свой собственный индикатор выполнения. Спасибо.