|
|
@@ -380,7 +380,21 @@ class AnimeService
|
|
|
})->toArray();
|
|
|
|
|
|
$acts = [];
|
|
|
+ $totalDuration = 0; // 初始化总时长
|
|
|
+
|
|
|
foreach($segments as $segment) {
|
|
|
+ // 计算分镜时长,优先级:video_duration > audio_duration > 默认5秒
|
|
|
+ $videoDuration = getProp($segment, 'video_duration');
|
|
|
+ $audioDuration = getProp($segment, 'audio_duration');
|
|
|
+
|
|
|
+ if (!empty($videoDuration) && is_numeric($videoDuration)) {
|
|
|
+ $totalDuration += floatval($videoDuration);
|
|
|
+ } elseif (!empty($audioDuration) && is_numeric($audioDuration)) {
|
|
|
+ $totalDuration += floatval($audioDuration);
|
|
|
+ } else {
|
|
|
+ $totalDuration += 5; // 默认5秒
|
|
|
+ }
|
|
|
+
|
|
|
if (isset($acts[getProp($segment, 'act_number')])) {
|
|
|
$acts[getProp($segment, 'act_number')]['segments'][] = [
|
|
|
'segment_id' => getProp($segment, 'segment_id'),
|
|
|
@@ -406,7 +420,10 @@ class AnimeService
|
|
|
'voice_type' => getProp($segment, 'voice_type'),
|
|
|
'voice_audio_url' => getProp($segment, 'voice_audio_url'),
|
|
|
'img_url' => getProp($segment, 'img_url'),
|
|
|
+ 'audio_url' => getProp($segment, 'audio_url'),
|
|
|
+ 'audio_duration' => getProp($segment, 'audio_duration', 0),
|
|
|
'video_url' => getProp($segment, 'video_url'),
|
|
|
+ 'video_duration' => getProp($segment, 'video_duration', 0),
|
|
|
'last_frame_url' => getProp($segment, 'last_frame_url'),
|
|
|
];
|
|
|
}else {
|
|
|
@@ -438,7 +455,10 @@ class AnimeService
|
|
|
'voice_type' => getProp($segment, 'voice_type'),
|
|
|
'voice_audio_url' => getProp($segment, 'voice_audio_url'),
|
|
|
'img_url' => getProp($segment, 'img_url'),
|
|
|
+ 'audio_url' => getProp($segment, 'audio_url'),
|
|
|
+ 'audio_duration' => getProp($segment, 'audio_duration', 0),
|
|
|
'video_url' => getProp($segment, 'video_url'),
|
|
|
+ 'video_duration' => getProp($segment, 'video_duration', 0),
|
|
|
'last_frame_url' => getProp($segment, 'last_frame_url'),
|
|
|
]
|
|
|
]
|
|
|
@@ -446,6 +466,7 @@ class AnimeService
|
|
|
}
|
|
|
}
|
|
|
$episode['acts'] = array_values($acts);
|
|
|
+ $episode['total_duration'] = intval(round($totalDuration)); // 取整后的总时长
|
|
|
|
|
|
return $episode;
|
|
|
}
|
|
|
@@ -589,7 +610,21 @@ class AnimeService
|
|
|
|
|
|
// 复用已有的分镜数据,按 act 分组(避免重复查询数据库)
|
|
|
$acts = [];
|
|
|
+ $totalDuration = 0; // 初始化总时长
|
|
|
+
|
|
|
foreach($segments_for_insert as $segment) {
|
|
|
+ // 计算分镜时长,优先级:video_duration > audio_duration > 默认5秒
|
|
|
+ $videoDuration = getProp($segment, 'video_duration');
|
|
|
+ $audioDuration = getProp($segment, 'audio_duration');
|
|
|
+
|
|
|
+ if (!empty($videoDuration) && is_numeric($videoDuration)) {
|
|
|
+ $totalDuration += floatval($videoDuration);
|
|
|
+ } elseif (!empty($audioDuration) && is_numeric($audioDuration)) {
|
|
|
+ $totalDuration += floatval($audioDuration);
|
|
|
+ } else {
|
|
|
+ $totalDuration += 5; // 默认5秒
|
|
|
+ }
|
|
|
+
|
|
|
$act_number = getProp($segment, 'act_number');
|
|
|
$segment_info = [
|
|
|
'segment_id' => getProp($segment, 'segment_id'),
|
|
|
@@ -615,7 +650,10 @@ class AnimeService
|
|
|
'voice_type' => getProp($segment, 'voice_type'),
|
|
|
'voice_audio_url' => getProp($segment, 'voice_audio_url'),
|
|
|
'img_url' => getProp($segment, 'img_url'),
|
|
|
+ 'audio_url' => getProp($segment, 'audio_url'),
|
|
|
+ 'audio_duration' => getProp($segment, 'audio_duration', 0),
|
|
|
'video_url' => getProp($segment, 'video_url'),
|
|
|
+ 'video_duration' => getProp($segment, 'video_duration', 0),
|
|
|
'last_frame_url' => getProp($segment, 'last_frame_url'),
|
|
|
];
|
|
|
|
|
|
@@ -630,6 +668,7 @@ class AnimeService
|
|
|
}
|
|
|
}
|
|
|
$result['acts'] = array_values($acts);
|
|
|
+ $result['total_duration'] = intval(round($totalDuration)); // 取整后的总时长
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
@@ -660,7 +699,21 @@ class AnimeService
|
|
|
})->toArray();
|
|
|
|
|
|
$acts = [];
|
|
|
+ $totalDuration = 0; // 初始化总时长
|
|
|
+
|
|
|
foreach($segments as $segment) {
|
|
|
+ // 计算分镜时长,优先级:video_duration > audio_duration > 默认5秒
|
|
|
+ $videoDuration = getProp($segment, 'video_duration');
|
|
|
+ $audioDuration = getProp($segment, 'audio_duration');
|
|
|
+
|
|
|
+ if (!empty($videoDuration) && is_numeric($videoDuration)) {
|
|
|
+ $totalDuration += floatval($videoDuration);
|
|
|
+ } elseif (!empty($audioDuration) && is_numeric($audioDuration)) {
|
|
|
+ $totalDuration += floatval($audioDuration);
|
|
|
+ } else {
|
|
|
+ $totalDuration += 5; // 默认5秒
|
|
|
+ }
|
|
|
+
|
|
|
if (isset($acts[getProp($segment, 'act_number')])) {
|
|
|
$acts[getProp($segment, 'act_number')]['segments'][] = [
|
|
|
'segment_id' => getProp($segment, 'segment_id'),
|
|
|
@@ -686,7 +739,10 @@ class AnimeService
|
|
|
'voice_type' => getProp($segment, 'voice_type'),
|
|
|
'voice_audio_url' => getProp($segment, 'voice_audio_url'),
|
|
|
'img_url' => getProp($segment, 'img_url'),
|
|
|
+ 'audio_url' => getProp($segment, 'audio_url'),
|
|
|
+ 'audio_duration' => getProp($segment, 'audio_duration', 0),
|
|
|
'video_url' => getProp($segment, 'video_url'),
|
|
|
+ 'video_duration' => getProp($segment, 'video_duration', 0),
|
|
|
'last_frame_url' => getProp($segment, 'last_frame_url'),
|
|
|
];
|
|
|
}else {
|
|
|
@@ -718,7 +774,10 @@ class AnimeService
|
|
|
'voice_type' => getProp($segment, 'voice_type'),
|
|
|
'voice_audio_url' => getProp($segment, 'voice_audio_url'),
|
|
|
'img_url' => getProp($segment, 'img_url'),
|
|
|
+ 'audio_url' => getProp($segment, 'audio_url'),
|
|
|
+ 'audio_duration' => getProp($segment, 'audio_duration', 0),
|
|
|
'video_url' => getProp($segment, 'video_url'),
|
|
|
+ 'video_duration' => getProp($segment, 'video_duration', 0),
|
|
|
'last_frame_url' => getProp($segment, 'last_frame_url'),
|
|
|
]
|
|
|
]
|
|
|
@@ -726,6 +785,7 @@ class AnimeService
|
|
|
}
|
|
|
}
|
|
|
$episode['acts'] = array_values($acts);
|
|
|
+ $episode['total_duration'] = intval(round($totalDuration)); // 取整后的总时长
|
|
|
}
|
|
|
|
|
|
return $episodes;
|