Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
begenieus-jobs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ramdayal Munda
begenieus-jobs
Commits
685ede17
Commit
685ede17
authored
Mar 07, 2024
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small size image handling to stretch fixed
parent
e7fa9a7b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
tutor-shot.js
controller/tutor-shot.js
+13
-2
tutor-shot.js
helper/tutor-shot.js
+1
-1
No files found.
controller/tutor-shot.js
View file @
685ede17
...
@@ -14,7 +14,9 @@ const CONFIG = require("../config.js")
...
@@ -14,7 +14,9 @@ const CONFIG = require("../config.js")
const
socket
=
require
(
"../socket.js"
)
const
socket
=
require
(
"../socket.js"
)
module
.
exports
.
generateVideo
=
async
function
(
req
,
res
)
{
module
.
exports
.
generateVideo
=
async
function
(
req
,
res
)
{
let
uid
;
let
_id
let
filesCreated
=
[]
try
{
try
{
let
tutorShotData
=
req
.
body
.
tutorShotData
;
let
tutorShotData
=
req
.
body
.
tutorShotData
;
let
videoPath
;
// local path of the video file
let
videoPath
;
// local path of the video file
...
@@ -24,6 +26,8 @@ module.exports.generateVideo = async function (req, res) {
...
@@ -24,6 +26,8 @@ module.exports.generateVideo = async function (req, res) {
let
updatedData
;
let
updatedData
;
if
(
tutorShotData
)
{
if
(
tutorShotData
)
{
uid
=
tutorShotData
.
uid
_id
=
tutorShotData
.
_id
let
socketPayload
=
{
let
socketPayload
=
{
uid
:
tutorShotData
.
uid
,
uid
:
tutorShotData
.
uid
,
task
:
"Video Generation"
,
task
:
"Video Generation"
,
...
@@ -58,22 +62,25 @@ module.exports.generateVideo = async function (req, res) {
...
@@ -58,22 +62,25 @@ module.exports.generateVideo = async function (req, res) {
],
],
{
{
outputType
:
"buffer"
,
outputType
:
"buffer"
,
dimension
:
tutorShotData
.
segments
[
i
].
dimension
}
}
)
)
let
limit
=
24
*
((
tutorShotData
.
segments
[
i
]?.
duration
)
?
(
tutorShotData
.
segments
[
i
].
duration
)
:
2
);
let
limit
=
24
*
((
tutorShotData
.
segments
[
i
]?.
duration
)
?
(
tutorShotData
.
segments
[
i
].
duration
)
:
2
);
let
frameNum
=
0
let
frameNum
=
0
let
firstImage
=
path
.
join
(
imageDir
,
`
${
tutorShotData
.
_id
}
_
${
frameNumber
++
}
.png`
)
let
firstImage
=
path
.
join
(
imageDir
,
`
${
tutorShotData
.
_id
}
_
${
frameNumber
++
}
.png`
)
await
sharp
(
mergedImage
).
toFile
(
firstImage
)
await
sharp
(
mergedImage
).
toFile
(
firstImage
)
imageArr
.
push
(
firstImage
)
imageArr
.
push
(
firstImage
)
filesCreated
.
push
(
firstImage
)
do
{
do
{
let
fileName
=
path
.
join
(
imageDir
,
`
${
tutorShotData
.
_id
}
_
${
frameNumber
++
}
.png`
)
let
fileName
=
path
.
join
(
imageDir
,
`
${
tutorShotData
.
_id
}
_
${
frameNumber
++
}
.png`
)
imageArr
.
push
(
fileName
)
imageArr
.
push
(
fileName
)
filesCreated
.
push
(
fileName
)
fs
.
copyFileSync
(
firstImage
,
fileName
)
fs
.
copyFileSync
(
firstImage
,
fileName
)
}
while
(
++
frameNum
<
limit
)
}
while
(
++
frameNum
<
limit
)
if
(
i
==
0
&&
thumbnailPath
)
{
if
(
i
==
0
&&
thumbnailPath
)
{
fs
.
copyFileSync
(
firstImage
,
thumbnailPath
)
fs
.
copyFileSync
(
firstImage
,
thumbnailPath
)
filesCreated
.
push
(
thumbnailPath
)
}
}
socketPayload
.
subTask
[
0
].
percent
=
Math
.
round
(((
i
+
1
)
/
tutorShotData
.
segments
.
length
)
*
75
);
// 75% for generating images
socketPayload
.
subTask
[
0
].
percent
=
Math
.
round
(((
i
+
1
)
/
tutorShotData
.
segments
.
length
)
*
75
);
// 75% for generating images
...
@@ -92,6 +99,7 @@ module.exports.generateVideo = async function (req, res) {
...
@@ -92,6 +99,7 @@ module.exports.generateVideo = async function (req, res) {
}
}
await
createVideoFromImages
([],
options
);
await
createVideoFromImages
([],
options
);
filesCreated
.
push
(
path
.
dirname
(
videoPath
))
socketPayload
.
subTask
[
0
].
percent
=
100
;
// 100% if video(without audio) is generated
socketPayload
.
subTask
[
0
].
percent
=
100
;
// 100% if video(without audio) is generated
socketPayload
.
percent
=
Math
.
round
(
tutorShotData
?.
audio
?.
length
?
socketPayload
.
subTask
[
0
].
percent
/
2
:
socketPayload
.
subTask
[
0
].
percent
);
socketPayload
.
percent
=
Math
.
round
(
tutorShotData
?.
audio
?.
length
?
socketPayload
.
subTask
[
0
].
percent
/
2
:
socketPayload
.
subTask
[
0
].
percent
);
socket
.
emit
(
"videoGenerationProgress"
,
socketPayload
);
socket
.
emit
(
"videoGenerationProgress"
,
socketPayload
);
...
@@ -130,7 +138,10 @@ module.exports.generateVideo = async function (req, res) {
...
@@ -130,7 +138,10 @@ module.exports.generateVideo = async function (req, res) {
res
.
status
(
STATUS_CODE
.
OK
).
json
(
tutorShotData
)
res
.
status
(
STATUS_CODE
.
OK
).
json
(
tutorShotData
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'------ERROR:GENERATING VIDEO'
,
err
)
console
.
log
(
'------ERROR:GENERATING VIDEO'
,
err
)
console
.
log
(
'------ERROR:GENERATING VIDEO'
)
res
.
status
(
STATUS_CODE
.
ERROR
).
json
()
res
.
status
(
STATUS_CODE
.
ERROR
).
json
()
socket
.
emit
(
"videoGenerationFailed"
,
{
uid
,
_id
})
deleteFile
(
filesCreated
)
}
}
}
}
...
...
helper/tutor-shot.js
View file @
685ede17
...
@@ -15,7 +15,7 @@ module.exports.mergeImages = async function (imageArr, options) {
...
@@ -15,7 +15,7 @@ module.exports.mergeImages = async function (imageArr, options) {
let
imageSharp
;
let
imageSharp
;
if
(
imageArr
[
0
].
url
)
{
if
(
imageArr
[
0
].
url
)
{
let
{
data
}
=
await
axios
.
get
(
imageArr
[
0
].
url
,
{
responseType
:
'arraybuffer'
});
let
{
data
}
=
await
axios
.
get
(
imageArr
[
0
].
url
,
{
responseType
:
'arraybuffer'
});
imageSharp
=
sharp
(
Buffer
.
from
(
data
))
imageSharp
=
sharp
(
Buffer
.
from
(
data
))
.
resize
(
options
.
dimension
.
width
,
options
.
dimension
.
height
)
delete
data
delete
data
}
}
let
compositeArr
=
[]
let
compositeArr
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment