Showing
3 changed files
with
62 additions
and
1 deletions
| ... | @@ -4,6 +4,7 @@ namespace App\Admin\Controllers; | ... | @@ -4,6 +4,7 @@ namespace App\Admin\Controllers; |
| 4 | 4 | ||
| 5 | use App\Admin\Renderable\PoemTable; | 5 | use App\Admin\Renderable\PoemTable; |
| 6 | use App\Admin\Renderable\TemplateTable; | 6 | use App\Admin\Renderable\TemplateTable; |
| 7 | +use App\Jobs\MakeImages; | ||
| 7 | use App\Jobs\MakeVideo; | 8 | use App\Jobs\MakeVideo; |
| 8 | use App\Models\AdminMakeVideo; | 9 | use App\Models\AdminMakeVideo; |
| 9 | use App\Models\Immerse; | 10 | use App\Models\Immerse; |
| ... | @@ -152,9 +153,15 @@ class AdminMakeVideoController extends AdminController | ... | @@ -152,9 +153,15 @@ class AdminMakeVideoController extends AdminController |
| 152 | 153 | ||
| 153 | try{ | 154 | try{ |
| 154 | $video = AdminMakeVideo::query()->create($all); | 155 | $video = AdminMakeVideo::query()->create($all); |
| 156 | + if ($all['type'] == 1){ | ||
| 155 | // 添加至队列 | 157 | // 添加至队列 |
| 156 | MakeVideo::dispatch($video); | 158 | MakeVideo::dispatch($video); |
| 157 | - | 159 | + }elseif ($all['type'] == 2){ // 新增类型,不止视频,还有静态图。 |
| 160 | + // MakeImages | ||
| 161 | + MakeImages::dispatch($video); | ||
| 162 | + }else{ | ||
| 163 | + return $this->form()->response()->error('类型选择错误'); | ||
| 164 | + } | ||
| 158 | }catch (\Exception $exception){ | 165 | }catch (\Exception $exception){ |
| 159 | return $this->form()->response()->error($exception->getMessage()); | 166 | return $this->form()->response()->error($exception->getMessage()); |
| 160 | } | 167 | } | ... | ... |
app/Jobs/MakeImages.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Jobs; | ||
| 4 | + | ||
| 5 | +use App\Models\AdminMakeVideo; | ||
| 6 | +use Illuminate\Bus\Queueable; | ||
| 7 | +use Illuminate\Contracts\Queue\ShouldBeUnique; | ||
| 8 | +use Illuminate\Contracts\Queue\ShouldQueue; | ||
| 9 | +use Illuminate\Foundation\Bus\Dispatchable; | ||
| 10 | +use Illuminate\Queue\InteractsWithQueue; | ||
| 11 | +use Illuminate\Queue\SerializesModels; | ||
| 12 | + | ||
| 13 | +class MakeImages implements ShouldQueue | ||
| 14 | +{ | ||
| 15 | + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
| 16 | + | ||
| 17 | + public $adminMakeVideo; | ||
| 18 | + | ||
| 19 | + protected $ffmpeg; | ||
| 20 | + | ||
| 21 | + protected $ffprobe; | ||
| 22 | + | ||
| 23 | + protected $ffplay; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * Create a new job instance. | ||
| 27 | + * @param AdminMakeVideo $adminMakeVideo | ||
| 28 | + * @return void | ||
| 29 | + */ | ||
| 30 | + public function __construct(AdminMakeVideo $adminMakeVideo) | ||
| 31 | + { | ||
| 32 | + $this->adminMakeVideo = $adminMakeVideo; | ||
| 33 | + | ||
| 34 | + $this->ffmpeg = env('FFMPEG_CMD'); | ||
| 35 | + $this->ffprobe = env('FFPROBE_CMD'); | ||
| 36 | + $this->ffplay = env('FFPLAY_CMD'); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * Execute the job. | ||
| 41 | + * | ||
| 42 | + * @return void | ||
| 43 | + */ | ||
| 44 | + public function handle() | ||
| 45 | + { | ||
| 46 | + //思路: | ||
| 47 | + // if 有背景音 多张图合成视频,时长为音频时长,音频加入背景音 | ||
| 48 | + // else 没有背景音,单图一张,输出为单图。 | ||
| 49 | + | ||
| 50 | + } | ||
| 51 | +} |
| ... | @@ -40,6 +40,9 @@ Route::prefix('v1')->namespace('App\Http\Controllers\V1')->group(function (Route | ... | @@ -40,6 +40,9 @@ Route::prefix('v1')->namespace('App\Http\Controllers\V1')->group(function (Route |
| 40 | /** 用户信息*/ | 40 | /** 用户信息*/ |
| 41 | $api->get('/user', 'UserController@user')->middleware('auth:sanctum'); | 41 | $api->get('/user', 'UserController@user')->middleware('auth:sanctum'); |
| 42 | 42 | ||
| 43 | + /** 上传作品 */ | ||
| 44 | + $api->get('/user', 'UserController@user')->middleware('auth:sanctum'); | ||
| 45 | + | ||
| 43 | 46 | ||
| 44 | /** 临境 */ | 47 | /** 临境 */ |
| 45 | $api->apiResource('/immersive', 'ImmerseController'); | 48 | $api->apiResource('/immersive', 'ImmerseController'); | ... | ... |
-
Please register or login to post a comment