Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
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
Linshizhi
ffmpeg.wasm-core
Commits
cc8a08ed
Commit
cc8a08ed
authored
May 17, 2021
by
Jerome Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add exit unit test
parent
3df24c56
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
exit.test.js
wasm/tests/exit.test.js
+21
-0
utils.js
wasm/tests/utils.js
+7
-1
No files found.
wasm/tests/exit.test.js
0 → 100644
View file @
cc8a08ed
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
{
TIMEOUT
}
=
require
(
'./config'
);
const
{
runFFmpeg
}
=
require
(
'./utils'
);
const
IN_FILE_NAME
=
'video-1s.avi'
;
const
OUT_FILE_NAME
=
'video.mp4'
;
const
FILE_SIZE
=
38372
;
let
aviData
=
null
;
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'transcode avi to x264 mp4 with exit'
,
async
()
=>
{
const
processExit
=
process
.
exit
;
global
.
process
.
exit
=
jest
.
fn
();
const
args
=
[
'-i'
,
IN_FILE_NAME
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
,
[],
[],
1000
);
expect
(
fileSize
).
not
.
toBe
(
FILE_SIZE
);
global
.
process
.
exit
=
processExit
;
},
TIMEOUT
);
wasm/tests/utils.js
View file @
cc8a08ed
...
...
@@ -19,7 +19,7 @@ const ffmpeg = (Core, args) => {
);
};
const
runFFmpeg
=
async
(
ifilename
,
data
,
args
,
ofilename
,
extraFiles
=
[],
extraFolders
=
[])
=>
{
const
runFFmpeg
=
async
(
ifilename
,
data
,
args
,
ofilename
,
extraFiles
=
[],
extraFolders
=
[]
,
msBeforeExit
=
-
1
)
=>
{
let
resolve
=
null
;
let
file
=
null
;
let
fileSize
=
-
1
;
...
...
@@ -39,6 +39,12 @@ const runFFmpeg = async (ifilename, data, args, ofilename, extraFiles = [], extr
});
Core
.
FS
.
writeFile
(
ifilename
,
data
);
ffmpeg
(
Core
,
args
);
if
(
msBeforeExit
!==
-
1
)
{
setTimeout
(()
=>
{
Core
.
exit
();
resolve
();
},
msBeforeExit
);
}
await
new
Promise
((
_resolve
)
=>
{
resolve
=
_resolve
});
if
(
typeof
ofilename
!==
'undefined'
)
{
file
=
Core
.
FS
.
readFile
(
ofilename
);
...
...
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