shiveshnavin commited on
Commit
9f800de
·
1 Parent(s): 10f65be

Added import of file

Browse files
.gitignore CHANGED
@@ -2,6 +2,11 @@ node_modules
2
  dist
3
  .DS_Store
4
  .env
5
-
6
  # Ignore the output video from Git but not videos you import into src/.
7
  out
 
 
 
 
 
 
2
  dist
3
  .DS_Store
4
  .env
5
+ @@export_177ba1326b.zip
6
  # Ignore the output video from Git but not videos you import into src/.
7
  out
8
+
9
+ public/
10
+ **.zip
11
+ yarn.lock
12
+ package-lock.json
.vscode/launch.json CHANGED
@@ -2,11 +2,24 @@
2
  "version": "0.2.0",
3
  "configurations": [
4
  {
5
- "name": "Launch via NPM",
6
  "request": "launch",
7
  "runtimeArgs": [
8
  "run-script",
9
- "render-build"
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  ],
11
  "runtimeExecutable": "npm",
12
  "skipFiles": [
 
2
  "version": "0.2.0",
3
  "configurations": [
4
  {
5
+ "name": "Server",
6
  "request": "launch",
7
  "runtimeArgs": [
8
  "run-script",
9
+ "start"
10
+ ],
11
+ "runtimeExecutable": "npm",
12
+ "skipFiles": [
13
+ "<node_internals>/**"
14
+ ],
15
+ "type": "node"
16
+ },
17
+ {
18
+ "name": "Render",
19
+ "request": "launch",
20
+ "runtimeArgs": [
21
+ "run-script",
22
+ "render-preview"
23
  ],
24
  "runtimeExecutable": "npm",
25
  "skipFiles": [
package-lock.json CHANGED
The diff for this file is too large to render. See raw diff
 
package.json CHANGED
@@ -6,10 +6,10 @@
6
  "*.css"
7
  ],
8
  "scripts": {
9
- "render-preview": "remotion preview src/index.ts",
 
10
  "render-build": "remotion render SemibitComposition ",
11
  "render-still": "remotion still --image-format=jpeg SemibitCompositionPoster ",
12
- "start": "remotion studio",
13
  "build": "remotion render --image-format=jpeg --quality=70 --gl=angle SemibitComposition ",
14
  "upgrade": "remotion upgrade",
15
  "test": "eslint src --ext ts,tsx,js,jsx && tsc"
@@ -24,32 +24,33 @@
24
  }
25
  },
26
  "dependencies": {
27
- "@remotion/bundler": "4.0.12",
28
- "@remotion/cli": "4.0.12",
29
- "@remotion/google-fonts": "^4.0.12",
30
- "@remotion/noise": "^4.0.12",
31
- "@remotion/zod-types": "4.0.12",
 
32
  "path": "^0.12.7",
33
  "react": "^18.0.0",
34
  "react-dom": "^18.0.0",
35
- "remotion": "4.0.12",
36
  "remotion-animated": "^2.0.0",
37
  "remotion-transition-series": "^0.0.10",
38
  "styled-components": "^6.0.5",
 
39
  "zod": "^3.21.4"
40
  },
41
  "devDependencies": {
42
- "@remotion/cli": "4.0.12",
43
- "@remotion/eslint-config": "4.0.12",
44
- "@remotion/tailwind": "4.0.12",
45
  "@types/react": "^18.0.26",
46
  "@types/web": "^0.0.86",
47
  "eslint": "^8.43.0",
48
  "prettier": "^2.8.8",
49
  "react": "^18.0.0",
50
  "react-dom": "^18.0.0",
51
- "remotion": "4.0.12",
52
  "typescript": "^4.9.4"
53
  },
54
  "packageManager": "npm@8.19.4"
55
- }
 
6
  "*.css"
7
  ],
8
  "scripts": {
9
+ "start": "ts-node-dev --respawn --transpile-only server.ts",
10
+ "render-preview": "remotion studio",
11
  "render-build": "remotion render SemibitComposition ",
12
  "render-still": "remotion still --image-format=jpeg SemibitCompositionPoster ",
 
13
  "build": "remotion render --image-format=jpeg --quality=70 --gl=angle SemibitComposition ",
14
  "upgrade": "remotion upgrade",
15
  "test": "eslint src --ext ts,tsx,js,jsx && tsc"
 
24
  }
25
  },
26
  "dependencies": {
27
+ "@remotion/bundler": "4.0.17",
28
+ "@remotion/google-fonts": "4.0.17",
29
+ "@remotion/noise": "4.0.17",
30
+ "@remotion/zod-types": "4.0.17",
31
+ "body-parser": "^1.20.2",
32
+ "express": "^4.18.2",
33
  "path": "^0.12.7",
34
  "react": "^18.0.0",
35
  "react-dom": "^18.0.0",
 
36
  "remotion-animated": "^2.0.0",
37
  "remotion-transition-series": "^0.0.10",
38
  "styled-components": "^6.0.5",
39
+ "ts-node-dev": "^2.0.0",
40
  "zod": "^3.21.4"
41
  },
42
  "devDependencies": {
43
+ "@remotion/cli": "4.0.17",
44
+ "@remotion/eslint-config": "4.0.17",
45
+ "@remotion/tailwind": "4.0.17",
46
  "@types/react": "^18.0.26",
47
  "@types/web": "^0.0.86",
48
  "eslint": "^8.43.0",
49
  "prettier": "^2.8.8",
50
  "react": "^18.0.0",
51
  "react-dom": "^18.0.0",
52
+ "remotion": "4.0.17",
53
  "typescript": "^4.9.4"
54
  },
55
  "packageManager": "npm@8.19.4"
56
+ }
server.ts CHANGED
@@ -3,8 +3,11 @@ import express from 'express'
3
  import stream from 'stream'
4
  import bodyParser from 'body-parser';
5
  import { spawn } from 'child_process';
6
- import { unlinkSync, existsSync } from 'fs'
7
  import path from 'path'
 
 
 
8
 
9
  let pl = {
10
  onLog: console.log
@@ -18,8 +21,8 @@ function render() {
18
 
19
  return new Promise((resolve, reject) => {
20
 
21
- if (existsSync(outputFile)) {
22
- unlinkSync(outputFile)
23
  }
24
  const SEMIBI_MEDIA_RENDERER = "../semibit-media-render-farm"
25
  const options = {
@@ -73,3 +76,77 @@ function render() {
73
 
74
  })
75
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  import stream from 'stream'
4
  import bodyParser from 'body-parser';
5
  import { spawn } from 'child_process';
6
+ import fs from 'fs'
7
  import path from 'path'
8
+ import { Utils } from './common-utils';
9
+ import { UnzipFiles } from './common-utils/utils/FileZipper';
10
+ import { OriginalManuscript } from './src/OriginalManuscriptModel';
11
 
12
  let pl = {
13
  onLog: console.log
 
21
 
22
  return new Promise((resolve, reject) => {
23
 
24
+ if (fs.existsSync(outputFile)) {
25
+ fs.unlinkSync(outputFile)
26
  }
27
  const SEMIBI_MEDIA_RENDERER = "../semibit-media-render-farm"
28
  const options = {
 
76
 
77
  })
78
  }
79
+
80
+
81
+ function modifyFiles(originalManuscript: OriginalManuscript) {
82
+
83
+ let fname = path.join(__dirname, "./src/textWithBgImage/SequentialScene.orig.tsx")
84
+ let fnameTarget = path.join(__dirname, "./src/textWithBgImage/SequentialScene.tsx")
85
+ let SequentialSceneText = fs.readFileSync(fname).toString()
86
+ let seqScene = "";
87
+ let script = originalManuscript.transcript
88
+ for (let index = 0; index < script.length; index++) {
89
+ seqScene = seqScene + `\n{getScene(contents[${index}])}\n`
90
+ }
91
+ fs.writeFileSync(fnameTarget, SequentialSceneText.replace("{getScene(contents[0])}", seqScene));
92
+
93
+ }
94
+ async function extract(filePath: string) {
95
+ await UnzipFiles(filePath, './public')
96
+ }
97
+
98
+ const app = express()
99
+ app.all('/clear', async (req, res) => {
100
+ let cacheDirPath = path.join(__dirname, "./public")
101
+ fs.readdirSync(cacheDirPath).forEach(file => {
102
+ const filePath = path.join(cacheDirPath, file);
103
+ if (fs.statSync(filePath).isDirectory()) {
104
+ if (file !== "assets") {
105
+
106
+ }
107
+ } else {
108
+ if (path.basename(path.dirname(filePath)) !== "assets") {
109
+ fs.unlinkSync(filePath);
110
+ }
111
+ }
112
+ });
113
+ res.send("Cache Cleared")
114
+ })
115
+ app.all('/render', async (req, res) => {
116
+ let fileUrl = req.query.fileUrl
117
+ let skipRender = req.query.skipRender
118
+ let fileName = Utils.getFileName(fileUrl)
119
+ let filePath = req.query.filePath || path.join(__dirname, `public/${fileName}`)
120
+ if (fileUrl) {
121
+ console.log('Downloading remote asset bundle from', fileUrl)
122
+ await Utils.downloadFile(fileUrl, filePath)
123
+ console.log('Downloaded remote asset bundle', 'to', filePath)
124
+ }
125
+ if (fs.existsSync(filePath)) {
126
+ await extract(filePath)
127
+ let manuFile = path.join(__dirname, `public/original_manuscript.json`)
128
+ if (!fs.existsSync) {
129
+ res.status(400)
130
+ res.send({
131
+ message: 'The asset bundle dosent contain a original_manuscript.json at root'
132
+ })
133
+ }
134
+ let manuObj: OriginalManuscript = JSON.parse(fs.readFileSync(manuFile).toString())
135
+ modifyFiles(manuObj)
136
+
137
+ res.send({
138
+ job_id: manuObj.id
139
+ })
140
+ }
141
+ else {
142
+ res.status(400)
143
+ return res.send({ message: 'Unable to locate asset bundle' })
144
+ }
145
+ })
146
+
147
+
148
+
149
+ let port = process.env.PORT || 8083
150
+ app.listen(port, () => {
151
+ console.log("Remote renderer listenting at port", port)
152
+ })
src/OriginalManuscriptModel.ts ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export interface OriginalManuscript {
2
+ id: string;
3
+ bgMusic: string
4
+ status: boolean
5
+ transcriptText: string
6
+ transcript: Transcript[]
7
+ wordCount: number
8
+ outputFile: string
9
+ meta: Meta
10
+ }
11
+
12
+ export interface Transcript {
13
+ title: string
14
+ text: string
15
+ pointers: string[]
16
+ imageText: string[]
17
+ videoText: string[]
18
+ dialog: string[]
19
+ imageAbsPathsOriginal: string[]
20
+ index: number
21
+ status: boolean
22
+ imageAbsPaths: string[]
23
+ audioFullPath: string
24
+ durationInSeconds: number
25
+ duration: number
26
+ offset: number
27
+ }
28
+
29
+ export interface Meta {
30
+ filesRootDir: string
31
+ posterTitle: string
32
+ summary: string
33
+ tags: string
34
+ title: string
35
+ posterImage: string
36
+ countLeft: number
37
+ amazonAffiliateLink: string
38
+ platlistName: string
39
+ platlistId: string
40
+ userId: string
41
+ sourceVariantName: string
42
+ emphasisOnImage: boolean
43
+ speaker: Speaker
44
+ script_mode: string
45
+ fps: number
46
+ tenantVideoConfig: TenantVideoConfig
47
+ manuscriptFile: string
48
+ thumbnailFile: string
49
+ }
50
+
51
+ export interface Speaker {
52
+ wps: number
53
+ }
54
+
55
+ export interface TenantVideoConfig {
56
+ introFile: string
57
+ outroFile: string
58
+ }
src/textWithBgImage/SequentialScene.orig.tsx CHANGED
@@ -2,6 +2,7 @@ import { Composition, delayRender, continueRender, staticFile, Sequence, Series,
2
  import { getVideoMetadata } from "@remotion/media-utils";
3
  import React, { useEffect, useState } from 'react'
4
  import { SingleTextWithBG } from './SingleTextWithBG';
 
5
 
6
  export type SequentialSceneData = {
7
  text: string,
@@ -19,7 +20,7 @@ function getScene(data) {
19
  <Series.Sequence
20
  durationInFrames={data?.duration || 30} >
21
 
22
- <SingleTextWithBG
23
  {...data}
24
  />
25
  </Series.Sequence>
 
2
  import { getVideoMetadata } from "@remotion/media-utils";
3
  import React, { useEffect, useState } from 'react'
4
  import { SingleTextWithBG } from './SingleTextWithBG';
5
+ import { SectionTextWithBG } from './SectionTextWithBG';
6
 
7
  export type SequentialSceneData = {
8
  text: string,
 
20
  <Series.Sequence
21
  durationInFrames={data?.duration || 30} >
22
 
23
+ <SectionTextWithBG
24
  {...data}
25
  />
26
  </Series.Sequence>
src/textWithBgImage/SequentialScene.tsx CHANGED
@@ -14,15 +14,14 @@ export type SequentialSceneData = {
14
  direction?: string
15
  }
16
 
17
- function getScene(data, props?) {
18
 
19
- let newProps = { ...data, rootProps: props }
20
  return (
21
  <Series.Sequence
22
  durationInFrames={data?.duration || 30} >
23
 
24
  <SectionTextWithBG
25
- {...newProps}
26
  />
27
  </Series.Sequence>
28
  )
@@ -34,7 +33,6 @@ export const SequentialScene: React.FC = (
34
 
35
  const contents = props.contents
36
  const bgMusic = props.bgMusic
37
- const meta = props.meta
38
 
39
  return (
40
  <div>
@@ -53,10 +51,18 @@ export const SequentialScene: React.FC = (
53
  }
54
 
55
 
 
 
56
 
57
- {getScene(contents[0], props)}
58
 
59
- {getScene(contents[1], props)}
 
 
 
 
 
 
60
 
61
 
62
 
 
14
  direction?: string
15
  }
16
 
17
+ function getScene(data) {
18
 
 
19
  return (
20
  <Series.Sequence
21
  durationInFrames={data?.duration || 30} >
22
 
23
  <SectionTextWithBG
24
+ {...data}
25
  />
26
  </Series.Sequence>
27
  )
 
33
 
34
  const contents = props.contents
35
  const bgMusic = props.bgMusic
 
36
 
37
  return (
38
  <div>
 
51
  }
52
 
53
 
54
+
55
+ {getScene(contents[0])}
56
 
57
+ {getScene(contents[1])}
58
 
59
+ {getScene(contents[2])}
60
+
61
+ {getScene(contents[3])}
62
+
63
+ {getScene(contents[4])}
64
+
65
+ {getScene(contents[5])}
66
 
67
 
68
 
tsconfig.json CHANGED
@@ -7,6 +7,7 @@
7
  "outDir": "./dist",
8
  "strict": true,
9
  "noEmit": true,
 
10
  "lib": [
11
  "es2015"
12
  ],
 
7
  "outDir": "./dist",
8
  "strict": true,
9
  "noEmit": true,
10
+ "noEmitOnError": false,
11
  "lib": [
12
  "es2015"
13
  ],