mirror of
https://github.com/danog/MadelineProto.git
synced 2024-12-02 10:57:46 +01:00
Improvements
This commit is contained in:
parent
5d30d1cc56
commit
b9513ac4a6
@ -1031,14 +1031,15 @@ trait FilesAbstraction
|
|||||||
$process = Process::start('ffmpeg -i pipe: -f image2pipe -', cancellation: $cancellation);
|
$process = Process::start('ffmpeg -i pipe: -f image2pipe -', cancellation: $cancellation);
|
||||||
$stdin = $process->getStdin();
|
$stdin = $process->getStdin();
|
||||||
$stdout = $process->getStdout();
|
$stdout = $process->getStdout();
|
||||||
$p = new Pipe(1024*1024);
|
|
||||||
$fileFuture = async(fn () => $this->upload(new StreamDuplicator($file, $stdin, $p->getSink()), $fileName ?? '', $callback, cancellation: $cancellation));
|
|
||||||
|
|
||||||
$f = [
|
$f = [
|
||||||
async(buffer(...), $process->getStdout(), $cancellation),
|
async(buffer(...), $process->getStdout(), $cancellation),
|
||||||
async(buffer(...), $process->getStderr(), $cancellation),
|
async(buffer(...), $process->getStderr(), $cancellation),
|
||||||
];
|
];
|
||||||
|
$streams = [$stdin];
|
||||||
|
|
||||||
if ($mimeType === null) {
|
if ($mimeType === null) {
|
||||||
|
$p = new Pipe(1024*1024);
|
||||||
|
$streams []= $p->getSink();
|
||||||
$f []= async(static function () use ($p, $cancellation, &$mimeType): void {
|
$f []= async(static function () use ($p, $cancellation, &$mimeType): void {
|
||||||
$buff = '';
|
$buff = '';
|
||||||
while (\strlen($buff) < 1024*1024 && null !== $chunk = $p->getSource()->read($cancellation)) {
|
while (\strlen($buff) < 1024*1024 && null !== $chunk = $p->getSource()->read($cancellation)) {
|
||||||
@ -1051,6 +1052,8 @@ trait FilesAbstraction
|
|||||||
$mimeType ??= (new finfo())->buffer($buff, FILEINFO_MIME_TYPE);
|
$mimeType ??= (new finfo())->buffer($buff, FILEINFO_MIME_TYPE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fileFuture = async(fn () => $this->upload(new StreamDuplicator($file, ...$streams), $fileName ?? '', $callback, cancellation: $cancellation));
|
||||||
[$stdout, $stderr] = await($f);
|
[$stdout, $stderr] = await($f);
|
||||||
|
|
||||||
$process->join($cancellation);
|
$process->join($cancellation);
|
||||||
@ -1060,7 +1063,7 @@ trait FilesAbstraction
|
|||||||
$minutes = (int) $time[1];
|
$minutes = (int) $time[1];
|
||||||
$seconds = (int) $time[2];
|
$seconds = (int) $time[2];
|
||||||
$duration = $hours * 3600 + $minutes * 60 + $seconds;
|
$duration = $hours * 3600 + $minutes * 60 + $seconds;
|
||||||
$attributes[0]['duration'] = $duration;
|
$attributes[0]['duration'] ??= $duration;
|
||||||
}
|
}
|
||||||
if (preg_match('/TITLE\s*:\s*(.+)/', $stderr, $matches)) {
|
if (preg_match('/TITLE\s*:\s*(.+)/', $stderr, $matches)) {
|
||||||
$attributes[0]['title'] ??= $matches[1];
|
$attributes[0]['title'] ??= $matches[1];
|
||||||
@ -1098,14 +1101,14 @@ trait FilesAbstraction
|
|||||||
$ffmpeg = 'ffmpeg -i pipe: -ss '.$thumbSeek.' -frames:v 1 -f image2pipe -';
|
$ffmpeg = 'ffmpeg -i pipe: -ss '.$thumbSeek.' -frames:v 1 -f image2pipe -';
|
||||||
$process = Process::start($ffmpeg, cancellation: $cancellation);
|
$process = Process::start($ffmpeg, cancellation: $cancellation);
|
||||||
$stdin = $process->getStdin();
|
$stdin = $process->getStdin();
|
||||||
$p = new Pipe(1024*1024);
|
|
||||||
$fileFuture = async(fn () => $this->upload(new StreamDuplicator($file, $stdin, $p->getSink()), $fileName ?? '', $callback, cancellation: $cancellation));
|
|
||||||
|
|
||||||
$f = [
|
$f = [
|
||||||
async(buffer(...), $process->getStdout(), $cancellation),
|
async(buffer(...), $process->getStdout(), $cancellation),
|
||||||
async(buffer(...), $process->getStderr(), $cancellation),
|
async(buffer(...), $process->getStderr(), $cancellation),
|
||||||
];
|
];
|
||||||
|
$streams = [$stdin];
|
||||||
if ($mimeType === null) {
|
if ($mimeType === null) {
|
||||||
|
$p = new Pipe(1024*1024);
|
||||||
|
$streams []= $p->getSink();
|
||||||
$f []= async(static function () use ($p, $cancellation, &$mimeType): void {
|
$f []= async(static function () use ($p, $cancellation, &$mimeType): void {
|
||||||
$buff = '';
|
$buff = '';
|
||||||
while (\strlen($buff) < 1024*1024 && null !== $chunk = $p->getSource()->read($cancellation)) {
|
while (\strlen($buff) < 1024*1024 && null !== $chunk = $p->getSource()->read($cancellation)) {
|
||||||
@ -1118,6 +1121,8 @@ trait FilesAbstraction
|
|||||||
$mimeType ??= (new finfo())->buffer($buff, FILEINFO_MIME_TYPE);
|
$mimeType ??= (new finfo())->buffer($buff, FILEINFO_MIME_TYPE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fileFuture = async(fn () => $this->upload(new StreamDuplicator($file, ...$streams), $fileName ?? '', $callback, cancellation: $cancellation));
|
||||||
[$stdout, $stderr] = await($f);
|
[$stdout, $stderr] = await($f);
|
||||||
|
|
||||||
$thumb ??= new ReadableBuffer($stdout);
|
$thumb ??= new ReadableBuffer($stdout);
|
||||||
|
Loading…
Reference in New Issue
Block a user