李帅

1.修复一些bug

...@@ -220,23 +220,63 @@ class AdminMakeImmerse implements ShouldQueue ...@@ -220,23 +220,63 @@ class AdminMakeImmerse implements ShouldQueue
220 switch ($component->name){ 220 switch ($component->name){
221 case 'one_poem': 221 case 'one_poem':
222 $default = $this->adminMakeVideo->poem2->title . "\n" . $this->adminMakeVideo->poem2->author; 222 $default = $this->adminMakeVideo->poem2->title . "\n" . $this->adminMakeVideo->poem2->author;
223 - $contents[] = $this->autoCenter($default,$font_size, $this->output_width); 223 + $contents[] = [
224 + "text" => $this->autoCenter($default, $font_size, $this->output_width),
225 + "tag" => "title"
226 + ];
227 +
224 foreach ($this->adminMakeVideo->poem2->verses as $item) { 228 foreach ($this->adminMakeVideo->poem2->verses as $item) {
225 - $source = " " . "\n" . $item->source; 229 + if ($item->content){
226 - if ($item->content != '') $contents[] = $this->autoEnter($item->content, $font_size, $this->output_width) . "\n" . $this->autoCenter($source, $font_size, $this->output_width); 230 + if ($item->source){
227 - if ($item->annotate != '') $contents[] = $this->autoEnter($item->annotate, $font_size, $this->output_width); 231 + $contents[] = [
228 - if ($item->spelling != '') $contents[] = $this->autoEnter($item->spelling, $font_size, $this->output_width); 232 + "text" => $this->autoEnter($item->content, $font_size, $this->output_width) . "\n" . $this->autoCenter($item->source, $font_size, $this->output_width),
229 - if ($item->en != '') $contents[] = $this->autoEnter($item->en, $font_size, $this->output_width); 233 + "tag" => "source"
234 + ];
235 + }else{
236 + $contents[] = [
237 + "text" => $this->autoEnter($item->content, $font_size, $this->output_width),
238 + "tag" => "content"
239 + ];
240 + }
241 + }
242 +// if ($item->content != '') $contents[] = $this->autoEnter($item->content, $font_size, $this->output_width) . "\n" . $this->autoCenter($source, $font_size, $this->output_width);
243 + if ($item->annotate){
244 + $contents[] = [
245 + "text" => $this->autoEnter($item->annotate, $font_size, $this->output_width),
246 + "tag" => "annotate"
247 + ];
248 + }
249 + if ($item->spelling){
250 + $contents[] = [
251 + "text" => $this->autoEnter($item->spelling, $font_size, $this->output_width),
252 + "tag" => "spelling"
253 + ];
254 + }
255 + if ($item->en){
256 + $contents[] = [
257 + "text" => $this->autoEnter($item->en, $font_size, $this->output_width),
258 + "tag" => "en"
259 + ];
260 + }
230 } 261 }
231 break; 262 break;
232 case 'weather': 263 case 'weather':
233 - $contents[] = $this->adminMakeVideo->weather; 264 + $contents[] = [
265 + "text" => $this->adminMakeVideo->weather,
266 + "tag" => "weather"
267 + ];
234 break; 268 break;
235 case 'date': 269 case 'date':
236 - $contents[] = Carbon::now()->format('Y年m月d日H时'); 270 + $contents[] = [
271 + "text" => Carbon::now()->format('Y年m月d日H时'),
272 + "tag" => "date"
273 + ];
237 break; 274 break;
238 case 'feel': 275 case 'feel':
239 - $contents[] = $this->adminMakeVideo->feel ?: '读此一言,仿佛身临其境。'; 276 + $contents[] = [
277 + "text" => $this->adminMakeVideo->feel ?: '读此一言,仿佛身临其境。',
278 + "tag" => "feel"
279 + ];
240 break; 280 break;
241 } 281 }
242 282
...@@ -247,6 +287,57 @@ class AdminMakeImmerse implements ShouldQueue ...@@ -247,6 +287,57 @@ class AdminMakeImmerse implements ShouldQueue
247 foreach ($contents as $key => $content){ 287 foreach ($contents as $key => $content){
248 $DS = $key * $round; 288 $DS = $key * $round;
249 $DE = $DS + $round; 289 $DE = $DS + $round;
290 + if ($content['tag'] == 'title'){
291 + $arr = explode("\n", $content['text']);
292 + $title = $arr[0] ?? " ";
293 + $author = $arr[1] ?? " ";
294 + // 标题
295 + $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text'));
296 + file_put_contents($text_file, $title);
297 + $sub_text .= 'drawtext="'.
298 + 'fontfile=' . escapeshellarg($font_file) . ':' .
299 + 'textfile=' . escapeshellarg($text_file) . ':' .
300 + 'fontsize=' . $font_size . ':' .
301 + '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 }') . ':' .
302 + 'x=(w-text_w)/2:y=(h-text_h)/2' . ':' .
303 + '", ';
304 + // 作者
305 + $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text'));
306 + file_put_contents($text_file, $author);
307 + $sub_text .= 'drawtext="'.
308 + 'fontfile=' . escapeshellarg($font_file) . ':' .
309 + 'textfile=' . escapeshellarg($text_file) . ':' .
310 + 'fontsize=' . $font_size / 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 }') . ':' .
312 + 'x=(w-text_w)/2:y=(h-text_h)/2' . ':' .
313 + '", ';
314 + }elseif($content['tag'] == 'source'){
315 + $arr = explode("\n", $content['text']);
316 + $title = $arr[0] ?? " ";
317 + $author = $arr[1] ?? " ";
318 + //诗句
319 + $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text'));
320 + file_put_contents($text_file, $title);
321 + $sub_text .= 'drawtext="'.
322 + 'fontfile=' . escapeshellarg($font_file) . ':' .
323 + 'textfile=' . escapeshellarg($text_file) . ':' .
324 + 'fontsize=' . $font_size . ':' .
325 + '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 + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' .
327 + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1]) . ':' .
328 + '", ';
329 + // 出处
330 + $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text'));
331 + file_put_contents($text_file, $author);
332 + $sub_text .= 'drawtext="'.
333 + 'fontfile=' . escapeshellarg($font_file) . ':' .
334 + 'textfile=' . escapeshellarg($text_file) . ':' .
335 + 'fontsize=' . $font_size / 2 . ':' .
336 + '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 + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' .
338 + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1] + $font_size) . ':' .
339 + '", ';
340 + }else{
250 $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text')); 341 $text_file = $this->getAbsolutePath($this->getTempPath('.txt','text'));
251 file_put_contents($text_file, $content); 342 file_put_contents($text_file, $content);
252 $sub_text .= 'drawtext="'. 343 $sub_text .= 'drawtext="'.
...@@ -258,6 +349,7 @@ class AdminMakeImmerse implements ShouldQueue ...@@ -258,6 +349,7 @@ class AdminMakeImmerse implements ShouldQueue
258 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1]) . ':' . 349 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1]) . ':' .
259 '", '; 350 '", ';
260 } 351 }
352 + }
261 353
262 $drawtext .= $sub_text; 354 $drawtext .= $sub_text;
263 } 355 }
......
...@@ -513,23 +513,62 @@ class UserMakeImmerse implements ShouldQueue ...@@ -513,23 +513,62 @@ class UserMakeImmerse implements ShouldQueue
513 switch ($component->name){ 513 switch ($component->name){
514 case 'one_poem': 514 case 'one_poem':
515 $default = $this->immerse->poem2->title . "\n" . $this->immerse->poem2->author; 515 $default = $this->immerse->poem2->title . "\n" . $this->immerse->poem2->author;
516 - $contents[] = $this->autoCenter($default,$font_size, $this->output_width); 516 + $contents[] = [
517 + "text" => $this->autoCenter($default, $font_size, $this->output_width),
518 + "tag" => "title"
519 + ];
520 +
517 foreach ($this->immerse->poem2->verses as $item) { 521 foreach ($this->immerse->poem2->verses as $item) {
518 - if ($item->content != '') $contents[] = $this->autoEnter($item->content, $font_size, $this->output_width); 522 + if ($item->content){
519 - if ($item->annotate != '') $contents[] = $this->autoEnter($item->annotate, $font_size, $this->output_width); 523 + if ($item->source){
520 - if ($item->spelling != '') $contents[] = $this->autoEnter($item->spelling, $font_size, $this->output_width); 524 + $contents[] = [
521 - if ($item->en != '') $contents[] = $this->autoEnter($item->en, $font_size, $this->output_width); 525 + "text" => $this->autoEnter($item->content, $font_size, $this->output_width) . "\n" . $this->autoCenter($item->source, $font_size, $this->output_width),
526 + "tag" => "source"
527 + ];
528 + }else{
529 + $contents[] = [
530 + "text" => $this->autoEnter($item->content, $font_size, $this->output_width),
531 + "tag" => "content"
532 + ];
533 + }
534 + }
535 + if ($item->annotate){
536 + $contents[] = [
537 + "text" => $this->autoEnter($item->annotate, $font_size, $this->output_width),
538 + "tag" => "annotate"
539 + ];
540 + }
541 + if ($item->spelling){
542 + $contents[] = [
543 + "text" => $this->autoEnter($item->spelling, $font_size, $this->output_width),
544 + "tag" => "spelling"
545 + ];
546 + }
547 + if ($item->en){
548 + $contents[] = [
549 + "text" => $this->autoEnter($item->en, $font_size, $this->output_width),
550 + "tag" => "en"
551 + ];
552 + }
522 } 553 }
523 break; 554 break;
524 -
525 case 'weather': 555 case 'weather':
526 - $contents[] = $this->immerse->weather; 556 + $contents[] = [
557 + "text" => $this->immerse->weather,
558 + "tag" => "weather"
559 + ];
527 break; 560 break;
528 case 'date': 561 case 'date':
529 - $contents[] = Carbon::now()->format('Y年m月d日H时'); 562 + $contents[] = [
563 + "text" => Carbon::now()->format('Y年m月d日H时'),
564 + "tag" => "date"
565 + ];
530 break; 566 break;
531 case 'feel': 567 case 'feel':
532 - $contents[] = $this->immerse->feel ?: '读此一言,仿佛身临其境。'; 568 + $contents[] = [
569 + "text" => $this->immerse->feel ?: '读此一言,仿佛身临其境。',
570 + "tag" => "feel"
571 + ];
533 break; 572 break;
534 } 573 }
535 574
...@@ -540,17 +579,69 @@ class UserMakeImmerse implements ShouldQueue ...@@ -540,17 +579,69 @@ class UserMakeImmerse implements ShouldQueue
540 foreach ($contents as $key => $content){ 579 foreach ($contents as $key => $content){
541 $DS = $key * $round; 580 $DS = $key * $round;
542 $DE = $DS + $round; 581 $DE = $DS + $round;
582 + if ($content['tag'] == 'title'){
583 + $arr = explode("\n", $content['text']);
584 + $title = $arr[0] ?? " ";
585 + $author = $arr[1] ?? " ";
586 + // 标题
587 + $text_file = Storage::disk('public')->path($this->getTempPath('.txt','text'));
588 + file_put_contents($text_file, $title);
589 + $sub_text .= 'drawtext="'.
590 + 'fontfile=' . escapeshellarg($font_file) . ':' .
591 + 'textfile=' . escapeshellarg($text_file) . ':' .
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 }') . ':' .
594 + 'x=(w-text_w)/2:y=(h-text_h)/2' . ':' .
595 + '", ';
596 + // 作者
597 + $text_file = Storage::disk('public')->path($this->getTempPath('.txt','text'));
598 + file_put_contents($text_file, $author);
599 + $sub_text .= 'drawtext="'.
600 + 'fontfile=' . escapeshellarg($font_file) . ':' .
601 + 'textfile=' . escapeshellarg($text_file) . ':' .
602 + '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 + 'x=(w-text_w)/2:y=(h-text_h)/2+' . $font_size . ':' .
605 + '", ';
606 + }elseif($content['tag'] == 'source'){
607 + $arr = explode("\n", $content['text']);
608 + $title = $arr[0] ?? " ";
609 + $author = $arr[1] ?? " ";
610 + //诗句
611 + $text_file = Storage::disk('public')->path($this->getTempPath('.txt','text'));
612 + file_put_contents($text_file, $title);
613 + $sub_text .= 'drawtext="'.
614 + 'fontfile=' . escapeshellarg($font_file) . ':' .
615 + 'textfile=' . escapeshellarg($text_file) . ':' .
616 + 'fontsize=' . $font_size . ':' .
617 + '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 }') . ':' .
618 + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' .
619 + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1]) . ':' .
620 + '", ';
621 + // 出处
622 + $text_file = Storage::disk('public')->path($this->getTempPath('.txt','text'));
623 + file_put_contents($text_file, $author);
624 + $sub_text .= 'drawtext="'.
625 + 'fontfile=' . escapeshellarg($font_file) . ':' .
626 + 'textfile=' . escapeshellarg($text_file) . ':' .
627 + '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 }') . ':' .
629 + 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' .
630 + 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1] + $font_size) . ':' .
631 + '", ';
632 + }else{
543 $text_file = Storage::disk('public')->path($this->getTempPath('.txt','text')); 633 $text_file = Storage::disk('public')->path($this->getTempPath('.txt','text'));
544 file_put_contents($text_file, $content); 634 file_put_contents($text_file, $content);
545 $sub_text .= 'drawtext="'. 635 $sub_text .= 'drawtext="'.
546 'fontfile=' . escapeshellarg($font_file) . ':' . 636 'fontfile=' . escapeshellarg($font_file) . ':' .
547 'textfile=' . escapeshellarg($text_file) . ':' . 637 'textfile=' . escapeshellarg($text_file) . ':' .
548 - 'fontsize=' . $this->calcFontSize($component->font_size) . ':' . 638 + 'fontsize=' . $font_size . ':' .
549 '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 }') . ':' . 639 '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 }') . ':' .
550 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' . 640 'x=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][0]) . ':' .
551 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1]) . ':' . 641 'y=' . escapeshellarg(VideoTemp::POSITION_FFMPEG[$component->position][1]) . ':' .
552 '", '; 642 '", ';
553 } 643 }
644 + }
554 645
555 $drawtext .= $sub_text; 646 $drawtext .= $sub_text;
556 } 647 }
......