use ffmpeg

This commit is contained in:
2023-02-05 12:41:50 +10:00
parent 09751208a1
commit 145b5559ef

View File

@@ -45,6 +45,20 @@ class OCRController extends ApiController
file_put_contents($tmpfname, $curlResult);
$ffmpeg = FFMpeg\FFMpeg::create();
$inputFile = $ffmpeg->open('input.mp4');
if ($inputFile !== null) {
$videoFrames = $inputFile->frames();
foreach ($videoFrames as $frame) {
unlink($tmpfname);
$tmpfname = tempnam(sys_get_temp_dir(), 'download');
// Save the frame as a PNG
$frame->save(new FFMpeg\Format\Video\PNG(), $tmpfname);
break;
}
}
// Raw OCR
$ocr = new TesseractOCR();
$ocr->image($tmpfname);