Showing
2 changed files
with
75 additions
and
79 deletions
... | @@ -60,7 +60,6 @@ class AdminMakeImmerse implements ShouldQueue | ... | @@ -60,7 +60,6 @@ class AdminMakeImmerse implements ShouldQueue |
60 | 60 | ||
61 | // 组装文字参数 | 61 | // 组装文字参数 |
62 | $drawtext = $this->getTextContentString(); | 62 | $drawtext = $this->getTextContentString(); |
63 | - echo $drawtext; | ||
64 | 63 | ||
65 | // 判断双轨 没有则制作空轨 | 64 | // 判断双轨 没有则制作空轨 |
66 | $is_bgm = $this->adminMakeVideo->temp->bg_music == 1; //是否手动上传背景音 | 65 | $is_bgm = $this->adminMakeVideo->temp->bg_music == 1; //是否手动上传背景音 |
... | @@ -278,82 +277,77 @@ class AdminMakeImmerse implements ShouldQueue | ... | @@ -278,82 +277,77 @@ class AdminMakeImmerse implements ShouldQueue |
278 | ]; | 277 | ]; |
279 | break; | 278 | break; |
280 | } | 279 | } |
281 | - try{ | 280 | + $FID = $FOD = floatval($component->fade_time / 1000); |
282 | - $FID = $FOD = floatval($component->fade_time / 1000); | 281 | + $round = round($this->media_info['format']['duration'] / count($contents),1); |
283 | - $round = round($this->media_info['format']['duration'] / count($contents),1); | 282 | + if ($round < 1) $round = 1; |
284 | - if ($round < 1) $round = 1; | 283 | + $sub_text = ''; |
285 | - $sub_text = ''; | 284 | + foreach ($contents as $key => $content){ |
286 | - foreach ($contents as $key => $content){ | 285 | + $DS = $key * $round; |
287 | - $DS = $key * $round; | 286 | + $DE = $DS + $round; |
288 | - $DE = $DS + $round; | 287 | + if ($content['tag'] == 'title'){ |
289 | - if ($content['tag'] == 'title'){ | 288 | + $arr = explode("\n", $content['text']); |
290 | - $arr = explode("\n", $content['text']); | 289 | + $title = $arr[0] ?? " "; |
291 | - $title = $arr[0] ?? " "; | 290 | + $author = $arr[1] ?? " "; |
292 | - $author = $arr[1] ?? " "; | 291 | + // 标题 |
293 | - // 标题 | 292 | + $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); |
294 | - $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); | 293 | + file_put_contents($text_file, $title); |
295 | - file_put_contents($text_file, $title); | 294 | + $sub_text .= 'drawtext="'. |
296 | - $sub_text .= 'drawtext="'. | 295 | + 'fontfile=' . escapeshellarg($font_file) . ':' . |
297 | - 'fontfile=' . escapeshellarg($font_file) . ':' . | 296 | + 'textfile=' . escapeshellarg($text_file) . ':' . |
298 | - 'textfile=' . escapeshellarg($text_file) . ':' . | 297 | + 'fontsize=' . $font_size . ':' . |
299 | - 'fontsize=' . $font_size . ':' . | 298 | + 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . |
300 | - 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . | 299 | + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][0]) . ':' . |
301 | - 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][0]) . ':' . | 300 | + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][1]) . ':' . |
302 | - 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][1]) . ':' . | 301 | + '", '; |
303 | - '", '; | 302 | + // 作者 |
304 | - // 作者 | 303 | + $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); |
305 | - $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); | 304 | + file_put_contents($text_file, $author); |
306 | - file_put_contents($text_file, $author); | 305 | + $sub_text .= 'drawtext="'. |
307 | - $sub_text .= 'drawtext="'. | 306 | + 'fontfile=' . escapeshellarg($font_file) . ':' . |
308 | - 'fontfile=' . escapeshellarg($font_file) . ':' . | 307 | + 'textfile=' . escapeshellarg($text_file) . ':' . |
309 | - 'textfile=' . escapeshellarg($text_file) . ':' . | 308 | + 'fontsize=' . $font_size / 2 . ':' . |
310 | - 'fontsize=' . $font_size / 2 . ':' . | 309 | + 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . |
311 | - 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . | 310 | + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][0]) . ':' . |
312 | - 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][0]) . ':' . | 311 | + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][1] . '+' . $font_size) . ':' . |
313 | - 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][1] + $font_size) . ':' . | 312 | + '", '; |
314 | - '", '; | 313 | + }elseif($content['tag'] == 'source'){ |
315 | - }elseif($content['tag'] == 'source'){ | 314 | + $arr = explode("\n", $content['text']); |
316 | - $arr = explode("\n", $content['text']); | 315 | + $title = $arr[0] ?? " "; |
317 | - $title = $arr[0] ?? " "; | 316 | + $author = $arr[1] ?? " "; |
318 | - $author = $arr[1] ?? " "; | 317 | + //诗句 |
319 | - //诗句 | 318 | + $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); |
320 | - $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); | 319 | + file_put_contents($text_file, $title); |
321 | - file_put_contents($text_file, $title); | 320 | + $sub_text .= 'drawtext="'. |
322 | - $sub_text .= 'drawtext="'. | 321 | + 'fontfile=' . escapeshellarg($font_file) . ':' . |
323 | - 'fontfile=' . escapeshellarg($font_file) . ':' . | 322 | + 'textfile=' . escapeshellarg($text_file) . ':' . |
324 | - 'textfile=' . escapeshellarg($text_file) . ':' . | 323 | + 'fontsize=' . $font_size . ':' . |
325 | - 'fontsize=' . $font_size . ':' . | 324 | + 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . |
326 | - 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . | 325 | + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' . |
327 | - 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' . | 326 | + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1]) . ':' . |
328 | - 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1]) . ':' . | 327 | + '", '; |
329 | - '", '; | 328 | + // 出处 |
330 | - // 出处 | 329 | + $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); |
331 | - $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); | 330 | + file_put_contents($text_file, $author); |
332 | - file_put_contents($text_file, $author); | 331 | + $sub_text .= 'drawtext="'. |
333 | - $sub_text .= 'drawtext="'. | 332 | + 'fontfile=' . escapeshellarg($font_file) . ':' . |
334 | - 'fontfile=' . escapeshellarg($font_file) . ':' . | 333 | + 'textfile=' . escapeshellarg($text_file) . ':' . |
335 | - 'textfile=' . escapeshellarg($text_file) . ':' . | 334 | + 'fontsize=' . $font_size / 2 . ':' . |
336 | - 'fontsize=' . $font_size / 2 . ':' . | 335 | + 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . |
337 | - 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . | 336 | + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' . |
338 | - 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' . | 337 | + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1] . '+' . $font_size) . ':' . |
339 | - 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1] + $font_size) . ':' . | 338 | + '", '; |
340 | - '", '; | 339 | + }else{ |
341 | - }else{ | 340 | + $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); |
342 | - $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); | 341 | + file_put_contents($text_file, $content); |
343 | - file_put_contents($text_file, $content); | 342 | + $sub_text .= 'drawtext="'. |
344 | - $sub_text .= 'drawtext="'. | 343 | + 'fontfile=' . escapeshellarg($font_file) . ':' . |
345 | - 'fontfile=' . escapeshellarg($font_file) . ':' . | 344 | + 'textfile=' . escapeshellarg($text_file) . ':' . |
346 | - 'textfile=' . escapeshellarg($text_file) . ':' . | 345 | + 'fontsize=' . $font_size . ':' . |
347 | - 'fontsize=' . $font_size . ':' . | 346 | + 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . |
348 | - 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . | 347 | + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' . |
349 | - 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' . | 348 | + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1]) . ':' . |
350 | - 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1]) . ':' . | 349 | + '", '; |
351 | - '", '; | ||
352 | - } | ||
353 | } | 350 | } |
354 | - }catch (\Exception $exception){ | ||
355 | - echo $exception->getMessage(); | ||
356 | - echo $exception->getLine(); | ||
357 | } | 351 | } |
358 | 352 | ||
359 | $drawtext .= $sub_text; | 353 | $drawtext .= $sub_text; | ... | ... |
... | @@ -591,7 +591,8 @@ class UserMakeImmerse implements ShouldQueue | ... | @@ -591,7 +591,8 @@ class UserMakeImmerse implements ShouldQueue |
591 | 'textfile=' . escapeshellarg($text_file) . ':' . | 591 | 'textfile=' . escapeshellarg($text_file) . ':' . |
592 | 'fontsize=' . $font_size . ':' . | 592 | 'fontsize=' . $font_size . ':' . |
593 | 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . | 593 | 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . |
594 | - 'x=(w-text_w)/2:y=(h-text_h)/2' . ':' . | 594 | + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][0]) . ':' . |
595 | + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][1]) . ':' . | ||
595 | '", '; | 596 | '", '; |
596 | // 作者 | 597 | // 作者 |
597 | $text_file = Storage::disk('public')->path($this->getTempPath('.txt','text')); | 598 | $text_file = Storage::disk('public')->path($this->getTempPath('.txt','text')); |
... | @@ -601,7 +602,8 @@ class UserMakeImmerse implements ShouldQueue | ... | @@ -601,7 +602,8 @@ class UserMakeImmerse implements ShouldQueue |
601 | 'textfile=' . escapeshellarg($text_file) . ':' . | 602 | 'textfile=' . escapeshellarg($text_file) . ':' . |
602 | 'fontsize=' . $font_size / 2 . ':' . | 603 | 'fontsize=' . $font_size / 2 . ':' . |
603 | 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . | 604 | 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . |
604 | - 'x=(w-text_w)/2:y=(h-text_h)/2+' . $font_size . ':' . | 605 | + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][0]) . ':' . |
606 | + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG['midMiddle'][1] . '+' . $font_size) . ':' . | ||
605 | '", '; | 607 | '", '; |
606 | }elseif($content['tag'] == 'source'){ | 608 | }elseif($content['tag'] == 'source'){ |
607 | $arr = explode("\n", $content['text']); | 609 | $arr = explode("\n", $content['text']); |
... | @@ -627,7 +629,7 @@ class UserMakeImmerse implements ShouldQueue | ... | @@ -627,7 +629,7 @@ class UserMakeImmerse implements ShouldQueue |
627 | 'fontsize=' . $font_size / 2 . ':' . | 629 | 'fontsize=' . $font_size / 2 . ':' . |
628 | 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . | 630 | 'fontcolor_expr=' . escapeshellarg($text_color . '%{eif\\\\: clip(255*(1*between(t\\, ' . $DS . ' + ' . $FID . '\\, ' . $DE . ' - ' . $FOD . ') + ((t - ' . $DS . ')/' . $FID . ')*between(t\\, ' . $DS . '\\, ' . $DS . ' + ' . $FID . ') + (-(t - ' . $DE . ')/' . $FOD . ')*between(t\\, ' . $DE . ' - ' . $FOD . '\\, ' . $DE . '))\\, 0\\, 255) \\\\: x\\\\: 2 }') . ':' . |
629 | 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' . | 631 | 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' . |
630 | - 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1] + $font_size) . ':' . | 632 | + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1] . '+' . $font_size) . ':' . |
631 | '", '; | 633 | '", '; |
632 | }else{ | 634 | }else{ |
633 | $text_file = Storage::disk('public')->path($this->getTempPath('.txt','text')); | 635 | $text_file = Storage::disk('public')->path($this->getTempPath('.txt','text')); | ... | ... |
-
Please register or login to post a comment