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-03-28 01:01:58 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3011228e73feaf6f51292249760a978442e52833
3011228e
1 parent
c4291336
1.调试合成脚本程序
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
7 deletions
app/Jobs/AdminMakeImmerse.php
app/Jobs/AdminMakeImmerse.php
View file @
3011228
...
...
@@ -212,6 +212,7 @@ class AdminMakeImmerse implements ShouldQueue
$opacity
=
$component
->
opacity
?
$component
->
opacity
/
100
:
0.5
;
$font_file
=
$this
->
getAbsolutePath
(
$component
->
font_file
);
$text_bg_box
=
$component
->
text_bg_box
??
0
;
$font_size
=
$this
->
calcFontSize
(
$component
->
font_size
);
// 文字淡入淡出模式
if
(
$component
->
draw
==
'fade'
){
...
...
@@ -219,13 +220,13 @@ class AdminMakeImmerse implements ShouldQueue
switch
(
$component
->
name
){
case
'one_poem'
:
foreach
(
$this
->
adminMakeVideo
->
poem2
->
verses
as
$item
)
{
if
(
$item
->
content
!=
''
)
$contents
[]
=
$
item
->
content
;
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
[]
=
$
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
->
content
,
$font_size
,
$this
->
output_width
)
;
}
break
;
case
'weather'
:
...
...
@@ -251,13 +252,14 @@ class AdminMakeImmerse implements ShouldQueue
$sub_text
.=
'drawtext="'
.
'fontfile='
.
escapeshellarg
(
$font_file
)
.
':'
.
'textfile='
.
escapeshellarg
(
$text_file
)
.
':'
.
'fontsize='
.
$
this
->
calcFontSize
(
$component
->
font_size
)
.
':'
.
'fontsize='
.
$
font_size
.
':'
.
'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 }'
)
.
':'
.
'x='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
0
])
.
':'
.
'y='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
1
])
.
':'
.
'", '
;
}
$drawtext
.=
$sub_text
;
}
...
...
@@ -269,7 +271,8 @@ class AdminMakeImmerse implements ShouldQueue
case
'one_poem'
:
$stanzas
=
''
;
foreach
(
$this
->
adminMakeVideo
->
poem2
->
verses
as
$item
)
{
if
(
$item
->
content
!=
''
)
$stanzas
.=
$item
->
content
.
"
\n
"
;
if
(
$item
->
content
!=
''
)
$stanzas
.=
$this
->
autoEnter
(
$item
->
content
,
$font_size
,
$this
->
output_width
)
.
"
\n
"
;
}
$contents
[]
=
$stanzas
;
break
;
...
...
@@ -290,7 +293,7 @@ class AdminMakeImmerse implements ShouldQueue
$sub_text
.=
'drawtext="'
.
'fontfile='
.
escapeshellarg
(
$font_file
)
.
':'
.
'textfile='
.
escapeshellarg
(
$text_file
)
.
':'
.
'fontsize='
.
$
this
->
calcFontSize
(
$component
->
font_size
)
.
':'
.
'fontsize='
.
$
font_size
.
':'
.
'fontcolor='
.
$text_color
.
'@'
.
$opacity
.
':'
.
'x='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
0
])
.
':'
.
'y='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
1
])
.
':'
.
...
...
@@ -304,9 +307,28 @@ class AdminMakeImmerse 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
calcFontSize
(
$width
)
{
return
ceil
(
$this
->
output_width
/
360
*
$width
);
return
floor
(
$this
->
output_width
/
360
*
$width
);
}
/**
...
...
Please
register
or
login
to post a comment