Fix: the IO namespace doesn't exist anymore :)

This commit is contained in:
flash 2024-10-23 19:51:01 +00:00
parent 26431aeb79
commit 2c265fa702

View file

@ -4,23 +4,26 @@ namespace Uiharu;
use stdClass; use stdClass;
use Imagick; use Imagick;
use RuntimeException; use RuntimeException;
use Index\IO\Stream;
use Index\IO\ProcessStream;
final class FFMPEG { final class FFMPEG {
public static function grabFirstVideoFrame(string $url): Stream { public static function grabFirstVideoFrame(string $url): string {
return new ProcessStream( try {
sprintf('ffmpeg -i %s -ss 00:00:00.000 -vframes 1 -c:v png -f image2pipe -', escapeshellarg($url)), $file = popen(sprintf('ffmpeg -i %s -f image2pipe -c:v png -frames:v 1 2>/dev/null -', escapeshellarg($url)), 'rb');
'rb' return stream_get_contents($file);
); } finally {
if(isset($file) && is_resource($file))
pclose($file);
}
} }
public static function grabFirstAudioCover(string $url): Stream { public static function grabFirstAudioCover(string $url): string {
return self::grabFirstVideoFrame($url); try {
/*return new ProcessStream( $file = popen(sprintf('ffmpeg -i %s -an -f image2pipe -c:v copy -frames:v 1 2>/dev/null -', escapeshellarg($url)), 'rb');
sprintf('ffmpeg -i %s -an -c:v png -f image2pipe -', escapeshellarg($url)), return stream_get_contents($file);
'rb' } finally {
);*/ if(isset($file) && is_resource($file))
pclose($file);
}
} }
public static function probe(string $url): ?object { public static function probe(string $url): ?object {