|
|
@@ -240,16 +240,24 @@ public class VideoGenerateJob {
|
|
|
private String randomImageToVideoAnimation(String imageUrl, String outputVideoName) {
|
|
|
String command;
|
|
|
switch (new Random().nextInt(2)) {
|
|
|
- // 放大
|
|
|
+ // 背景模糊 + 放大
|
|
|
case 0:
|
|
|
- command = String.format("ffmpeg -y -loop 1 -i %s -t 3 -vf " +
|
|
|
- "\"scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2:black\" " +
|
|
|
- "-c:v libx264 -pix_fmt yuv420p %s",
|
|
|
+ command = String.format("ffmpeg -y -loop 1 -i %s -t 3 -r 25 -filter_complex " +
|
|
|
+ "\"[0:v]scale=720:1280:force_original_aspect_ratio=increase,crop=720:1280,boxblur=10:1[bg];" +
|
|
|
+ "[0:v]scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2:color=black@0[fg];" +
|
|
|
+ "[fg]zoompan=z='1.0+0.001*on':d=75:s=720x1280[fg_anim];[bg][fg_anim]overlay=0:0:format=auto,format=yuv420p\" " +
|
|
|
+ "-c:v libx264 -pix_fmt yuv420p -movflags +faststart %s",
|
|
|
imageUrl, outputVideoName);
|
|
|
break;
|
|
|
- // 平移
|
|
|
+ // 背景模糊
|
|
|
case 1:
|
|
|
- // 背景模糊
|
|
|
+ command = String.format("ffmpeg -y -loop 1 -i %s -t 3 -r 25 -filter_complex " +
|
|
|
+ "\"[0:v]scale=720:1280:force_original_aspect_ratio=increase,crop=720:1280,boxblur=10:1[bg];" +
|
|
|
+ "[0:v]scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2:color=black@0[fg];" +
|
|
|
+ "[bg][fg]overlay=0:0:format=auto,format=yuv420p\" " +
|
|
|
+ "-c:v libx264 -pix_fmt yuv420p -movflags +faststart %s",
|
|
|
+ imageUrl, outputVideoName);
|
|
|
+ break;
|
|
|
default:
|
|
|
command = String.format("ffmpeg -y -loop 1 -i %s -t 3 -vf " +
|
|
|
"\"scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2:black\" " +
|
|
|
@@ -410,7 +418,7 @@ public class VideoGenerateJob {
|
|
|
VideoTimeCutParam timeCutParam = VideoTimeCutParam.builder()
|
|
|
.videoUrl(concatVideoUrl)
|
|
|
.startTime("00:00:00")
|
|
|
- .endTime(formatSecondsToTime(audio.getDuration() / 1000 ))
|
|
|
+ .endTime(formatSecondsToTime(audio.getDuration() / 1000))
|
|
|
.build();
|
|
|
String cutVideoUrl = ffmpegApiService.timeCutVideo(timeCutParam);
|
|
|
// add audio
|