Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-Server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
李帅
2023-05-17 01:33:51 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fc37e889d3d22584693bd942ab6741733e11daff
fc37e889
1 parent
ef316b01
1.修复一些bug
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
41 deletions
app/Admin/Controllers/VideoTempController.php
app/Jobs/AdminMakeImmerse.php
app/Jobs/SendVerificationMessage.php
app/Jobs/UserMakeImmerse.php
app/Admin/Controllers/VideoTempController.php
View file @
fc37e88
...
...
@@ -114,7 +114,6 @@ class VideoTempController extends AdminController
$form
->
hasMany
(
'components'
,
'组件'
,
function
(
Form\NestedForm
$form
)
{
$form
->
select
(
'name'
,
'组件名称'
)
->
options
([
'one_poem_with_annotate'
=>
'一言带注解组件'
,
'one_poem'
=>
'一言组件'
,
'weather'
=>
'天气组件'
,
'date'
=>
'日期组件'
,
...
...
app/Jobs/AdminMakeImmerse.php
View file @
fc37e88
...
...
@@ -56,7 +56,7 @@ class AdminMakeImmerse implements ShouldQueue
$this
->
media_info
=
$this
->
mediaInfo
(
$file
);
// 准备素材
$watermark
=
$this
->
getAbsolutePath
(
'images/
LOGO_eng
.png'
);
$watermark
=
$this
->
getAbsolutePath
(
'images/
logo
.png'
);
// 组装文字参数
$drawtext
=
$this
->
getTextContentString
();
...
...
@@ -219,24 +219,8 @@ class AdminMakeImmerse implements ShouldQueue
$contents
=
[];
//
switch
(
$component
->
name
){
case
'one_poem'
:
foreach
(
$this
->
adminMakeVideo
->
poem2
->
verses
as
$item
)
{
if
(
$item
->
content
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
content
,
$font_size
,
$this
->
output_width
);
}
break
;
case
'one_poem_with_annotate'
:
foreach
(
$this
->
adminMakeVideo
->
poem2
->
verses
as
$item
)
{
if
(
$item
->
content
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
content
,
$font_size
,
$this
->
output_width
);
if
(
$item
->
annotate
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
annotate
,
$font_size
,
$this
->
output_width
);
}
break
;
case
'one_poem_with_annotate_and_source'
:
foreach
(
$this
->
adminMakeVideo
->
poem2
->
verses
as
$item
)
{
if
(
$item
->
content
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
content
,
$font_size
,
$this
->
output_width
);
if
(
$item
->
annotate
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
annotate
,
$font_size
,
$this
->
output_width
);
if
(
$item
->
source
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
source
,
$font_size
,
$this
->
output_width
);
}
break
;
case
'one_poem_with_all'
:
$default
=
$this
->
adminMakeVideo
->
poem2
->
title
.
"
\n
"
.
$this
->
adminMakeVideo
->
poem2
->
author
;
$contents
[]
=
$this
->
autoCenter
(
$default
,
$font_size
,
$this
->
output_width
);
foreach
(
$this
->
adminMakeVideo
->
poem2
->
verses
as
$item
)
{
if
(
$item
->
content
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
content
,
$font_size
,
$this
->
output_width
);
if
(
$item
->
annotate
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
annotate
,
$font_size
,
$this
->
output_width
);
...
...
@@ -275,7 +259,6 @@ class AdminMakeImmerse implements ShouldQueue
'", '
;
}
$drawtext
.=
$sub_text
;
}
...
...
@@ -283,13 +266,11 @@ class AdminMakeImmerse implements ShouldQueue
if
(
$component
->
draw
==
'fix'
){
$contents
=
[];
//
switch
(
$component
->
name
){
case
'one_poem_with_annotate'
:
case
'one_poem_with_annotate_and_source'
:
case
'one_poem_with_all'
:
case
'one_poem'
:
$stanzas
=
''
;
$default
=
$this
->
adminMakeVideo
->
poem2
->
title
.
"
\n
"
.
$this
->
adminMakeVideo
->
poem2
->
author
;
$stanzas
.=
$this
->
autoCenter
(
$default
,
$font_size
,
$this
->
output_width
)
.
PHP_EOL
.
PHP_EOL
;
foreach
(
$this
->
adminMakeVideo
->
poem2
->
verses
as
$item
)
{
if
(
$item
->
content
!=
''
)
$stanzas
.=
$this
->
autoEnter
(
$item
->
content
,
$font_size
,
$this
->
output_width
)
.
"
\n
"
;
}
$contents
[]
=
$stanzas
;
...
...
@@ -344,6 +325,39 @@ class AdminMakeImmerse implements ShouldQueue
}
}
public
function
autoCenter
(
$string
,
$font_width
,
$video_width
)
{
$video_width
=
$video_width
-
2
*
$font_width
;
// 两侧留出空隙
$row_count
=
floor
(
$video_width
/
$font_width
);
$arr
=
explode
(
"
\n
"
,
$string
);
$title
=
$arr
[
0
];
$author
=
$arr
[
1
];
$title_len
=
mb_strlen
(
$title
);
if
(
$title_len
>
$row_count
)
{
$tmp
=
array_chunk
(
preg_split
(
"//u"
,
$string
,
-
1
,
PREG_SPLIT_NO_EMPTY
),
$row_count
);
$tmp
[
count
(
$tmp
-
1
)]
=
$this
->
autoStrPad
(
end
(
$tmp
),
$row_count
*
2
,
' '
,
STR_PAD_BOTH
);
$new_title
=
''
;
foreach
(
$tmp
as
$t
)
{
$new_title
.=
join
(
""
,
$t
)
.
"
\n
"
;
}
}
else
{
$new_title
=
$this
->
autoStrPad
(
$title
,
$row_count
*
2
,
' '
,
STR_PAD_BOTH
);
}
$new_author
=
$this
->
autoStrPad
(
$author
,
$row_count
*
2
,
' '
,
STR_PAD_BOTH
);
return
$new_title
.
PHP_EOL
.
$new_author
;
}
public
function
autoStrPad
(
$string
,
$length
,
$pad_string
=
""
,
$pad_type
=
STR_PAD_BOTH
)
{
$mb_disparity_count
=
(
strlen
(
$string
)
-
mb_strlen
(
$string
))
/
2
;
return
str_pad
(
$string
,
$length
+
$mb_disparity_count
,
$pad_string
,
$pad_type
);
}
public
function
calcFontSize
(
$width
)
{
return
floor
(
$this
->
output_width
/
360
*
$width
);
...
...
app/Jobs/SendVerificationMessage.php
View file @
fc37e88
...
...
@@ -85,14 +85,13 @@ class SendVerificationMessage implements ShouldQueue
$email
=
new
\SendGrid\Mail\Mail
();
$email
->
setFrom
(
"hello@parlando.ink"
,
"Parlando"
);
$email
->
setSubject
(
"Verification Code"
);
$email
->
addTo
(
$this
->
email
,
"Parlando User"
);
$email
->
addTo
(
$this
->
email
,
$this
->
email
);
$email
->
addContent
(
"text/html"
,
"
Please enter in the verification code input box
: <strong>
$code
</strong><br/>(The code will expire in 30 minutes.)"
"text/html"
,
"
Your verification code is
: <strong>
$code
</strong><br/>(The code will expire in 30 minutes.)"
);
$sendgrid
=
new
\SendGrid
(
env
(
'SENDGRID_API_KEY'
));
try
{
$res
=
$sendgrid
->
send
(
$email
);
Log
::
channel
(
"daily"
)
->
debug
(
$res
->
body
());
$sendgrid
->
send
(
$email
);
}
catch
(
\Exception
$e
)
{
Log
::
channel
(
"daily"
)
->
error
(
"send email error :"
.
$e
->
getMessage
());
}
...
...
app/Jobs/UserMakeImmerse.php
View file @
fc37e88
...
...
@@ -97,7 +97,7 @@ class UserMakeImmerse implements ShouldQueue
}
$drawtext
=
$this
->
getTextContentString
();
$watermark
=
Storage
::
disk
(
'public'
)
->
path
(
'images/
LOGO_eng
.png'
);
$watermark
=
Storage
::
disk
(
'public'
)
->
path
(
'images/
logo
.png'
);
//直接将音频替换
$cmd
=
$this
->
ffmpeg
.
' -y '
.
...
...
@@ -156,7 +156,7 @@ class UserMakeImmerse implements ShouldQueue
}
$drawtext
=
$this
->
getTextContentString
();
$watermark
=
Storage
::
disk
(
'public'
)
->
path
(
'images/
LOGO_eng
.png'
);
$watermark
=
Storage
::
disk
(
'public'
)
->
path
(
'images/
logo
.png'
);
//直接将音频替换
$cmd
=
$this
->
ffmpeg
.
' -y '
.
...
...
@@ -207,7 +207,7 @@ class UserMakeImmerse implements ShouldQueue
//
$drawtext
=
$this
->
getTextContentString
();
$watermark
=
Storage
::
disk
(
'public'
)
->
path
(
'images/
LOGO_eng
.png'
);
$watermark
=
Storage
::
disk
(
'public'
)
->
path
(
'images/
logo
.png'
);
// 截取中间帧作为视频封面
$frame
=
ceil
(
$this
->
media_info
[
'streams'
][
0
][
'nb_frames'
]
/
2
);
...
...
@@ -498,23 +498,23 @@ class UserMakeImmerse implements ShouldQueue
$opacity
=
$component
->
opacity
?
$component
->
opacity
/
100
:
0.5
;
$font_file
=
Storage
::
disk
(
'public'
)
->
path
(
$component
->
font_file
);
$text_bg_box
=
$component
->
text_bg_box
??
0
;
$font_size
=
$this
->
calcFontSize
(
$component
->
font_size
);
// 文字淡入淡出模式
if
(
$component
->
draw
==
'fade'
){
$contents
=
[];
//
switch
(
$component
->
name
){
case
'one_poem'
:
$default
=
$this
->
immerse
->
poem2
->
title
.
"
\n
"
.
$this
->
immerse
->
poem2
->
author
;
$contents
[]
=
$this
->
autoCenter
(
$default
,
$font_size
,
$this
->
output_width
);
foreach
(
$this
->
immerse
->
poem2
->
verses
as
$item
)
{
if
(
$item
->
content
!=
''
)
$contents
[]
=
$item
->
content
;
}
break
;
case
'one_poem_with_annotate'
:
foreach
(
$this
->
immerse
->
poem2
->
verses
as
$item
)
{
if
(
$item
->
content
!=
''
)
$contents
[]
=
$item
->
content
;
if
(
$item
->
annotate
!=
''
)
$contents
[]
=
$item
->
annotate
;
if
(
$item
->
content
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
content
,
$font_size
,
$this
->
output_width
);
if
(
$item
->
annotate
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
annotate
,
$font_size
,
$this
->
output_width
);
if
(
$item
->
spelling
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
spelling
,
$font_size
,
$this
->
output_width
);
if
(
$item
->
en
!=
''
)
$contents
[]
=
$this
->
autoEnter
(
$item
->
en
,
$font_size
,
$this
->
output_width
);
}
break
;
case
'weather'
:
$contents
[]
=
$this
->
immerse
->
weather
;
break
;
...
...
@@ -552,7 +552,6 @@ class UserMakeImmerse implements ShouldQueue
if
(
$component
->
draw
==
'fix'
){
$contents
=
[];
//
switch
(
$component
->
name
){
case
'one_poem_with_annotate'
:
case
'one_poem'
:
$stanzas
=
''
;
foreach
(
$this
->
immerse
->
poem2
->
verses
as
$item
)
{
...
...
@@ -591,6 +590,57 @@ class UserMakeImmerse implements ShouldQueue
return
rtrim
(
$drawtext
,
', '
);
}
public
function
autoEnter
(
$string
,
$font_width
,
$video_width
)
{
$video_width
=
$video_width
-
2
*
$font_width
;
// 两侧留出空隙
$row_count
=
floor
(
$video_width
/
$font_width
);
echo
$row_count
;
$str_len
=
mb_strlen
(
$string
);
if
(
$str_len
>
$row_count
)
{
$tmp
=
array_chunk
(
preg_split
(
"//u"
,
$string
,
-
1
,
PREG_SPLIT_NO_EMPTY
),
$row_count
);
$new_str
=
""
;
foreach
(
$tmp
as
$t
)
{
$new_str
.=
join
(
""
,
$t
)
.
"
\n
"
;
}
return
$new_str
;
}
else
{
return
$string
;
}
}
public
function
autoCenter
(
$string
,
$font_width
,
$video_width
)
{
$video_width
=
$video_width
-
2
*
$font_width
;
// 两侧留出空隙
$row_count
=
floor
(
$video_width
/
$font_width
);
$arr
=
explode
(
"
\n
"
,
$string
);
$title
=
$arr
[
0
];
$author
=
$arr
[
1
];
$title_len
=
mb_strlen
(
$title
);
if
(
$title_len
>
$row_count
)
{
$tmp
=
array_chunk
(
preg_split
(
"//u"
,
$string
,
-
1
,
PREG_SPLIT_NO_EMPTY
),
$row_count
);
$tmp
[
count
(
$tmp
-
1
)]
=
$this
->
autoStrPad
(
end
(
$tmp
),
$row_count
*
2
,
' '
,
STR_PAD_BOTH
);
$new_title
=
''
;
foreach
(
$tmp
as
$t
)
{
$new_title
.=
join
(
""
,
$t
)
.
"
\n
"
;
}
}
else
{
$new_title
=
$this
->
autoStrPad
(
$title
,
$row_count
*
2
,
' '
,
STR_PAD_BOTH
);
}
$new_author
=
$this
->
autoStrPad
(
$author
,
$row_count
*
2
,
' '
,
STR_PAD_BOTH
);
return
$new_title
.
PHP_EOL
.
$new_author
;
}
public
function
autoStrPad
(
$string
,
$length
,
$pad_string
=
""
,
$pad_type
=
STR_PAD_BOTH
)
{
$mb_disparity_count
=
(
strlen
(
$string
)
-
mb_strlen
(
$string
))
/
2
;
return
str_pad
(
$string
,
$length
+
$mb_disparity_count
,
$pad_string
,
$pad_type
);
}
/**
* @param $width
* @param $content
...
...
Please
register
or
login
to post a comment