From 3b99ddae269de0a2588930c8a011f598c2b378c1 Mon Sep 17 00:00:00 2001 From: koogua Date: Mon, 7 Dec 2020 21:06:33 +0800 Subject: [PATCH] =?UTF-8?q?!35=20=E4=BF=AE=E5=A4=8D=E8=85=BE=E8=AE=AF?= =?UTF-8?q?=E4=BA=91=E5=9B=9E=E8=B0=83=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E6=94=B9=E5=8F=98=E5=AF=BC=E8=87=B4=E7=9A=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=20*=20=E4=BF=AE=E5=A4=8D=E8=85=BE=E8=AE=AF=E4=BA=91=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E6=94=B9=E5=8F=98?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E9=94=99=E8=AF=AF=EF=BC=8C=E7=BC=A9?= =?UTF-8?q?=E7=9F=ADvod=5Fevent=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Tasks/VodEventTask.php | 12 +++--------- app/Http/Admin/Services/ChapterContent.php | 14 ++++++++++---- scheduler.php | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/Console/Tasks/VodEventTask.php b/app/Console/Tasks/VodEventTask.php index 0189960b..49d86fc7 100644 --- a/app/Console/Tasks/VodEventTask.php +++ b/app/Console/Tasks/VodEventTask.php @@ -45,7 +45,8 @@ class VodEventTask extends Task protected function handleNewFileUploadEvent($event) { $fileId = $event['FileUploadEvent']['FileId']; - $format = $event['FileUploadEvent']['MediaBasicInfo']['Type']; + $width = $event['FileUploadEvent']['MetaData']['Height']; + $height = $event['FileUploadEvent']['MetaData']['Width']; $duration = $event['FileUploadEvent']['MetaData']['Duration']; $chapterRepo = new ChapterRepo(); @@ -56,7 +57,7 @@ class VodEventTask extends Task $vodService = new VodService(); - if ($this->isAudioFile($format)) { + if ($width == 0 && $height == 0) { $vodService->createTransAudioTask($fileId); } else { $vodService->createTransVideoTask($fileId); @@ -144,13 +145,6 @@ class VodEventTask extends Task return $vodService->confirmEvents($handles); } - protected function isAudioFile($format) - { - $formats = ['mp3', 'm4a', 'wav', 'flac', 'ogg']; - - return in_array(strtolower($format), $formats); - } - protected function updateVodAttrs(ChapterModel $chapter) { $courseStats = new CourseStatService(); diff --git a/app/Http/Admin/Services/ChapterContent.php b/app/Http/Admin/Services/ChapterContent.php index f02962d1..09fccf37 100644 --- a/app/Http/Admin/Services/ChapterContent.php +++ b/app/Http/Admin/Services/ChapterContent.php @@ -81,10 +81,20 @@ class ChapterContent extends Service $vod = $chapterRepo->findChapterVod($chapter->id); + /** + * 无新文件上传 + */ if ($fileId == $vod->file_id) { return; } + /** + * 删除旧文件 + */ + if ($vod->file_id) { + $this->deleteVodFile($vod->file_id); + } + $vod->update([ 'file_id' => $fileId, 'file_transcode' => '', @@ -102,10 +112,6 @@ class ChapterContent extends Service $chapter->update(['attrs' => $attrs]); $this->updateCourseVodAttrs($vod->course_id); - - if (!empty($vod->file_id)) { - $this->deleteVodFile($vod->file_id); - } } protected function updateChapterLive(ChapterModel $chapter) diff --git a/scheduler.php b/scheduler.php index ddc820e2..b038b608 100644 --- a/scheduler.php +++ b/scheduler.php @@ -20,7 +20,7 @@ $scheduler->php($script, $bin, ['--task' => 'sync_learning', '--action' => 'main ->at('*/7 * * * *'); $scheduler->php($script, $bin, ['--task' => 'vod_event', '--action' => 'main']) - ->at('*/9 * * * *'); + ->at('*/5 * * * *'); $scheduler->php($script, $bin, ['--task' => 'close_trade', '--action' => 'main']) ->at('*/13 * * * *');