李帅

1.修复一些bug

...@@ -114,7 +114,6 @@ class VideoTempController extends AdminController ...@@ -114,7 +114,6 @@ class VideoTempController extends AdminController
114 114
115 $form->hasMany('components','组件', function (Form\NestedForm $form) { 115 $form->hasMany('components','组件', function (Form\NestedForm $form) {
116 $form->select('name','组件名称')->options([ 116 $form->select('name','组件名称')->options([
117 - 'one_poem_with_annotate' => '一言带注解组件',
118 'one_poem' => '一言组件', 117 'one_poem' => '一言组件',
119 'weather' => '天气组件', 118 'weather' => '天气组件',
120 'date' => '日期组件', 119 'date' => '日期组件',
......
...@@ -56,7 +56,7 @@ class AdminMakeImmerse implements ShouldQueue ...@@ -56,7 +56,7 @@ class AdminMakeImmerse implements ShouldQueue
56 $this->media_info = $this->mediaInfo($file); 56 $this->media_info = $this->mediaInfo($file);
57 57
58 // 准备素材 58 // 准备素材
59 - $watermark = $this->getAbsolutePath('images/LOGO_eng.png'); 59 + $watermark = $this->getAbsolutePath('images/logo.png');
60 60
61 // 组装文字参数 61 // 组装文字参数
62 $drawtext = $this->getTextContentString(); 62 $drawtext = $this->getTextContentString();
...@@ -219,24 +219,8 @@ class AdminMakeImmerse implements ShouldQueue ...@@ -219,24 +219,8 @@ class AdminMakeImmerse implements ShouldQueue
219 $contents = []; // 219 $contents = []; //
220 switch ($component->name){ 220 switch ($component->name){
221 case 'one_poem': 221 case 'one_poem':
222 - foreach ($this->adminMakeVideo->poem2->verses as $item) { 222 + $default = $this->adminMakeVideo->poem2->title . "\n" . $this->adminMakeVideo->poem2->author;
223 - if ($item->content != '') $contents[] = $this->autoEnter($item->content, $font_size, $this->output_width); 223 + $contents[] = $this->autoCenter($default,$font_size, $this->output_width);
224 - }
225 - break;
226 - case 'one_poem_with_annotate':
227 - foreach ($this->adminMakeVideo->poem2->verses as $item) {
228 - if ($item->content != '') $contents[] = $this->autoEnter($item->content, $font_size, $this->output_width);
229 - if ($item->annotate != '') $contents[] = $this->autoEnter($item->annotate, $font_size, $this->output_width);
230 - }
231 - break;
232 - case 'one_poem_with_annotate_and_source':
233 - foreach ($this->adminMakeVideo->poem2->verses as $item) {
234 - if ($item->content != '') $contents[] = $this->autoEnter($item->content, $font_size, $this->output_width);
235 - if ($item->annotate != '') $contents[] = $this->autoEnter($item->annotate, $font_size, $this->output_width);
236 - if ($item->source != '') $contents[] = $this->autoEnter($item->source, $font_size, $this->output_width);
237 - }
238 - break;
239 - case 'one_poem_with_all':
240 foreach ($this->adminMakeVideo->poem2->verses as $item) { 224 foreach ($this->adminMakeVideo->poem2->verses as $item) {
241 if ($item->content != '') $contents[] = $this->autoEnter($item->content, $font_size, $this->output_width); 225 if ($item->content != '') $contents[] = $this->autoEnter($item->content, $font_size, $this->output_width);
242 if ($item->annotate != '') $contents[] = $this->autoEnter($item->annotate, $font_size, $this->output_width); 226 if ($item->annotate != '') $contents[] = $this->autoEnter($item->annotate, $font_size, $this->output_width);
...@@ -275,7 +259,6 @@ class AdminMakeImmerse implements ShouldQueue ...@@ -275,7 +259,6 @@ class AdminMakeImmerse implements ShouldQueue
275 '", '; 259 '", ';
276 } 260 }
277 261
278 -
279 $drawtext .= $sub_text; 262 $drawtext .= $sub_text;
280 } 263 }
281 264
...@@ -283,13 +266,11 @@ class AdminMakeImmerse implements ShouldQueue ...@@ -283,13 +266,11 @@ class AdminMakeImmerse implements ShouldQueue
283 if ($component->draw == 'fix'){ 266 if ($component->draw == 'fix'){
284 $contents = []; // 267 $contents = []; //
285 switch ($component->name){ 268 switch ($component->name){
286 - case 'one_poem_with_annotate':
287 - case 'one_poem_with_annotate_and_source':
288 - case 'one_poem_with_all':
289 case 'one_poem': 269 case 'one_poem':
290 $stanzas = ''; 270 $stanzas = '';
271 + $default = $this->adminMakeVideo->poem2->title . "\n" . $this->adminMakeVideo->poem2->author;
272 + $stanzas .= $this->autoCenter($default,$font_size, $this->output_width) .PHP_EOL.PHP_EOL;
291 foreach ($this->adminMakeVideo->poem2->verses as $item) { 273 foreach ($this->adminMakeVideo->poem2->verses as $item) {
292 -
293 if ($item->content != '') $stanzas .= $this->autoEnter($item->content, $font_size, $this->output_width) . "\n"; 274 if ($item->content != '') $stanzas .= $this->autoEnter($item->content, $font_size, $this->output_width) . "\n";
294 } 275 }
295 $contents[] = $stanzas; 276 $contents[] = $stanzas;
...@@ -344,6 +325,39 @@ class AdminMakeImmerse implements ShouldQueue ...@@ -344,6 +325,39 @@ class AdminMakeImmerse implements ShouldQueue
344 } 325 }
345 } 326 }
346 327
328 + public function autoCenter($string, $font_width, $video_width)
329 + {
330 + $video_width = $video_width - 2 * $font_width; // 两侧留出空隙
331 + $row_count = floor($video_width / $font_width);
332 + $arr = explode("\n", $string);
333 + $title = $arr[0];
334 + $author = $arr[1];
335 +
336 + $title_len = mb_strlen($title);
337 + if ($title_len > $row_count) {
338 + $tmp = array_chunk(
339 + preg_split("//u", $string, -1, PREG_SPLIT_NO_EMPTY), $row_count);
340 + $tmp[count($tmp - 1)] = $this->autoStrPad(end($tmp), $row_count * 2, ' ', STR_PAD_BOTH);
341 + $new_title = '';
342 + foreach ($tmp as $t) {
343 + $new_title .= join("", $t) . "\n";
344 + }
345 + } else {
346 + $new_title = $this->autoStrPad($title, $row_count * 2, ' ', STR_PAD_BOTH);
347 + }
348 +
349 + $new_author = $this->autoStrPad($author, $row_count * 2, ' ', STR_PAD_BOTH);
350 +
351 + return $new_title . PHP_EOL . $new_author;
352 + }
353 +
354 +
355 + public function autoStrPad($string, $length, $pad_string = "", $pad_type = STR_PAD_BOTH)
356 + {
357 + $mb_disparity_count = (strlen($string) - mb_strlen($string)) / 2;
358 + return str_pad($string,$length+$mb_disparity_count,$pad_string,$pad_type);
359 + }
360 +
347 public function calcFontSize($width) 361 public function calcFontSize($width)
348 { 362 {
349 return floor($this->output_width / 360 * $width); 363 return floor($this->output_width / 360 * $width);
......
...@@ -85,14 +85,13 @@ class SendVerificationMessage implements ShouldQueue ...@@ -85,14 +85,13 @@ class SendVerificationMessage implements ShouldQueue
85 $email = new \SendGrid\Mail\Mail(); 85 $email = new \SendGrid\Mail\Mail();
86 $email->setFrom("hello@parlando.ink", "Parlando"); 86 $email->setFrom("hello@parlando.ink", "Parlando");
87 $email->setSubject("Verification Code"); 87 $email->setSubject("Verification Code");
88 - $email->addTo($this->email, "Parlando User"); 88 + $email->addTo($this->email, $this->email);
89 $email->addContent( 89 $email->addContent(
90 - "text/html", "Please enter in the verification code input box: <strong>$code</strong><br/>(The code will expire in 30 minutes.)" 90 + "text/html", "Your verification code is: <strong>$code</strong><br/>(The code will expire in 30 minutes.)"
91 ); 91 );
92 $sendgrid = new \SendGrid(env('SENDGRID_API_KEY')); 92 $sendgrid = new \SendGrid(env('SENDGRID_API_KEY'));
93 try { 93 try {
94 - $res = $sendgrid->send($email); 94 + $sendgrid->send($email);
95 - Log::channel("daily")->debug($res->body());
96 } catch (\Exception $e) { 95 } catch (\Exception $e) {
97 Log::channel("daily")->error("send email error :".$e->getMessage()); 96 Log::channel("daily")->error("send email error :".$e->getMessage());
98 } 97 }
......
...@@ -97,7 +97,7 @@ class UserMakeImmerse implements ShouldQueue ...@@ -97,7 +97,7 @@ class UserMakeImmerse implements ShouldQueue
97 } 97 }
98 98
99 $drawtext = $this->getTextContentString(); 99 $drawtext = $this->getTextContentString();
100 - $watermark = Storage::disk('public')->path('images/LOGO_eng.png'); 100 + $watermark = Storage::disk('public')->path('images/logo.png');
101 101
102 //直接将音频替换 102 //直接将音频替换
103 $cmd = $this->ffmpeg . ' -y ' . 103 $cmd = $this->ffmpeg . ' -y ' .
...@@ -156,7 +156,7 @@ class UserMakeImmerse implements ShouldQueue ...@@ -156,7 +156,7 @@ class UserMakeImmerse implements ShouldQueue
156 } 156 }
157 157
158 $drawtext = $this->getTextContentString(); 158 $drawtext = $this->getTextContentString();
159 - $watermark = Storage::disk('public')->path('images/LOGO_eng.png'); 159 + $watermark = Storage::disk('public')->path('images/logo.png');
160 160
161 //直接将音频替换 161 //直接将音频替换
162 $cmd = $this->ffmpeg . ' -y ' . 162 $cmd = $this->ffmpeg . ' -y ' .
...@@ -207,7 +207,7 @@ class UserMakeImmerse implements ShouldQueue ...@@ -207,7 +207,7 @@ class UserMakeImmerse implements ShouldQueue
207 // 207 //
208 208
209 $drawtext = $this->getTextContentString(); 209 $drawtext = $this->getTextContentString();
210 - $watermark = Storage::disk('public')->path('images/LOGO_eng.png'); 210 + $watermark = Storage::disk('public')->path('images/logo.png');
211 211
212 // 截取中间帧作为视频封面 212 // 截取中间帧作为视频封面
213 $frame = ceil($this->media_info['streams'][0]['nb_frames'] / 2); 213 $frame = ceil($this->media_info['streams'][0]['nb_frames'] / 2);
...@@ -498,23 +498,23 @@ class UserMakeImmerse implements ShouldQueue ...@@ -498,23 +498,23 @@ class UserMakeImmerse implements ShouldQueue
498 $opacity = $component->opacity ? $component->opacity / 100 : 0.5; 498 $opacity = $component->opacity ? $component->opacity / 100 : 0.5;
499 $font_file = Storage::disk('public')->path($component->font_file); 499 $font_file = Storage::disk('public')->path($component->font_file);
500 $text_bg_box = $component->text_bg_box ?? 0; 500 $text_bg_box = $component->text_bg_box ?? 0;
501 - 501 + $font_size = $this->calcFontSize($component->font_size);
502 502
503 // 文字淡入淡出模式 503 // 文字淡入淡出模式
504 if ($component->draw == 'fade'){ 504 if ($component->draw == 'fade'){
505 $contents = []; // 505 $contents = []; //
506 switch ($component->name){ 506 switch ($component->name){
507 case 'one_poem': 507 case 'one_poem':
508 + $default = $this->immerse->poem2->title . "\n" . $this->immerse->poem2->author;
509 + $contents[] = $this->autoCenter($default,$font_size, $this->output_width);
508 foreach ($this->immerse->poem2->verses as $item) { 510 foreach ($this->immerse->poem2->verses as $item) {
509 - if ($item->content != '') $contents[] = $item->content; 511 + if ($item->content != '') $contents[] = $this->autoEnter($item->content, $font_size, $this->output_width);
510 - } 512 + if ($item->annotate != '') $contents[] = $this->autoEnter($item->annotate, $font_size, $this->output_width);
511 - break; 513 + if ($item->spelling != '') $contents[] = $this->autoEnter($item->spelling, $font_size, $this->output_width);
512 - case 'one_poem_with_annotate': 514 + if ($item->en != '') $contents[] = $this->autoEnter($item->en, $font_size, $this->output_width);
513 - foreach ($this->immerse->poem2->verses as $item) {
514 - if ($item->content != '') $contents[] = $item->content;
515 - if ($item->annotate != '') $contents[] = $item->annotate;
516 } 515 }
517 break; 516 break;
517 +
518 case 'weather': 518 case 'weather':
519 $contents[] = $this->immerse->weather; 519 $contents[] = $this->immerse->weather;
520 break; 520 break;
...@@ -552,7 +552,6 @@ class UserMakeImmerse implements ShouldQueue ...@@ -552,7 +552,6 @@ class UserMakeImmerse implements ShouldQueue
552 if ($component->draw == 'fix'){ 552 if ($component->draw == 'fix'){
553 $contents = []; // 553 $contents = []; //
554 switch ($component->name){ 554 switch ($component->name){
555 - case 'one_poem_with_annotate':
556 case 'one_poem': 555 case 'one_poem':
557 $stanzas = ''; 556 $stanzas = '';
558 foreach ($this->immerse->poem2->verses as $item) { 557 foreach ($this->immerse->poem2->verses as $item) {
...@@ -591,6 +590,57 @@ class UserMakeImmerse implements ShouldQueue ...@@ -591,6 +590,57 @@ class UserMakeImmerse implements ShouldQueue
591 return rtrim($drawtext,', '); 590 return rtrim($drawtext,', ');
592 } 591 }
593 592
593 + public function autoEnter($string, $font_width, $video_width)
594 + {
595 + $video_width = $video_width - 2 * $font_width; // 两侧留出空隙
596 + $row_count = floor($video_width / $font_width);
597 + echo $row_count;
598 + $str_len = mb_strlen($string);
599 + if ($str_len > $row_count) {
600 + $tmp = array_chunk(
601 + preg_split("//u", $string, -1, PREG_SPLIT_NO_EMPTY), $row_count);
602 + $new_str = "";
603 + foreach ($tmp as $t) {
604 + $new_str .= join("", $t) . "\n";
605 + }
606 + return $new_str;
607 + }else{
608 + return $string;
609 + }
610 + }
611 +
612 + public function autoCenter($string, $font_width, $video_width)
613 + {
614 + $video_width = $video_width - 2 * $font_width; // 两侧留出空隙
615 + $row_count = floor($video_width / $font_width);
616 + $arr = explode("\n", $string);
617 + $title = $arr[0];
618 + $author = $arr[1];
619 +
620 + $title_len = mb_strlen($title);
621 + if ($title_len > $row_count) {
622 + $tmp = array_chunk(
623 + preg_split("//u", $string, -1, PREG_SPLIT_NO_EMPTY), $row_count);
624 + $tmp[count($tmp - 1)] = $this->autoStrPad(end($tmp), $row_count * 2, ' ', STR_PAD_BOTH);
625 + $new_title = '';
626 + foreach ($tmp as $t) {
627 + $new_title .= join("", $t) . "\n";
628 + }
629 + } else {
630 + $new_title = $this->autoStrPad($title, $row_count * 2, ' ', STR_PAD_BOTH);
631 + }
632 +
633 + $new_author = $this->autoStrPad($author, $row_count * 2, ' ', STR_PAD_BOTH);
634 +
635 + return $new_title . PHP_EOL . $new_author;
636 + }
637 +
638 + public function autoStrPad($string, $length, $pad_string = "", $pad_type = STR_PAD_BOTH)
639 + {
640 + $mb_disparity_count = (strlen($string) - mb_strlen($string)) / 2;
641 + return str_pad($string,$length+$mb_disparity_count,$pad_string,$pad_type);
642 + }
643 +
594 /** 644 /**
595 * @param $width 645 * @param $width
596 * @param $content 646 * @param $content
......