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
7ce04f32
Commit
7ce04f32
authored
Jun 10, 2024
by
Pragati Upadhyay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue fixed
parent
19deb370
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
18 deletions
+34
-18
ffmpeg-helper.js
helper/ffmpeg-helper.js
+34
-18
No files found.
helper/ffmpeg-helper.js
View file @
7ce04f32
...
@@ -37,7 +37,6 @@ function createClipFromImage(imagePath, duration, outputClipPath, callback) {
...
@@ -37,7 +37,6 @@ function createClipFromImage(imagePath, duration, outputClipPath, callback) {
])
])
.
output
(
outputClipPath
)
.
output
(
outputClipPath
)
.
on
(
'end'
,
()
=>
{
.
on
(
'end'
,
()
=>
{
console
.
log
(
`Clip created:
${
outputClipPath
}
`
);
callback
(
null
,
outputClipPath
);
// Pass the clip path on success
callback
(
null
,
outputClipPath
);
// Pass the clip path on success
})
})
.
on
(
'error'
,
(
err
)
=>
{
.
on
(
'error'
,
(
err
)
=>
{
...
@@ -71,37 +70,54 @@ function concatenateClips(clips, outputPath, callback) {
...
@@ -71,37 +70,54 @@ function concatenateClips(clips, outputPath, callback) {
}
}
module
.
exports
.
createVideo
=
async
function
(
screenshots
,
outputPath
)
{
module
.
exports
.
createVideo
=
async
function
(
screenshots
,
outputPath
)
{
return
new
Promise
(
async
(
res
,
rej
)
=>
{
return
new
Promise
(
async
(
res
olve
,
reject
)
=>
{
le
t
clips
=
[];
cons
t
clips
=
[];
try
{
for
(
let
index
=
0
;
index
<
screenshots
.
length
;
index
++
)
{
for
(
let
index
=
0
;
index
<
screenshots
.
length
;
index
++
)
{
const
screenshot
=
screenshots
[
index
];
const
screenshot
=
screenshots
[
index
];
const
duration
=
screenshots
[
index
]?.
duration
?
screenshots
[
index
].
duration
:
3
;
const
duration
=
screenshot
.
duration
||
3
;
const
clipPath
=
`clip
${
index
}
.mp4`
;
// Temporary clip path
const
clipPath
=
`clip
${
index
}
.mp4`
;
// Temporary clip path
const
clip
=
await
createClipFromImageAsync
(
screenshot
,
duration
,
clipPath
);
clips
.
push
(
clip
);
}
console
.
log
(
"🚀 ~ returnnewPromise ~ clips:"
,
clips
)
await
concatenateClipsAsync
(
clips
,
outputPath
);
resolve
();
}
catch
(
error
)
{
console
.
error
(
'Error processing video:'
,
error
);
reject
(
error
);
}
});
};
// Helper function to convert callback-based createClipFromImage to promise-based
function
createClipFromImageAsync
(
screenshot
,
duration
,
clipPath
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
createClipFromImage
(
screenshot
,
duration
,
clipPath
,
(
err
,
clip
)
=>
{
createClipFromImage
(
screenshot
,
duration
,
clipPath
,
(
err
,
clip
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to create clip for
${
screenshot
}
:
${
err
}
`
);
reject
(
err
);
return
;
}
else
{
resolve
(
clip
);
}
}
});
});
}
clips
.
push
(
clip
);
// Helper function to convert callback-based concatenateClips to promise-based
function
concatenateClipsAsync
(
clips
,
outputPath
)
{
if
(
index
===
screenshots
.
length
-
1
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// All screenshots processed, concatenate clips
concatenateClips
(
clips
,
outputPath
,
(
err
)
=>
{
concatenateClips
(
clips
,
outputPath
,
(
err
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to concatenate clips:
${
err
}
`
);
reject
(
err
);
return
;
}
else
{
resolve
();
}
}
console
.
log
(
'All done'
);
res
();
});
});
}
});
});
}
});
}
}
...
...
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