shiveshnavin commited on
Commit
59c0ef4
·
1 Parent(s): 44751a6

SSR working

Browse files
.gitignore CHANGED
@@ -17,4 +17,5 @@ functions/*.log
17
  **.log
18
  uploads/
19
  uploads/**
20
- audit_log_creds.json
 
 
17
  **.log
18
  uploads/
19
  uploads/**
20
+ audit_log_creds.json
21
+ build/
package.json CHANGED
@@ -16,7 +16,8 @@
16
  "preinstall": "cd common-utils && npm run build",
17
  "build:utils": "cd common-utils && npm run build && cd .. && npm install ./common-utils",
18
  "render-build:igreels": "remotion render --audio-codec mp3 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --concurrency 1 --gl=vulkan IGReelComposition",
19
- "render-build": "remotion $npm_config_target --audio-codec mp3 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --timeout 60000 --concurrency 1 --gl=angle --browser-executable /usr/bin/chromium-browser $npm_config_composition",
 
20
  "render-still": "remotion still --image-format=jpeg SemibitCompositionPoster ",
21
  "render-image": "remotion still --image-format=jpeg --concurrency 1 $npm_config_composition $npm_config_output",
22
  "render-images": "remotion render --enable-multiprocess-on-linux --sequence --image-format=jpeg $npm_config_composition $npm_config_output",
 
16
  "preinstall": "cd common-utils && npm run build",
17
  "build:utils": "cd common-utils && npm run build && cd .. && npm install ./common-utils",
18
  "render-build:igreels": "remotion render --audio-codec mp3 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --concurrency 1 --gl=vulkan IGReelComposition",
19
+ "render-build:win32": "remotion %npm_config_target% --audio-codec mp3 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --timeout 60000 --concurrency 1 --gl=angle %npm_config_composition%",
20
+ "render-build": "remotion $npm_config_target --audio-codec mp3 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --timeout 60000 --concurrency 1 --gl=angle $npm_config_composition out/",
21
  "render-still": "remotion still --image-format=jpeg SemibitCompositionPoster ",
22
  "render-image": "remotion still --image-format=jpeg --concurrency 1 $npm_config_composition $npm_config_output",
23
  "render-images": "remotion render --enable-multiprocess-on-linux --sequence --image-format=jpeg $npm_config_composition $npm_config_output",
renderer.js CHANGED
@@ -4,13 +4,13 @@ import pkg from 'common-utils';
4
  import {exec} from 'child_process';
5
  import {dirname} from 'path';
6
  import {fileURLToPath} from 'url';
 
7
  const {UnzipFiles, Utils, ZipFiles} = pkg;
8
 
9
  const __filename = fileURLToPath(import.meta.url);
10
  const __dirname = dirname(__filename);
11
 
12
- export async function explodeUrl(fileUrl, jobId, dir) {
13
- const zipFile = `${dir}/exported-${jobId}.zip`;
14
  await Utils.downloadFile(fileUrl, zipFile, true);
15
  await UnzipFiles(zipFile, dir);
16
  }
@@ -38,15 +38,21 @@ export async function generateOutputBundle(jobId) {
38
  export function getNpmScript(mediaType) {
39
  if (mediaType === 'image') {
40
  return 'still';
41
- } else {
42
  return 'render';
 
 
43
  }
44
  }
45
 
46
  export function doRender(jobId, composition, sendToObserver, target = 'render') {
47
  const renderComposition = composition || 'SemibitComposition';
48
  let outFile = `out/${jobId}-video.mp4`;
49
- let cmd = `npm run render-build --target=${target} --composition=${renderComposition}`;
 
 
 
 
50
  const childProcess = exec(cmd);
51
 
52
  console.log('Starting video render. ' + cmd);
 
4
  import {exec} from 'child_process';
5
  import {dirname} from 'path';
6
  import {fileURLToPath} from 'url';
7
+ import { platform } from 'os';
8
  const {UnzipFiles, Utils, ZipFiles} = pkg;
9
 
10
  const __filename = fileURLToPath(import.meta.url);
11
  const __dirname = dirname(__filename);
12
 
13
+ export async function explodeUrl(fileUrl, jobId, dir, zipFile) {
 
14
  await Utils.downloadFile(fileUrl, zipFile, true);
15
  await UnzipFiles(zipFile, dir);
16
  }
 
38
  export function getNpmScript(mediaType) {
39
  if (mediaType === 'image') {
40
  return 'still';
41
+ } else if (!mediaType || mediaType === 'video') {
42
  return 'render';
43
+ } else {
44
+ return mediaType;
45
  }
46
  }
47
 
48
  export function doRender(jobId, composition, sendToObserver, target = 'render') {
49
  const renderComposition = composition || 'SemibitComposition';
50
  let outFile = `out/${jobId}-video.mp4`;
51
+ let script = 'render-build';
52
+ if (platform() == 'win32') {
53
+ script = `render-build:win32`
54
+ }
55
+ let cmd = `npm run ${script} --target=${target} --composition=${renderComposition}`;
56
  const childProcess = exec(cmd);
57
 
58
  console.log('Starting video render. ' + cmd);
routes.js CHANGED
@@ -13,6 +13,7 @@ import {fileURLToPath} from 'url';
13
  import pkg from 'common-utils';
14
  const {Utils, PerformanceRecorder, FileUploader, Vault} = pkg;
15
  import bodyParser from 'body-parser';
 
16
 
17
  const RenderRouter = Router();
18
  const __filename = fileURLToPath(import.meta.url);
@@ -50,14 +51,22 @@ RenderRouter.post('/api/render-sync', async (req, res) => {
50
  res.setHeader('X-Job-Id', jobId);
51
  res.setTimeout(0);
52
  res.setHeader('Connection', 'keep-alive');
53
- if (!skipClear) {
54
- clear();
55
- }
56
  let logs = [];
57
  try {
58
- async function run() {
59
  let pref = new PerformanceRecorder();
60
- await explodeUrl(fileUrl, jobId, path.join(__dirname, 'public'));
 
 
 
 
 
 
 
 
 
 
61
  let originalManuscript = Utils.readFileToObject(
62
  path.join(__dirname, `public/original_manuscript.json`)
63
  );
 
13
  import pkg from 'common-utils';
14
  const {Utils, PerformanceRecorder, FileUploader, Vault} = pkg;
15
  import bodyParser from 'body-parser';
16
+ import { existsSync } from 'fs';
17
 
18
  const RenderRouter = Router();
19
  const __filename = fileURLToPath(import.meta.url);
 
51
  res.setHeader('X-Job-Id', jobId);
52
  res.setTimeout(0);
53
  res.setHeader('Connection', 'keep-alive');
54
+
 
 
55
  let logs = [];
56
  try {
57
+ const run = async () => {
58
  let pref = new PerformanceRecorder();
59
+ const dir = path.join(__dirname, 'public')
60
+ const zipFile = `${dir}/exported-${jobId}.zip`;
61
+ if (!existsSync(zipFile)) {
62
+ if (!skipClear) {
63
+ clear();
64
+ }
65
+ await explodeUrl(fileUrl, jobId, dir, zipFile);
66
+ }
67
+ else {
68
+ console.log(`Job ${jobId} assets already exploded to public. Not downloading again.`)
69
+ }
70
  let originalManuscript = Utils.readFileToObject(
71
  path.join(__dirname, `public/original_manuscript.json`)
72
  );
src/GenerateScript.cjs ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ exports.GenerateScript = void 0;
7
+ var transitions_json_1 = __importDefault(require("../public/assets/transitions.json"));
8
+ var RenderUtils_1 = require("./RenderUtils.cjs");
9
+ var Categories_1 = require("./models/Categories.cjs");
10
+ function GenerateScript(Script) {
11
+ var _a, _b, _c, _d, _e, _f;
12
+ var fps = (_a = Script === null || Script === void 0 ? void 0 : Script.meta) === null || _a === void 0 ? void 0 : _a.fps;
13
+ if (!fps) {
14
+ Script.meta.fps = 24;
15
+ fps = 24;
16
+ }
17
+ var durationInSec = 0;
18
+ var lastDirection = false;
19
+ var preloadImages = [];
20
+ var preloadVideos = [];
21
+ var contents = Script.transcript
22
+ .sort(function (t, u) { return t.index - u.index; })
23
+ // .filter(item => (item.audioCaptionFile != undefined))
24
+ // .slice(0, 2)
25
+ .map(function (section, idx, array) {
26
+ section.index = section.index || idx;
27
+ var text = section.text, durationMilis = section.duration, offset = section.offset, mediaAbsPaths = section.mediaAbsPaths, mediaAbsPaths = section.mediaAbsPaths, audioFullPath = section.audioFullPath, title = section.title, pointers = section.pointers;
28
+ mediaAbsPaths = mediaAbsPaths || mediaAbsPaths || [];
29
+ if (!durationMilis) {
30
+ durationMilis = section.durationInSeconds * 1000;
31
+ }
32
+ if (!durationMilis)
33
+ durationMilis = 10e3;
34
+ // maybe required for youtube composition !!!
35
+ var curDurSecs = (durationMilis / 1e3);
36
+ if (curDurSecs < 3) {
37
+ curDurSecs = 3;
38
+ }
39
+ //@ts-ignore
40
+ var transitionFile = ((section === null || section === void 0 ? void 0 : section.transition_file) || transitions_json_1["default"][0].file);
41
+ var transition_type = (section === null || section === void 0 ? void 0 : section.transition_type);
42
+ if (transition_type && transition_type != 'none') {
43
+ section.transition_duration_sec = (section === null || section === void 0 ? void 0 : section.transition_duration_sec) || 0.5;
44
+ }
45
+ //@ts-ignore
46
+ var transitionDurationSec = ((section === null || section === void 0 ? void 0 : section.transition_duration_sec) || (transition_type && transition_type != 'none') ? 0.5 : 0);
47
+ var transitionDurationFrames = transitionDurationSec * fps;
48
+ var commDuration = durationInSec; //+ transitionDurationSec
49
+ durationInSec = durationInSec + curDurSecs; ///+ transitionDurationSec
50
+ lastDirection = !lastDirection;
51
+ mediaAbsPaths.forEach(function (p) {
52
+ var im = p.path;
53
+ if (im.startsWith("http")) {
54
+ if (im.indexOf("-video-") > -1 || im.indexOf(".mp4") > -1 || im.indexOf(".webm") > -1) {
55
+ preloadVideos.push(im);
56
+ // preloadVideo(im)
57
+ }
58
+ else {
59
+ preloadImages.push(im);
60
+ // preloadImage(im)
61
+ }
62
+ }
63
+ });
64
+ var bgImagePaths = mediaAbsPaths.map(function (p) {
65
+ p.path = RenderUtils_1.RenderUtils.getFileName(p === null || p === void 0 ? void 0 : p.path);
66
+ return p;
67
+ });
68
+ if (!offset) {
69
+ offset = commDuration;
70
+ }
71
+ var frame = Object.assign(section, {
72
+ "commulativeDurationStartSec": commDuration,
73
+ "text": text,
74
+ "transition_file": RenderUtils_1.RenderUtils.getFileName(transitionFile),
75
+ "durationInSecs": curDurSecs,
76
+ "duration": Math.ceil(curDurSecs * fps),
77
+ "offset": offset * fps,
78
+ "direction": lastDirection ? 'left' : 'right',
79
+ "bgImagePaths": bgImagePaths,
80
+ "audioPath": RenderUtils_1.RenderUtils.getFileName(audioFullPath),
81
+ "textColor": '#F44336',
82
+ "emphasisOnImage": (title === null || title === void 0 ? void 0 : title.length) > 0 && (pointers === null || pointers === void 0 ? void 0 : pointers.length) > 0 || Script.meta.emphasisOnImage
83
+ });
84
+ return frame;
85
+ });
86
+ console.log('contents', contents);
87
+ var intro = {
88
+ durationInFrames: 0,
89
+ durationInSec: 5.433,
90
+ file: Script.meta.tenantVideoConfig ? RenderUtils_1.RenderUtils.getFileName(Script.meta.tenantVideoConfig.introFile, "assets") : 'assets/music_intro.mp4'
91
+ };
92
+ var ADJUST_END_DUR_SEC = 3;
93
+ var outro = {
94
+ durationInFrames: 0,
95
+ durationInSec: 8.034 - ADJUST_END_DUR_SEC,
96
+ file: Script.meta.tenantVideoConfig ? RenderUtils_1.RenderUtils.getFileName(Script.meta.tenantVideoConfig.outroFile, "assets") : 'assets/music_outro.mp4'
97
+ };
98
+ if (intro && ((_c = (_b = Script === null || Script === void 0 ? void 0 : Script.meta) === null || _b === void 0 ? void 0 : _b.tenantVideoConfig) === null || _c === void 0 ? void 0 : _c.introFile)) {
99
+ durationInSec += intro.durationInSec;
100
+ intro.durationInFrames = Math.ceil(fps * intro.durationInSec);
101
+ }
102
+ if (outro && ((_e = (_d = Script === null || Script === void 0 ? void 0 : Script.meta) === null || _d === void 0 ? void 0 : _d.tenantVideoConfig) === null || _e === void 0 ? void 0 : _e.outroFile)) {
103
+ durationInSec += outro.durationInSec;
104
+ //hack for blank end
105
+ outro.durationInSec += 30;
106
+ outro.durationInFrames = Math.ceil(fps * outro.durationInSec);
107
+ }
108
+ // durationInSec = 10
109
+ var duration = Math.ceil(durationInSec * fps);
110
+ console.log("Total Video Duration", durationInSec);
111
+ //@ts-ignore
112
+ var playListsIDs = Categories_1.YoutubeCategoriesConfig.GET_PLAY_LIST_IDS(((_f = Script.meta) === null || _f === void 0 ? void 0 : _f.userId) || "104349087108535511186");
113
+ return {
114
+ Script: Script,
115
+ contents: contents,
116
+ playListsIDs: playListsIDs,
117
+ duration: duration,
118
+ outro: outro,
119
+ intro: intro
120
+ };
121
+ }
122
+ exports.GenerateScript = GenerateScript;
src/GenerateScript.js ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ exports.GenerateScript = void 0;
7
+ var transitions_json_1 = __importDefault(require("../public/assets/transitions.json"));
8
+ var RenderUtils_1 = require("./RenderUtils");
9
+ var Categories_1 = require("./models/Categories");
10
+ function GenerateScript(Script) {
11
+ var _a, _b, _c, _d, _e, _f;
12
+ var fps = (_a = Script === null || Script === void 0 ? void 0 : Script.meta) === null || _a === void 0 ? void 0 : _a.fps;
13
+ if (!fps) {
14
+ Script.meta.fps = 24;
15
+ fps = 24;
16
+ }
17
+ var durationInSec = 0;
18
+ var lastDirection = false;
19
+ var preloadImages = [];
20
+ var preloadVideos = [];
21
+ var contents = Script.transcript
22
+ .sort(function (t, u) { return t.index - u.index; })
23
+ // .filter(item => (item.audioCaptionFile != undefined))
24
+ // .slice(0, 2)
25
+ .map(function (section, idx, array) {
26
+ section.index = section.index || idx;
27
+ var text = section.text, durationMilis = section.duration, offset = section.offset, mediaAbsPaths = section.mediaAbsPaths, mediaAbsPaths = section.mediaAbsPaths, audioFullPath = section.audioFullPath, title = section.title, pointers = section.pointers;
28
+ mediaAbsPaths = mediaAbsPaths || mediaAbsPaths || [];
29
+ if (!durationMilis) {
30
+ durationMilis = section.durationInSeconds * 1000;
31
+ }
32
+ if (!durationMilis)
33
+ durationMilis = 10e3;
34
+ // maybe required for youtube composition !!!
35
+ var curDurSecs = (durationMilis / 1e3);
36
+ if (curDurSecs < 3) {
37
+ curDurSecs = 3;
38
+ }
39
+ //@ts-ignore
40
+ var transitionFile = ((section === null || section === void 0 ? void 0 : section.transition_file) || transitions_json_1["default"][0].file);
41
+ var transition_type = (section === null || section === void 0 ? void 0 : section.transition_type);
42
+ if (transition_type && transition_type != 'none') {
43
+ section.transition_duration_sec = (section === null || section === void 0 ? void 0 : section.transition_duration_sec) || 0.5;
44
+ }
45
+ //@ts-ignore
46
+ var transitionDurationSec = ((section === null || section === void 0 ? void 0 : section.transition_duration_sec) || (transition_type && transition_type != 'none') ? 0.5 : 0);
47
+ var transitionDurationFrames = transitionDurationSec * fps;
48
+ var commDuration = durationInSec; //+ transitionDurationSec
49
+ durationInSec = durationInSec + curDurSecs; ///+ transitionDurationSec
50
+ lastDirection = !lastDirection;
51
+ mediaAbsPaths.forEach(function (p) {
52
+ var im = p.path;
53
+ if (im.startsWith("http")) {
54
+ if (im.indexOf("-video-") > -1 || im.indexOf(".mp4") > -1 || im.indexOf(".webm") > -1) {
55
+ preloadVideos.push(im);
56
+ // preloadVideo(im)
57
+ }
58
+ else {
59
+ preloadImages.push(im);
60
+ // preloadImage(im)
61
+ }
62
+ }
63
+ });
64
+ var bgImagePaths = mediaAbsPaths.map(function (p) {
65
+ p.path = RenderUtils_1.RenderUtils.getFileName(p === null || p === void 0 ? void 0 : p.path);
66
+ return p;
67
+ });
68
+ if (!offset) {
69
+ offset = commDuration;
70
+ }
71
+ var frame = Object.assign(section, {
72
+ "commulativeDurationStartSec": commDuration,
73
+ "text": text,
74
+ "transition_file": RenderUtils_1.RenderUtils.getFileName(transitionFile),
75
+ "durationInSecs": curDurSecs,
76
+ "duration": Math.ceil(curDurSecs * fps),
77
+ "offset": offset * fps,
78
+ "direction": lastDirection ? 'left' : 'right',
79
+ "bgImagePaths": bgImagePaths,
80
+ "audioPath": RenderUtils_1.RenderUtils.getFileName(audioFullPath),
81
+ "textColor": '#F44336',
82
+ "emphasisOnImage": (title === null || title === void 0 ? void 0 : title.length) > 0 && (pointers === null || pointers === void 0 ? void 0 : pointers.length) > 0 || Script.meta.emphasisOnImage
83
+ });
84
+ return frame;
85
+ });
86
+ console.log('contents', contents);
87
+ var intro = {
88
+ durationInFrames: 0,
89
+ durationInSec: 5.433,
90
+ file: Script.meta.tenantVideoConfig ? RenderUtils_1.RenderUtils.getFileName(Script.meta.tenantVideoConfig.introFile, "assets") : 'assets/music_intro.mp4'
91
+ };
92
+ var ADJUST_END_DUR_SEC = 3;
93
+ var outro = {
94
+ durationInFrames: 0,
95
+ durationInSec: 8.034 - ADJUST_END_DUR_SEC,
96
+ file: Script.meta.tenantVideoConfig ? RenderUtils_1.RenderUtils.getFileName(Script.meta.tenantVideoConfig.outroFile, "assets") : 'assets/music_outro.mp4'
97
+ };
98
+ if (intro && ((_c = (_b = Script === null || Script === void 0 ? void 0 : Script.meta) === null || _b === void 0 ? void 0 : _b.tenantVideoConfig) === null || _c === void 0 ? void 0 : _c.introFile)) {
99
+ durationInSec += intro.durationInSec;
100
+ intro.durationInFrames = Math.ceil(fps * intro.durationInSec);
101
+ }
102
+ if (outro && ((_e = (_d = Script === null || Script === void 0 ? void 0 : Script.meta) === null || _d === void 0 ? void 0 : _d.tenantVideoConfig) === null || _e === void 0 ? void 0 : _e.outroFile)) {
103
+ durationInSec += outro.durationInSec;
104
+ //hack for blank end
105
+ outro.durationInSec += 30;
106
+ outro.durationInFrames = Math.ceil(fps * outro.durationInSec);
107
+ }
108
+ // durationInSec = 10
109
+ var duration = Math.ceil(durationInSec * fps);
110
+ console.log("Total Video Duration", durationInSec);
111
+ //@ts-ignore
112
+ var playListsIDs = Categories_1.YoutubeCategoriesConfig.GET_PLAY_LIST_IDS(((_f = Script.meta) === null || _f === void 0 ? void 0 : _f.userId) || "104349087108535511186");
113
+ return {
114
+ Script: Script,
115
+ contents: contents,
116
+ playListsIDs: playListsIDs,
117
+ duration: duration,
118
+ outro: outro,
119
+ intro: intro
120
+ };
121
+ }
122
+ exports.GenerateScript = GenerateScript;
src/GenerateScript.ts ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { OriginalManuscript } from 'common-utils'
2
+ import Transitions from '../public/assets/transitions.json'
3
+ import { RenderUtils } from './RenderUtils'
4
+ import { YoutubeCategoriesConfig } from './models/Categories'
5
+
6
+ export function GenerateScript(Script: OriginalManuscript) {
7
+
8
+ let fps = Script?.meta?.fps
9
+ if (!fps) {
10
+ Script.meta.fps = 24
11
+ fps = 24
12
+ }
13
+ var durationInSec = 0
14
+ var lastDirection = false;
15
+
16
+ let preloadImages = []
17
+ let preloadVideos = []
18
+
19
+ let contents =
20
+ Script.transcript
21
+ .sort((t, u) => t.index - u.index)
22
+ // .filter(item => (item.audioCaptionFile != undefined))
23
+ // .slice(0, 2)
24
+ .map((section, idx, array) => {
25
+ section.index = section.index || idx;
26
+ var { text, duration: durationMilis, offset, mediaAbsPaths, mediaAbsPaths, audioFullPath, title, pointers } = section
27
+ mediaAbsPaths = mediaAbsPaths || mediaAbsPaths || []
28
+ if (!durationMilis) {
29
+ durationMilis = section.durationInSeconds * 1000
30
+ }
31
+ if (!durationMilis)
32
+ durationMilis = 10e3
33
+ // maybe required for youtube composition !!!
34
+ let curDurSecs = (durationMilis / 1e3)
35
+ if (curDurSecs < 3) {
36
+ curDurSecs = 3
37
+ }
38
+ //@ts-ignore
39
+ const transitionFile = (section?.transition_file || Transitions[0].file)
40
+ const transition_type = (section?.transition_type)
41
+ if (transition_type && transition_type != 'none') {
42
+ section.transition_duration_sec = section?.transition_duration_sec || 0.5
43
+ }
44
+ //@ts-ignore
45
+ const transitionDurationSec = (section?.transition_duration_sec || (transition_type && transition_type != 'none') ? 0.5 : 0)
46
+ const transitionDurationFrames = transitionDurationSec * fps
47
+
48
+
49
+ let commDuration = durationInSec //+ transitionDurationSec
50
+ durationInSec = durationInSec + curDurSecs;///+ transitionDurationSec
51
+ lastDirection = !lastDirection
52
+ mediaAbsPaths.forEach(p => {
53
+ let im = p.path
54
+ if (im.startsWith("http")) {
55
+ if (im.indexOf("-video-") > -1 || im.indexOf(".mp4") > -1 || im.indexOf(".webm") > -1) {
56
+ preloadVideos.push(im)
57
+ // preloadVideo(im)
58
+ }
59
+ else {
60
+ preloadImages.push(im)
61
+ // preloadImage(im)
62
+ }
63
+ }
64
+ })
65
+ let bgImagePaths = mediaAbsPaths.map(p => {
66
+ p.path = RenderUtils.getFileName(p?.path)!!
67
+ return p
68
+ })
69
+ if (!offset) {
70
+ offset = commDuration
71
+ }
72
+ let frame = Object.assign(section, {
73
+ "commulativeDurationStartSec": commDuration,
74
+ "text": text,
75
+ "transition_file": RenderUtils.getFileName(transitionFile),
76
+ "durationInSecs": curDurSecs,
77
+ "duration": Math.ceil(curDurSecs * fps),
78
+ "offset": offset * fps,
79
+ "direction": lastDirection ? 'left' : 'right',
80
+ "bgImagePaths": bgImagePaths,
81
+ "audioPath": RenderUtils.getFileName(audioFullPath),
82
+ "textColor": '#F44336',
83
+ "emphasisOnImage": title?.length > 0 && pointers?.length > 0 || Script.meta.emphasisOnImage
84
+ })
85
+
86
+ return frame
87
+ })
88
+
89
+ console.log('contents', contents)
90
+ const intro = {
91
+ durationInFrames: 0,
92
+ durationInSec: 5.433,
93
+ file: Script.meta.tenantVideoConfig ? RenderUtils.getFileName(Script.meta.tenantVideoConfig.introFile, "assets") : 'assets/music_intro.mp4'
94
+ }
95
+ let ADJUST_END_DUR_SEC = 3
96
+ const outro = {
97
+ durationInFrames: 0,
98
+ durationInSec: 8.034 - ADJUST_END_DUR_SEC,
99
+ file: Script.meta.tenantVideoConfig ? RenderUtils.getFileName(Script.meta.tenantVideoConfig.outroFile, "assets") : 'assets/music_outro.mp4'
100
+ }
101
+
102
+ if (intro && Script?.meta?.tenantVideoConfig?.introFile) {
103
+ durationInSec += intro.durationInSec
104
+ intro.durationInFrames = Math.ceil(fps * intro.durationInSec)
105
+ }
106
+
107
+ if (outro && Script?.meta?.tenantVideoConfig?.outroFile) {
108
+ durationInSec += outro.durationInSec
109
+ //hack for blank end
110
+ outro.durationInSec += 30
111
+ outro.durationInFrames = Math.ceil(fps * outro.durationInSec)
112
+ }
113
+
114
+ // durationInSec = 10
115
+ const duration = Math.ceil(durationInSec * fps)
116
+ console.log("Total Video Duration", durationInSec)
117
+
118
+ //@ts-ignore
119
+ const playListsIDs = YoutubeCategoriesConfig.GET_PLAY_LIST_IDS(Script.meta?.userId || "104349087108535511186")
120
+
121
+ return {
122
+ Script,
123
+ contents,
124
+ playListsIDs,
125
+ duration,
126
+ outro,
127
+ intro
128
+ }
129
+ }
src/RenderUtils.cjs ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ exports.RenderUtils = void 0;
7
+ var lodash_1 = __importDefault(require("lodash"));
8
+ var remotion_1 = require("remotion");
9
+ function levenshteinDistance(str1, str2) {
10
+ var dp = Array.from({ length: str1.length + 1 }, function (_, i) { return [i]; });
11
+ for (var j = 1; j <= str2.length; j++) {
12
+ dp[0][j] = j;
13
+ }
14
+ for (var i = 1; i <= str1.length; i++) {
15
+ for (var j = 1; j <= str2.length; j++) {
16
+ var cost = str1[i - 1] === str2[j - 1] ? 0 : 1;
17
+ dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost);
18
+ }
19
+ }
20
+ return dp[str1.length][str2.length];
21
+ }
22
+ var RenderUtils = /** @class */ (function () {
23
+ function RenderUtils() {
24
+ }
25
+ RenderUtils.calculateDisplayMedia = function (item, durationInSeconds, frame, fps) {
26
+ var currentDisplayMedia = ((item === null || item === void 0 ? void 0 : item.mediaAbsPaths) || [])[0];
27
+ if (!lodash_1["default"].isEmpty(item === null || item === void 0 ? void 0 : item.mediaAbsPaths)) {
28
+ var frameOffest = 0;
29
+ for (var i = 0; i < (item === null || item === void 0 ? void 0 : item.mediaAbsPaths.length); i++) {
30
+ var media = item.mediaAbsPaths[i];
31
+ if (!media) {
32
+ return undefined;
33
+ }
34
+ media.idx = i;
35
+ media.startFrame = frameOffest;
36
+ if (media.durationSec == undefined) {
37
+ media.durationSec = durationInSeconds / (item === null || item === void 0 ? void 0 : item.mediaAbsPaths.length);
38
+ if (i == item.mediaAbsPaths.length - 1) {
39
+ media.durationSec = durationInSeconds;
40
+ }
41
+ }
42
+ media.durationFrames = media.durationSec * fps;
43
+ media.endFrame = frameOffest + media.durationFrames;
44
+ frameOffest = frameOffest + media.durationFrames;
45
+ if (frame > media.startFrame && frame < media.endFrame) {
46
+ currentDisplayMedia = media;
47
+ }
48
+ }
49
+ }
50
+ return currentDisplayMedia;
51
+ };
52
+ RenderUtils.tryStaticFile = function (file) {
53
+ try {
54
+ return (0, remotion_1.staticFile)(file);
55
+ }
56
+ catch (e) {
57
+ var fileName = RenderUtils.getFileName(file);
58
+ return (0, remotion_1.staticFile)(fileName);
59
+ }
60
+ };
61
+ RenderUtils.convertVHToPixels = function (vh) {
62
+ return Math.round(window.innerHeight * (parseInt(vh.replace("vh", "")) / 100));
63
+ };
64
+ RenderUtils.convertVWToPixels = function (vw) {
65
+ return Math.round(window.innerWidth * (parseInt(vw.replace("vw", "")) / 100));
66
+ };
67
+ RenderUtils.splitWordsIntoGroups = function (words) {
68
+ var groups = [];
69
+ var currentGroup = [];
70
+ for (var _i = 0, words_1 = words; _i < words_1.length; _i++) {
71
+ var word = words_1[_i];
72
+ if (currentGroup.length === 0) {
73
+ currentGroup.push(word);
74
+ }
75
+ else if (word.sentence_end) {
76
+ currentGroup.push(word);
77
+ groups.push(currentGroup);
78
+ currentGroup = [];
79
+ }
80
+ else if (currentGroup.length < 5) {
81
+ currentGroup.push(word);
82
+ }
83
+ else {
84
+ groups.push(currentGroup);
85
+ currentGroup = [word];
86
+ }
87
+ }
88
+ if (currentGroup.length > 0) {
89
+ groups.push(currentGroup);
90
+ }
91
+ // Ensure each group has a maximum of 5 words
92
+ var finalGroups = [];
93
+ for (var _a = 0, groups_1 = groups; _a < groups_1.length; _a++) {
94
+ var group = groups_1[_a];
95
+ while (group.length > 5) {
96
+ finalGroups.push(group.slice(0, 5));
97
+ group.splice(0, 5);
98
+ }
99
+ finalGroups.push(group);
100
+ }
101
+ return finalGroups === null || finalGroups === void 0 ? void 0 : finalGroups.map(function (group) {
102
+ return {
103
+ words: group,
104
+ start: undefined,
105
+ end: undefined
106
+ };
107
+ });
108
+ };
109
+ RenderUtils.findCurrentGroupByTime = function (timeSec, groups) {
110
+ var t = timeSec;
111
+ var wds = groups;
112
+ for (var i = 0; i < wds.length; i++) {
113
+ var x = wds[i];
114
+ if (x.start != undefined && x.end != undefined && (t >= x.start && t < x.end)) {
115
+ return x;
116
+ }
117
+ }
118
+ };
119
+ RenderUtils.findCurrentWord = function (timeSec, frames) {
120
+ var t = timeSec;
121
+ var wds = frames;
122
+ for (var i = 0; i < wds.length; i++) {
123
+ var x = wds[i];
124
+ if (x.start && x.end && (t >= x.start && t < x.end)) {
125
+ return x;
126
+ }
127
+ }
128
+ };
129
+ RenderUtils.randomElement = function (arr, seed) {
130
+ return arr[Math.floor((0, remotion_1.random)(seed || 1) * arr.length)];
131
+ };
132
+ RenderUtils.hashCode = function (s) {
133
+ return s.split("").reduce(function (a, b) {
134
+ a = ((a << 5) - a) + b.charCodeAt(0);
135
+ return a & a;
136
+ }, 0);
137
+ };
138
+ RenderUtils.splitArrayIntoChunks = function (arr, chunkSize) {
139
+ var chunkedArr = [];
140
+ for (var i = 0; i < arr.length; i += chunkSize) {
141
+ chunkedArr.push(arr.slice(i, i + chunkSize));
142
+ }
143
+ return chunkedArr;
144
+ };
145
+ RenderUtils.splitArray = function (arr, pieces) {
146
+ var result = [];
147
+ var chunkSize = Math.ceil(arr.length / pieces);
148
+ for (var i = 0, j = arr.length; i < j; i += chunkSize) {
149
+ result.push(arr.slice(i, i + chunkSize));
150
+ }
151
+ return result;
152
+ };
153
+ RenderUtils.getFileName = function (filePath, subdirpath) {
154
+ if (!filePath)
155
+ return undefined;
156
+ if (filePath.startsWith("http"))
157
+ return filePath;
158
+ // Always extract just the filename from any path
159
+ var match = filePath.match(/([^\/\\]+)$/);
160
+ var filename = match ? match[1] : '';
161
+ if (subdirpath) {
162
+ return subdirpath + "/" + filename;
163
+ }
164
+ else {
165
+ return filename;
166
+ }
167
+ };
168
+ RenderUtils.findMostSimilarString = function (inputString, stringArray) {
169
+ var minDistance = Number.MAX_SAFE_INTEGER;
170
+ var mostSimilarString = '';
171
+ stringArray.forEach(function (str) {
172
+ var distance = levenshteinDistance(inputString, str);
173
+ if (distance < minDistance) {
174
+ minDistance = distance;
175
+ mostSimilarString = str;
176
+ }
177
+ });
178
+ return mostSimilarString;
179
+ };
180
+ return RenderUtils;
181
+ }());
182
+ exports.RenderUtils = RenderUtils;
src/RenderUtils.js ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ exports.RenderUtils = void 0;
7
+ var lodash_1 = __importDefault(require("lodash"));
8
+ var remotion_1 = require("remotion");
9
+ function levenshteinDistance(str1, str2) {
10
+ var dp = Array.from({ length: str1.length + 1 }, function (_, i) { return [i]; });
11
+ for (var j = 1; j <= str2.length; j++) {
12
+ dp[0][j] = j;
13
+ }
14
+ for (var i = 1; i <= str1.length; i++) {
15
+ for (var j = 1; j <= str2.length; j++) {
16
+ var cost = str1[i - 1] === str2[j - 1] ? 0 : 1;
17
+ dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost);
18
+ }
19
+ }
20
+ return dp[str1.length][str2.length];
21
+ }
22
+ var RenderUtils = /** @class */ (function () {
23
+ function RenderUtils() {
24
+ }
25
+ RenderUtils.calculateDisplayMedia = function (item, durationInSeconds, frame, fps) {
26
+ var currentDisplayMedia = ((item === null || item === void 0 ? void 0 : item.mediaAbsPaths) || [])[0];
27
+ if (!lodash_1["default"].isEmpty(item === null || item === void 0 ? void 0 : item.mediaAbsPaths)) {
28
+ var frameOffest = 0;
29
+ for (var i = 0; i < (item === null || item === void 0 ? void 0 : item.mediaAbsPaths.length); i++) {
30
+ var media = item.mediaAbsPaths[i];
31
+ if (!media) {
32
+ return undefined;
33
+ }
34
+ media.idx = i;
35
+ media.startFrame = frameOffest;
36
+ if (media.durationSec == undefined) {
37
+ media.durationSec = durationInSeconds / (item === null || item === void 0 ? void 0 : item.mediaAbsPaths.length);
38
+ if (i == item.mediaAbsPaths.length - 1) {
39
+ media.durationSec = durationInSeconds;
40
+ }
41
+ }
42
+ media.durationFrames = media.durationSec * fps;
43
+ media.endFrame = frameOffest + media.durationFrames;
44
+ frameOffest = frameOffest + media.durationFrames;
45
+ if (frame > media.startFrame && frame < media.endFrame) {
46
+ currentDisplayMedia = media;
47
+ }
48
+ }
49
+ }
50
+ return currentDisplayMedia;
51
+ };
52
+ RenderUtils.tryStaticFile = function (file) {
53
+ try {
54
+ return (0, remotion_1.staticFile)(file);
55
+ }
56
+ catch (e) {
57
+ var fileName = RenderUtils.getFileName(file);
58
+ return (0, remotion_1.staticFile)(fileName);
59
+ }
60
+ };
61
+ RenderUtils.convertVHToPixels = function (vh) {
62
+ return Math.round(window.innerHeight * (parseInt(vh.replace("vh", "")) / 100));
63
+ };
64
+ RenderUtils.convertVWToPixels = function (vw) {
65
+ return Math.round(window.innerWidth * (parseInt(vw.replace("vw", "")) / 100));
66
+ };
67
+ RenderUtils.splitWordsIntoGroups = function (words) {
68
+ var groups = [];
69
+ var currentGroup = [];
70
+ for (var _i = 0, words_1 = words; _i < words_1.length; _i++) {
71
+ var word = words_1[_i];
72
+ if (currentGroup.length === 0) {
73
+ currentGroup.push(word);
74
+ }
75
+ else if (word.sentence_end) {
76
+ currentGroup.push(word);
77
+ groups.push(currentGroup);
78
+ currentGroup = [];
79
+ }
80
+ else if (currentGroup.length < 5) {
81
+ currentGroup.push(word);
82
+ }
83
+ else {
84
+ groups.push(currentGroup);
85
+ currentGroup = [word];
86
+ }
87
+ }
88
+ if (currentGroup.length > 0) {
89
+ groups.push(currentGroup);
90
+ }
91
+ // Ensure each group has a maximum of 5 words
92
+ var finalGroups = [];
93
+ for (var _a = 0, groups_1 = groups; _a < groups_1.length; _a++) {
94
+ var group = groups_1[_a];
95
+ while (group.length > 5) {
96
+ finalGroups.push(group.slice(0, 5));
97
+ group.splice(0, 5);
98
+ }
99
+ finalGroups.push(group);
100
+ }
101
+ return finalGroups === null || finalGroups === void 0 ? void 0 : finalGroups.map(function (group) {
102
+ return {
103
+ words: group,
104
+ start: undefined,
105
+ end: undefined
106
+ };
107
+ });
108
+ };
109
+ RenderUtils.findCurrentGroupByTime = function (timeSec, groups) {
110
+ var t = timeSec;
111
+ var wds = groups;
112
+ for (var i = 0; i < wds.length; i++) {
113
+ var x = wds[i];
114
+ if (x.start != undefined && x.end != undefined && (t >= x.start && t < x.end)) {
115
+ return x;
116
+ }
117
+ }
118
+ };
119
+ RenderUtils.findCurrentWord = function (timeSec, frames) {
120
+ var t = timeSec;
121
+ var wds = frames;
122
+ for (var i = 0; i < wds.length; i++) {
123
+ var x = wds[i];
124
+ if (x.start && x.end && (t >= x.start && t < x.end)) {
125
+ return x;
126
+ }
127
+ }
128
+ };
129
+ RenderUtils.randomElement = function (arr, seed) {
130
+ return arr[Math.floor((0, remotion_1.random)(seed || 1) * arr.length)];
131
+ };
132
+ RenderUtils.hashCode = function (s) {
133
+ return s.split("").reduce(function (a, b) {
134
+ a = ((a << 5) - a) + b.charCodeAt(0);
135
+ return a & a;
136
+ }, 0);
137
+ };
138
+ RenderUtils.splitArrayIntoChunks = function (arr, chunkSize) {
139
+ var chunkedArr = [];
140
+ for (var i = 0; i < arr.length; i += chunkSize) {
141
+ chunkedArr.push(arr.slice(i, i + chunkSize));
142
+ }
143
+ return chunkedArr;
144
+ };
145
+ RenderUtils.splitArray = function (arr, pieces) {
146
+ var result = [];
147
+ var chunkSize = Math.ceil(arr.length / pieces);
148
+ for (var i = 0, j = arr.length; i < j; i += chunkSize) {
149
+ result.push(arr.slice(i, i + chunkSize));
150
+ }
151
+ return result;
152
+ };
153
+ RenderUtils.getFileName = function (filePath, subdirpath) {
154
+ if (!filePath)
155
+ return undefined;
156
+ if (filePath.startsWith("http"))
157
+ return filePath;
158
+ // Always extract just the filename from any path
159
+ var match = filePath.match(/([^\/\\]+)$/);
160
+ var filename = match ? match[1] : '';
161
+ if (subdirpath) {
162
+ return subdirpath + "/" + filename;
163
+ }
164
+ else {
165
+ return filename;
166
+ }
167
+ };
168
+ RenderUtils.findMostSimilarString = function (inputString, stringArray) {
169
+ var minDistance = Number.MAX_SAFE_INTEGER;
170
+ var mostSimilarString = '';
171
+ stringArray.forEach(function (str) {
172
+ var distance = levenshteinDistance(inputString, str);
173
+ if (distance < minDistance) {
174
+ minDistance = distance;
175
+ mostSimilarString = str;
176
+ }
177
+ });
178
+ return mostSimilarString;
179
+ };
180
+ return RenderUtils;
181
+ }());
182
+ exports.RenderUtils = RenderUtils;
src/models/Categories.cjs ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ var _a, _b, _c;
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.YoutubeCategoriesConfig = void 0;
8
+ var path_1 = __importDefault(require("path"));
9
+ var PLAY_LIST_NAMES = {
10
+ SCIENCE_AND_TECHNOLOGY: 'Science & Technology',
11
+ AMAZING_UNIVERSE: 'The Amazing Universe: From Microbes to Galaxies',
12
+ HISTORY_AND_POLITICS: 'The Past is Present: Lessons from History and Politics',
13
+ CURRENT_AND_NEWS: 'Current Events & News Digest',
14
+ GADGET_REVIEWS: 'Gadget Reviews',
15
+ LAPTOP_REVIEWS: 'Laptop Reviews',
16
+ MOBILE_REVIEWS: 'Mobile Reviews',
17
+ RAD_TECH_TODAY: 'Rad Tech Today'
18
+ };
19
+ var INTRO_OUTRO_TENANT_CONFIG = {
20
+ "104349087108535511186": {
21
+ introFile: path_1["default"].join(__dirname, "../../public/assets/music_intro.mp4"),
22
+ outroFile: path_1["default"].join(__dirname, "../../public/assets/music_outro.mp4")
23
+ },
24
+ "116439292677772406470": {
25
+ introFile: path_1["default"].join(__dirname, "../../public/assets/music_techrads_intro.mp4"),
26
+ outroFile: path_1["default"].join(__dirname, "../../public/assets/music_techrads_outro.mp4")
27
+ }
28
+ };
29
+ var SOCIAL_HANDLES = {
30
+ INSTAGRAM: {
31
+ "104349087108535511186": 'semibit.media',
32
+ "116439292677772406470": 'tech.rads'
33
+ }
34
+ };
35
+ var ALL_TENANT_PLAYLISTS = {
36
+ "104349087108535511186": (_a = {},
37
+ _a[PLAY_LIST_NAMES.SCIENCE_AND_TECHNOLOGY] = 'PLeT-Kik6WdhQT35w5SVx1tUzM0L-U9aHy',
38
+ _a[PLAY_LIST_NAMES.AMAZING_UNIVERSE] = 'PLeT-Kik6WdhQJEnsI-QapmmjxEvZEXMQ2',
39
+ _a[PLAY_LIST_NAMES.HISTORY_AND_POLITICS] = 'PLeT-Kik6WdhSqoMh2dfnFpHaGTa-3PCBB',
40
+ _a[PLAY_LIST_NAMES.CURRENT_AND_NEWS] = 'PLeT-Kik6WdhTHl_RxwavJ3FXBGiXlYIxq',
41
+ _a),
42
+ "116439292677772406470": (_b = {},
43
+ _b[PLAY_LIST_NAMES.RAD_TECH_TODAY] = 'PLNGN7S9FgPhTFGUAhPdhdSJP5Jq0ljPqE',
44
+ _b[PLAY_LIST_NAMES.LAPTOP_REVIEWS] = 'PLNGN7S9FgPhSiWXNTZgoAKz9iu6zL12ox',
45
+ _b[PLAY_LIST_NAMES.MOBILE_REVIEWS] = 'PLNGN7S9FgPhQRQHOdrNXpVI_5CAT9-noa',
46
+ _b[PLAY_LIST_NAMES.GADGET_REVIEWS] = 'PLNGN7S9FgPhQflAC9FqdIm7_BtLWOCDHa',
47
+ _b)
48
+ };
49
+ var GET_PLAY_LIST_IDS = function (userId) {
50
+ var playlists = ALL_TENANT_PLAYLISTS[userId] || ALL_TENANT_PLAYLISTS['104349087108535511186'];
51
+ return playlists;
52
+ };
53
+ var YOUTUBE_VIDEO_CATEGORY_ID = (_c = {},
54
+ _c[PLAY_LIST_NAMES.SCIENCE_AND_TECHNOLOGY] = "28",
55
+ _c[PLAY_LIST_NAMES.AMAZING_UNIVERSE] = "28",
56
+ _c[PLAY_LIST_NAMES.HISTORY_AND_POLITICS] = "27",
57
+ _c[PLAY_LIST_NAMES.CURRENT_AND_NEWS] = "25",
58
+ _c[PLAY_LIST_NAMES.RAD_TECH_TODAY] = "28",
59
+ _c[PLAY_LIST_NAMES.LAPTOP_REVIEWS] = "28",
60
+ _c[PLAY_LIST_NAMES.MOBILE_REVIEWS] = "28",
61
+ _c[PLAY_LIST_NAMES.GADGET_REVIEWS] = "28",
62
+ _c);
63
+ exports.YoutubeCategoriesConfig = {
64
+ PLAY_LIST_NAMES: PLAY_LIST_NAMES,
65
+ ALL_TENANT_PLAYLISTS: ALL_TENANT_PLAYLISTS,
66
+ GET_PLAY_LIST_IDS: GET_PLAY_LIST_IDS,
67
+ YOUTUBE_VIDEO_CATEGORY_ID: YOUTUBE_VIDEO_CATEGORY_ID,
68
+ INTRO_OUTRO_TENANT_CONFIG: INTRO_OUTRO_TENANT_CONFIG,
69
+ SOCIAL_HANDLES: SOCIAL_HANDLES
70
+ };
src/models/Categories.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ var _a, _b, _c;
6
+ exports.__esModule = true;
7
+ exports.YoutubeCategoriesConfig = void 0;
8
+ var path_1 = __importDefault(require("path"));
9
+ var PLAY_LIST_NAMES = {
10
+ SCIENCE_AND_TECHNOLOGY: 'Science & Technology',
11
+ AMAZING_UNIVERSE: 'The Amazing Universe: From Microbes to Galaxies',
12
+ HISTORY_AND_POLITICS: 'The Past is Present: Lessons from History and Politics',
13
+ CURRENT_AND_NEWS: 'Current Events & News Digest',
14
+ GADGET_REVIEWS: 'Gadget Reviews',
15
+ LAPTOP_REVIEWS: 'Laptop Reviews',
16
+ MOBILE_REVIEWS: 'Mobile Reviews',
17
+ RAD_TECH_TODAY: 'Rad Tech Today'
18
+ };
19
+ var INTRO_OUTRO_TENANT_CONFIG = {
20
+ "104349087108535511186": {
21
+ introFile: path_1["default"].join(__dirname, "../../public/assets/music_intro.mp4"),
22
+ outroFile: path_1["default"].join(__dirname, "../../public/assets/music_outro.mp4")
23
+ },
24
+ "116439292677772406470": {
25
+ introFile: path_1["default"].join(__dirname, "../../public/assets/music_techrads_intro.mp4"),
26
+ outroFile: path_1["default"].join(__dirname, "../../public/assets/music_techrads_outro.mp4")
27
+ }
28
+ };
29
+ var SOCIAL_HANDLES = {
30
+ INSTAGRAM: {
31
+ "104349087108535511186": 'semibit.media',
32
+ "116439292677772406470": 'tech.rads'
33
+ }
34
+ };
35
+ var ALL_TENANT_PLAYLISTS = {
36
+ "104349087108535511186": (_a = {},
37
+ _a[PLAY_LIST_NAMES.SCIENCE_AND_TECHNOLOGY] = 'PLeT-Kik6WdhQT35w5SVx1tUzM0L-U9aHy',
38
+ _a[PLAY_LIST_NAMES.AMAZING_UNIVERSE] = 'PLeT-Kik6WdhQJEnsI-QapmmjxEvZEXMQ2',
39
+ _a[PLAY_LIST_NAMES.HISTORY_AND_POLITICS] = 'PLeT-Kik6WdhSqoMh2dfnFpHaGTa-3PCBB',
40
+ _a[PLAY_LIST_NAMES.CURRENT_AND_NEWS] = 'PLeT-Kik6WdhTHl_RxwavJ3FXBGiXlYIxq',
41
+ _a),
42
+ "116439292677772406470": (_b = {},
43
+ _b[PLAY_LIST_NAMES.RAD_TECH_TODAY] = 'PLNGN7S9FgPhTFGUAhPdhdSJP5Jq0ljPqE',
44
+ _b[PLAY_LIST_NAMES.LAPTOP_REVIEWS] = 'PLNGN7S9FgPhSiWXNTZgoAKz9iu6zL12ox',
45
+ _b[PLAY_LIST_NAMES.MOBILE_REVIEWS] = 'PLNGN7S9FgPhQRQHOdrNXpVI_5CAT9-noa',
46
+ _b[PLAY_LIST_NAMES.GADGET_REVIEWS] = 'PLNGN7S9FgPhQflAC9FqdIm7_BtLWOCDHa',
47
+ _b)
48
+ };
49
+ var GET_PLAY_LIST_IDS = function (userId) {
50
+ var playlists = ALL_TENANT_PLAYLISTS[userId] || ALL_TENANT_PLAYLISTS['104349087108535511186'];
51
+ return playlists;
52
+ };
53
+ var YOUTUBE_VIDEO_CATEGORY_ID = (_c = {},
54
+ _c[PLAY_LIST_NAMES.SCIENCE_AND_TECHNOLOGY] = "28",
55
+ _c[PLAY_LIST_NAMES.AMAZING_UNIVERSE] = "28",
56
+ _c[PLAY_LIST_NAMES.HISTORY_AND_POLITICS] = "27",
57
+ _c[PLAY_LIST_NAMES.CURRENT_AND_NEWS] = "25",
58
+ _c[PLAY_LIST_NAMES.RAD_TECH_TODAY] = "28",
59
+ _c[PLAY_LIST_NAMES.LAPTOP_REVIEWS] = "28",
60
+ _c[PLAY_LIST_NAMES.MOBILE_REVIEWS] = "28",
61
+ _c[PLAY_LIST_NAMES.GADGET_REVIEWS] = "28",
62
+ _c);
63
+ exports.YoutubeCategoriesConfig = {
64
+ PLAY_LIST_NAMES: PLAY_LIST_NAMES,
65
+ ALL_TENANT_PLAYLISTS: ALL_TENANT_PLAYLISTS,
66
+ GET_PLAY_LIST_IDS: GET_PLAY_LIST_IDS,
67
+ YOUTUBE_VIDEO_CATEGORY_ID: YOUTUBE_VIDEO_CATEGORY_ID,
68
+ INTRO_OUTRO_TENANT_CONFIG: INTRO_OUTRO_TENANT_CONFIG,
69
+ SOCIAL_HANDLES: SOCIAL_HANDLES
70
+ };
src/webpack-override.ts CHANGED
@@ -2,5 +2,28 @@ import { enableTailwind } from '@remotion/tailwind';
2
  import { WebpackOverrideFn } from '@remotion/bundler';
3
 
4
  export const webpackOverride: WebpackOverrideFn = (currentConfiguration) => {
5
- return enableTailwind(currentConfiguration);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  };
 
2
  import { WebpackOverrideFn } from '@remotion/bundler';
3
 
4
  export const webpackOverride: WebpackOverrideFn = (currentConfiguration) => {
5
+ const config = enableTailwind(currentConfiguration);
6
+
7
+ // Disable minification so symbols and names are preserved for debugging
8
+ config.optimization = config.optimization || {};
9
+ config.optimization.minimize = false;
10
+
11
+ // Remove any minimizers (e.g., Terser) if present
12
+ if (Array.isArray(config.optimization.minimizer)) {
13
+ config.optimization.minimizer.length = 0;
14
+ }
15
+
16
+ // Keep readable module/chunk ids so stack traces and names are preserved
17
+ // (supported values: 'named' or 'deterministic' / 'size' etc.)
18
+ config.optimization.moduleIds = 'named';
19
+ config.optimization.chunkIds = 'named';
20
+
21
+ // Emit full source maps for better debugging
22
+ config.devtool = config.devtool || 'source-map';
23
+
24
+ // Include path info in the output for easier inspection
25
+ config.output = config.output || {};
26
+ config.output.pathinfo = true;
27
+
28
+ return config;
29
  };
test-render.cjs ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { renderFrames, renderStill } = require('@remotion/renderer');
2
+ const { bundle } = require('@remotion/bundler');
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+
6
+ const { RenderUtils } = require('./src/RenderUtils.cjs')
7
+ const { GenerateScript } = require('./src/GenerateScript.cjs')
8
+
9
+ //npx tsc src/GenerateScript.ts --module commonjs --outDir build --esModuleInterop --declaration false
10
+ const entry = path.join(process.cwd(), 'src/index.ts'); // your Remotion entry file
11
+ const originalManuScriptPath = path.join(process.cwd(), 'public/original_manuscript.json');
12
+ const compositionId = 'IGReelComposition';
13
+ const outputDir = path.join(process.cwd(), 'out');
14
+ const bundleLocation = path.join(process.cwd(), 'build');
15
+ (async () => {
16
+ const ScriptStr = fs.readFileSync(originalManuScriptPath);
17
+ const ScriptInput = JSON.parse(ScriptStr);
18
+ const {
19
+ duration,
20
+ Script,
21
+ contents,
22
+ intro,
23
+ outro,
24
+ playListsIDs
25
+ } = GenerateScript(ScriptInput)
26
+ let renderConfig = {
27
+ composition: {
28
+ id: compositionId,
29
+ fps: Script.meta.fps,
30
+ height: Script.meta?.resolution?.height,
31
+ width: Script.meta?.resolution?.width,
32
+ durationInFrames: 1,
33
+ defaultProps: Object.assign(Script, {
34
+ bgMusic: RenderUtils.getFileName(Script.bgMusic),
35
+ contents: contents,
36
+ intro: intro,
37
+ outro: outro
38
+ }),
39
+ props: Object.assign(Script, {
40
+ bgMusic: RenderUtils.getFileName(Script.bgMusic),
41
+ contents: contents,
42
+ intro: intro,
43
+ outro: outro
44
+ }),
45
+ },
46
+ serveUrl: bundleLocation,
47
+ output: path.join(outputDir, 'output.jpg')
48
+ }
49
+ await renderStill(renderConfig);
50
+ })();