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
李帅
2022-04-06 16:52:39 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fb63e3f32617b41d5410edb083c4e543979549ed
fb63e3f3
1 parent
6af08eee
1.继续调试ffmpeg命令
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
14 deletions
app/Console/Commands/DevFFmpeg.php
app/Jobs/MakeVideo.php
app/Models/AdminMakeVideo.php
app/Models/VideoTemp.php
app/Console/Commands/DevFFmpeg.php
View file @
fb63e3f
...
...
@@ -46,6 +46,9 @@ class DevFFmpeg extends Command
*/
public
function
handle
()
{
$mv
=
AdminMakeVideo
::
query
()
->
first
();
dd
(
$mv
->
getContentPosition
());
$content
=
'题破山寺后禅院'
.
"
\t
"
.
' -- 常建'
.
PHP_EOL
.
'清晨入古寺,初日照高林。'
.
PHP_EOL
.
'曲径通幽处,禅房花木深。'
.
PHP_EOL
.
...
...
app/Jobs/MakeVideo.php
View file @
fb63e3f
...
...
@@ -61,6 +61,7 @@ class MakeVideo implements ShouldQueue
$signature_x
=
0
;
$signature_y
=
-
20
;
$content
=
$adminMakeVideo
->
poem
->
content
;
$content_position
=
$adminMakeVideo
->
getContentPosition
();
// 转换logo大小
// $watermark = $this->translateLogo(Storage::disk('public')->path('image/logo.jpg'));
...
...
@@ -77,7 +78,7 @@ class MakeVideo implements ShouldQueue
$animate
=
$this
->
makeAnimate
(
$last_frame_video
,
$end_wallpaper
,
''
,
$signature_x
,
$signature_y
,
$font
);
}
$video
=
$this
->
getTempPath
();
$video
_temp
=
$this
->
getTempPath
();
$cmd
=
$this
->
ffmpeg
.
' -y '
.
' -i '
.
escapeshellarg
(
$file
)
.
' -i '
.
escapeshellarg
(
$animate
)
.
...
...
@@ -89,31 +90,32 @@ class MakeVideo implements ShouldQueue
'text='
.
escapeshellarg
(
$content
)
.
':'
.
'fontsize=43:'
.
'fontcolor=white@1.0:'
.
'x=
main_w/2'
.
'-260'
.
':'
.
'y=
main_h/2'
.
'-20'
.
':'
.
'x=
'
.
$content_position
[
0
]
.
':'
.
'y=
'
.
$content_position
[
1
]
.
':'
.
'box=1:boxcolor=0xd0cdcc@0.5'
.
'" [text];'
.
'[text] [2:v]overlay='
.
$watermark_x
.
':'
.
$watermark_y
.
'[water];[water][0:1][1:0][1:1] concat=n=2:v=1:a=1[v][a]" '
.
' -map [v] -map [a]'
.
' -c:v libx264 -bt 256k -r 25'
.
' -ar 44100 -ac 2 -qmin 30 -qmax 60 -profile:v baseline -preset fast '
.
escapeshellarg
(
$video
);
escapeshellarg
(
$video
_temp
);
$this
->
execmd
(
$cmd
);
$video
=
$this
->
getTempPath
();
if
(
$adminMakeVideo
->
thumbnail
==
1
&&
$adminMakeVideo
->
thumbnail_url
){
$video_temp
=
$video
;
$video
=
$this
->
getTempPath
();
$cmd
=
$this
->
ffmpeg
.
' -y'
.
' -i '
.
escapeshellarg
(
$video_temp
)
.
' -i '
.
escapeshellarg
(
Storage
::
disk
(
'public'
)
->
path
(
$adminMakeVideo
->
thumbnail_url
))
.
' -map 1 -map 0 -c copy -disposition:0 attached_pic '
.
escapeshellarg
(
$video
);
$this
->
execmd
(
$cmd
);
$thumbnail
=
Storage
::
disk
(
'public'
)
->
path
(
$adminMakeVideo
->
thumbnail_url
);
}
else
{
$thumbnail
=
$last_frame_video
;
}
$cmd
=
$this
->
ffmpeg
.
' -y'
.
' -i '
.
escapeshellarg
(
$video_temp
)
.
' -i '
.
escapeshellarg
(
$thumbnail
)
.
' -map 1 -map 0 -c copy -disposition:0 attached_pic '
.
escapeshellarg
(
$video
);
$this
->
execmd
(
$cmd
);
// 全部合成以后创建 临境
$video_info
=
$this
->
mediainfo
(
$video
);
...
...
app/Models/AdminMakeVideo.php
View file @
fb63e3f
...
...
@@ -51,4 +51,11 @@ class AdminMakeVideo extends Model
{
return
$this
->
hasOne
(
VideoTemp
::
class
,
'id'
,
'temp_id'
);
}
public
function
getContentPosition
(
$field
=
'one_poem'
)
{
$component
=
$this
->
temp
()
->
first
()
->
components
()
->
where
(
'name'
,
'='
,
$field
)
->
first
();
return
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
];
}
}
...
...
app/Models/VideoTemp.php
View file @
fb63e3f
...
...
@@ -16,6 +16,12 @@ class VideoTemp extends Model
'botLeft'
=>
'下左'
,
'botMiddle'
=>
'下中'
,
'botRight'
=>
'下右'
,
];
const
POSITION_FFMPEG
=
[
'topLeft'
=>
[
0
,
0
],
'topMiddle'
=>
[
'(w-text_w)/2'
,
0
],
'topRight'
=>
[
'w-text_w'
,
0
],
'midLeft'
=>
[
0
,
'(h-text_h)/2'
],
'midMiddle'
=>
[
'(w-text_w)/2'
,
'(h-text_h)/2'
],
'midRight'
=>
[
'w-text_w'
,
'(h-text_h)/2'
],
'botLeft'
=>
[
0
,
'h-text_h'
],
'botMiddle'
=>
[
'(w-text_w)/2'
,
'h-text_h'
],
'botRight'
=>
[
'w-text_w'
,
'h-text_h'
],
];
protected
$table
=
'video_temp'
;
protected
$guarded
=
[
''
];
...
...
Please
register
or
login
to post a comment