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
Hide 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")
const
socket
=
require
(
"../socket.js"
)
module
.
exports
.
generateVideo
=
async
function
(
req
,
res
)
{
let
uid
;
let
_id
let
filesCreated
=
[]
try
{
let
tutorShotData
=
req
.
body
.
tutorShotData
;
let
videoPath
;
// local path of the video file
...
...
@@ -24,6 +26,8 @@ module.exports.generateVideo = async function (req, res) {
let
updatedData
;
if
(
tutorShotData
)
{
uid
=
tutorShotData
.
uid
_id
=
tutorShotData
.
_id
let
socketPayload
=
{
uid
:
tutorShotData
.
uid
,
task
:
"Video Generation"
,
...
...
@@ -58,22 +62,25 @@ module.exports.generateVideo = async function (req, res) {
],
{
outputType
:
"buffer"
,
dimension
:
tutorShotData
.
segments
[
i
].
dimension
}
)
let
limit
=
24
*
((
tutorShotData
.
segments
[
i
]?.
duration
)
?
(
tutorShotData
.
segments
[
i
].
duration
)
:
2
);
let
frameNum
=
0
let
firstImage
=
path
.
join
(
imageDir
,
`
${
tutorShotData
.
_id
}
_
${
frameNumber
++
}
.png`
)
await
sharp
(
mergedImage
).
toFile
(
firstImage
)
imageArr
.
push
(
firstImage
)
filesCreated
.
push
(
firstImage
)
do
{
let
fileName
=
path
.
join
(
imageDir
,
`
${
tutorShotData
.
_id
}
_
${
frameNumber
++
}
.png`
)
imageArr
.
push
(
fileName
)
filesCreated
.
push
(
fileName
)
fs
.
copyFileSync
(
firstImage
,
fileName
)
}
while
(
++
frameNum
<
limit
)
if
(
i
==
0
&&
thumbnailPath
)
{
fs
.
copyFileSync
(
firstImage
,
thumbnailPath
)
filesCreated
.
push
(
thumbnailPath
)
}
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) {
}
await
createVideoFromImages
([],
options
);
filesCreated
.
push
(
path
.
dirname
(
videoPath
))
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
);
socket
.
emit
(
"videoGenerationProgress"
,
socketPayload
);
...
...
@@ -130,7 +138,10 @@ module.exports.generateVideo = async function (req, res) {
res
.
status
(
STATUS_CODE
.
OK
).
json
(
tutorShotData
)
}
catch
(
err
)
{
console
.
log
(
'------ERROR:GENERATING VIDEO'
,
err
)
console
.
log
(
'------ERROR:GENERATING VIDEO'
)
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) {
let
imageSharp
;
if
(
imageArr
[
0
].
url
)
{
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
}
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