generated from fahricansecer/boilerplate-be
@@ -24,6 +24,7 @@ public class VideoRenderPipeline
|
||||
private readonly HiggsFieldService _higgsField;
|
||||
private readonly TtsService _tts;
|
||||
private readonly OpenAiTtsService _openAiTts;
|
||||
private readonly MinimaxTtsService _minimaxTts;
|
||||
private readonly SunoMusicService _sunoMusic;
|
||||
private readonly AudioCraftService _audioCraft;
|
||||
private readonly RemotionService _remotion;
|
||||
@@ -36,6 +37,7 @@ public class VideoRenderPipeline
|
||||
HiggsFieldService higgsField,
|
||||
TtsService tts,
|
||||
OpenAiTtsService openAiTts,
|
||||
MinimaxTtsService minimaxTts,
|
||||
SunoMusicService sunoMusic,
|
||||
AudioCraftService audioCraft,
|
||||
RemotionService remotion,
|
||||
@@ -47,6 +49,7 @@ public class VideoRenderPipeline
|
||||
_higgsField = higgsField;
|
||||
_tts = tts;
|
||||
_openAiTts = openAiTts;
|
||||
_minimaxTts = minimaxTts;
|
||||
_sunoMusic = sunoMusic;
|
||||
_audioCraft = audioCraft;
|
||||
_remotion = remotion;
|
||||
@@ -176,13 +179,48 @@ public class VideoRenderPipeline
|
||||
await progressCallback(70, "AMBIENT_GENERATION");
|
||||
|
||||
// ═══════════════════════════════════════
|
||||
// ADIM 5: REMOTION — Video render (Ken Burns + Audio Merge + Subtitles)
|
||||
// ADIM 5: REMOTION — Segmented Video render + FFmpeg Merge
|
||||
// ═══════════════════════════════════════
|
||||
_logger.LogInformation("🎬 Adım 5/6: Remotion render — Ken Burns + audio merge + subtitle");
|
||||
await progressCallback(75, "MEDIA_MERGE");
|
||||
_logger.LogInformation("🎬 Adım 5/6: Remotion Segmented Render — Ken Burns + audio merge + subtitle");
|
||||
await progressCallback(70, "MEDIA_MERGE");
|
||||
|
||||
var finalLocalPath = await _remotion.RenderVideoAsync(
|
||||
job.ProjectId, projectDir, scenes, allMediaFiles, musicFile?.LocalPath, job.TargetDuration, ct);
|
||||
int chunkSize = 20; // 20 scenes per chunk to prevent OOM
|
||||
var chunkPaths = new List<string>();
|
||||
var chunkIndex = 0;
|
||||
|
||||
for (int i = 0; i < scenes.Count; i += chunkSize)
|
||||
{
|
||||
var chunkScenes = scenes.Skip(i).Take(chunkSize).ToList();
|
||||
chunkIndex++;
|
||||
|
||||
_logger.LogInformation("Render Chunk {ChunkIndex} (Scenes {Start} to {End})",
|
||||
chunkIndex, i + 1, i + chunkScenes.Count);
|
||||
|
||||
// Pass null for musicPath so Remotion doesn't add music to each chunk
|
||||
var chunkPath = await _remotion.RenderVideoAsync(
|
||||
$"{job.ProjectId}_chunk_{chunkIndex}",
|
||||
projectDir,
|
||||
chunkScenes,
|
||||
allMediaFiles,
|
||||
null, // No music per chunk
|
||||
0,
|
||||
job.VisualEffect,
|
||||
ct);
|
||||
|
||||
chunkPaths.Add(chunkPath);
|
||||
|
||||
var progress = 70 + (int)(20.0 * (i + chunkScenes.Count) / scenes.Count);
|
||||
await progressCallback(progress, "MEDIA_MERGE");
|
||||
}
|
||||
|
||||
_logger.LogInformation("🎬 Chunklar birleştiriliyor ve müzik ekleniyor (FFmpeg)");
|
||||
var finalLocalPath = await _ffmpeg.ConcatenateAndFinalize(
|
||||
chunkPaths,
|
||||
musicFile?.LocalPath,
|
||||
projectDir,
|
||||
job.ProjectId,
|
||||
job.TargetDuration,
|
||||
ct);
|
||||
|
||||
allMediaFiles.Add(new GeneratedMediaFile
|
||||
{
|
||||
@@ -234,6 +272,10 @@ public class VideoRenderPipeline
|
||||
{
|
||||
result = await _openAiTts.GenerateNarrationAsync(scene, outputDir, voiceStyle, ct);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(scene.TtsProvider) && scene.TtsProvider.Equals("minimax", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result = await _minimaxTts.GenerateNarrationAsync(scene, outputDir, voiceStyle, ct);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default: ElevenLabs
|
||||
|
||||
Reference in New Issue
Block a user