Мне нужен прогресс команды FFmpeg, например, сколько времени осталось или сколько процентов выполнено.
this ffmpeg Progress Bar - Процент кодирования в PHP выполняет работу по работе с аудио и видео, но в моем случае не удалось создать видео из изображений.
аналогично вопрос Может ли ffmpeg отображать индикатор выполнения? в моем случае команда следующая
exec("$FFmpegPath -protocol_whitelist file,http,https,tcp,tls,crypto -f concat -safe 0 -i '$image_txt_file' -vsync vfr -pix_fmt yuv420p -vf 'pad=ceil(iw/2)*2:ceil(ih/2)*2' '$out_vid_name' 1>'output.txt' 2>&1", $output, $return_var);
, а в моем выходном файле это то, что у меня есть
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.16)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include/darwin -fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, concat, from '../LiveLapseData/image_file_5eb13b6cb0bb6.txt':
Duration: 00:00:02.50, start: 0.000000, bitrate: 33 kb/s
Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 2697x1800 [SAR 1:1 DAR 899:600], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler @ 0x10c679000] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x7f9def030200] using SAR=1/1
[libx264 @ 0x7f9def030200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f9def030200] profile High, level 5.0
[libx264 @ 0x7f9def030200] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '../LiveLapseData/init_video_5eb13b6cb0bc2.mp4':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 2698x1800 [SAR 1:1 DAR 1349:900], q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 3 fps=0.2 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 4 fps=0.1 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 5 fps=0.1 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 6 fps=0.1 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 7 fps=0.1 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 8 fps=0.1 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 9 fps=0.1 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 10 fps=0.1 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 11 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 12 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 13 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 14 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
<?php
// The file has JSON type.
header('Content-Type: application/json');
$content = @file_get_contents('output.txt');
if ($content) {
//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 "Duration: " . $duration . "<br>";
echo "Current Time: " . $time . "<br>";
echo "Progress: " . $progress . "%";
и я всегда получаю это прогресс 0 и последний прогресс 88