Spaces:
Running
Running
Commit ·
23a704f
1
Parent(s): 2887549
Render with bubbles working
Browse filesFiles changed (3)
1 unmodified line23456753 unmodified lines6162636465666 unmodified lines73747576777879808146 unmodified lines1281291301311321331341351361 unmodified lineimport os from 'os';import path from 'path';import fs from 'fs';const ffmpegLocation = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';53 unmodified lines// Burn captions for this sectionconst captionFile = section.audioCaptionFile;if (captionFile && captionFile.endsWith('.ass')) {const subbedFile = path.join(outDir, `${jobId}_section${i}_subbed.mp4`);const esc = captionFile.replace(/\\/g, '/').replace(/:/g, '\\:');6 unmodified linesonLog && onLog(`Burning captions for section ${i}...\n`);await this.runFFmpeg(subArgs, controller, onLog);tempFiles.push(subbedFile);sectionCaptionedVideos.push(subbedFile);} else {sectionCaptionedVideos.push(sectionVideo);}}46 unmodified lines}}// Cleanup intermediate filesfor (const f of tempFiles) {// try { if (fs.existsSync(f)) fs.unlinkSync(f); } catch (_) { }}return resultFile;1 unmodified line234567853 unmodified lines626364656667686 unmodified lines7576777879808182838485868788899091929394959697989946 unmodified lines1461471481491501511521531541551561571581591601611621631641651661 unmodified lineimport os from 'os';import path from 'path';import fs from 'fs';import Bubble from './bubble/Bubble.js';const ffmpegLocation = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';53 unmodified lines// Burn captions for this sectionconst captionFile = section.audioCaptionFile;let sourceForBubbles;if (captionFile && captionFile.endsWith('.ass')) {const subbedFile = path.join(outDir, `${jobId}_section${i}_subbed.mp4`);const esc = captionFile.replace(/\\/g, '/').replace(/:/g, '\\:');6 unmodified linesonLog && onLog(`Burning captions for section ${i}...\n`);await this.runFFmpeg(subArgs, controller, onLog);tempFiles.push(subbedFile);sourceForBubbles = subbedFile;} else {sourceForBubbles = sectionVideo;}// Apply bubbles if present on this sectionif (section.bubbles && Array.isArray(section.bubbles) && section.bubbles.length) {const bubbledFile = path.join(outDir, `${jobId}_section${i}_bubbled.mp4`);try {onLog && onLog(`Applying ${section.bubbles.length} bubble(s) to section ${i}...\n`);await Bubble.makeBubble(sourceForBubbles, section.bubbles, bubbledFile, onLog);tempFiles.push(bubbledFile);sectionCaptionedVideos.push(bubbledFile);} catch (e) {onLog && onLog(`Bubble application failed for section ${i}, using original: ${e}\n`);sectionCaptionedVideos.push(sourceForBubbles);}} else {sectionCaptionedVideos.push(sourceForBubbles);}}46 unmodified lines}}// Cleanup intermediate files — keep only the final resultFile and the manuscript JSONconst manuscriptPath = path.join(process.cwd(), 'public', 'original_manuscript.json');for (const f of tempFiles) {if (!f) continue;try {const abs = path.resolve(f);// never delete the final result file or the manuscript fileif (abs === path.resolve(resultFile)) continue;if (abs === path.resolve(manuscriptPath)) continue;if (fs.existsSync(abs)) {try { fs.unlinkSync(abs); onLog && onLog(`Deleted temp file: ${abs}\n`); } catch (e) { onLog && onLog(`Failed to delete temp file ${abs}: ${e}\n`); }}} catch (e) {onLog && onLog(`Error while cleaning temp file ${f}: ${e}\n`);}}return resultFile;
552 unmodified lines55355455555655755855956056152 unmodified lines614615616617552 unmodified linestoSec: 5.0};// Additional sample: simple-top-center-image uses an image or video asset centered at top with textconst imageSample = {templateName: 'simple-top-center-image',// provide mediaAbsPath (what makeBubble expects) pointing to an imagemediaAbsPath: path.join(cwd, 'public', 'media2.png'),bubbleText: { text: 'IMAGE ABOVE, TEXT CENTERED' },52 unmodified lines}}test()552 unmodified lines55355455555655755855956056152 unmodified lines614615616617552 unmodified linestoSec: 5.0};// Additional sample: simple-top-center-media uses an image or video asset centered at top with textconst imageSample = {templateName: 'simple-top-center-media',// provide mediaAbsPath (what makeBubble expects) pointing to an imagemediaAbsPath: path.join(cwd, 'public', 'media2.png'),bubbleText: { text: 'IMAGE ABOVE, TEXT CENTERED' },52 unmodified lines}}// test()
25 unmodified lines2627282930313225 unmodified lines// image-only variant: the caller must still provide the path when using this// template. animation defaults are pulled up to the top level so they survive// the case where the user specifies `mediaAbsPath` as a simple string.'simple-top-center-image': {borderRadius: 20,normalizeAudio: true,audioEffectFile: 'woosh',25 unmodified lines2627282930313225 unmodified lines// image-only variant: the caller must still provide the path when using this// template. animation defaults are pulled up to the top level so they survive// the case where the user specifies `mediaAbsPath` as a simple string.'simple-top-center-media': {borderRadius: 20,normalizeAudio: true,audioEffectFile: 'woosh',
utils/AvatarRender.js+34-4
utils/bubble/Bubble.js+3-3
utils/bubble/bubble-templates.js+1-1