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
58470441
Commit
58470441
authored
Oct 29, 2020
by
Jerome Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor tests
parent
acd70a80
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
31 deletions
+97
-31
data
wasm/tests/data
+1
-1
libvpx.test.js
wasm/tests/libvpx.test.js
+32
-0
multiple-round.test.js
wasm/tests/multiple-round.test.js
+20
-0
transcode-webm.test.js
wasm/tests/transcode-webm.test.js
+0
-27
utils.js
wasm/tests/utils.js
+8
-3
wv.test.js
wasm/tests/wv.test.js
+18
-0
x264.test.js
wasm/tests/x264.test.js
+18
-0
No files found.
data
@
ef325bd0
Subproject commit
96cca2e2666bd1a82c9bc46b95e50e195f438c23
Subproject commit
ef325bd0249c65d10614e87bff335c79cc3cea44
wasm/tests/libvpx.test.js
0 → 100644
View file @
58470441
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
{
TIMEOUT
}
=
require
(
'./config'
);
const
{
runFFmpeg
}
=
require
(
'./utils'
);
const
aviFilePath
=
path
.
join
(
__dirname
,
'data'
,
'video-1s.avi'
);
const
IN_FILE_NAME
=
'video-1s.avi'
;
const
OUT_FILE_NAME
=
'video.webm'
;
const
WEBM_SIZE
=
41904
;
const
WEBM_SIZE_MT
=
41878
;
let
aviData
=
null
;
let
BASELINE_TIME
=
0
;
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'transcode avi to vp9 webm'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
OUT_FILE_NAME
];
const
start
=
Date
.
now
();
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
);
BASELINE_TIME
=
Date
.
now
()
-
start
;
expect
(
fileSize
).
toBe
(
WEBM_SIZE
);
},
TIMEOUT
);
test
(
'transcode avi to vp9 webm with multithread'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-row-mt'
,
'1'
,
OUT_FILE_NAME
];
const
start
=
Date
.
now
();
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
);
const
timediff
=
Date
.
now
()
-
start
;
expect
(
fileSize
).
toBe
(
WEBM_SIZE_MT
);
expect
(
timediff
<
BASELINE_TIME
).
toBe
(
true
);
},
TIMEOUT
);
wasm/tests/multiple-round.test.js
0 → 100644
View file @
58470441
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
MP4_SIZE
=
38372
;
let
aviData
=
null
;
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'should transcode to mp4 twice'
,
async
()
=>
{
for
(
let
i
=
0
;
i
<
2
;
i
++
)
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
);
expect
(
fileSize
).
toBe
(
MP4_SIZE
);
}
},
TIMEOUT
);
wasm/tests/transcode-webm.test.js
deleted
100644 → 0
View file @
acd70a80
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
{
TIMEOUT
}
=
require
(
'./config'
);
const
{
runFFmpeg
}
=
require
(
'./utils'
);
const
aviFilePath
=
path
.
join
(
__dirname
,
'data'
,
'video-1s.avi'
);
const
WEBM_SIZE
=
41878
;
let
aviData
=
null
;
beforeAll
(
async
()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
aviFilePath
));
});
test
(
'transcode avi to webm'
,
async
()
=>
{
const
Core
=
await
runFFmpeg
(
'video.avi'
,
aviData
,
[
'-i'
,
'video.avi'
,
'-row-mt'
,
'1'
,
'video.webm'
]);
const
fileSize
=
Core
.
FS
.
readFile
(
'video.webm'
).
length
;
Core
.
FS
.
unlink
(
'video.webm'
);
expect
(
fileSize
).
toBe
(
WEBM_SIZE
);
},
TIMEOUT
);
test
(
'transcode avi to webm twice'
,
async
()
=>
{
for
(
let
i
=
0
;
i
<
2
;
i
++
)
{
const
Core
=
await
runFFmpeg
(
'video.avi'
,
aviData
,
[
'-i'
,
'video.avi'
,
'-row-mt'
,
'1'
,
'video.webm'
]);
const
fileSize
=
Core
.
FS
.
readFile
(
'video.webm'
).
length
;
Core
.
FS
.
unlink
(
'video.webm'
);
expect
(
fileSize
).
toBe
(
WEBM_SIZE
);
}
},
TIMEOUT
);
wasm/tests/utils.js
View file @
58470441
...
...
@@ -19,8 +19,9 @@ const ffmpeg = (Core, args) => {
);
};
const
runFFmpeg
=
async
(
filename
,
data
,
args
)
=>
{
const
runFFmpeg
=
async
(
ifilename
,
data
,
args
,
ofilename
)
=>
{
let
resolve
=
null
;
let
fileSize
=
-
1
;
const
Core
=
await
createFFmpegCore
({
printErr
:
()
=>
{},
print
:
(
m
)
=>
{
...
...
@@ -29,10 +30,14 @@ const runFFmpeg = async (filename, data, args) => {
}
},
});
Core
.
FS
.
writeFile
(
filename
,
data
);
Core
.
FS
.
writeFile
(
i
filename
,
data
);
ffmpeg
(
Core
,
args
);
await
new
Promise
((
_resolve
)
=>
{
resolve
=
_resolve
});
return
Core
;
if
(
typeof
ofilename
!==
'undefined'
)
{
fileSize
=
Core
.
FS
.
readFile
(
ofilename
).
length
;
Core
.
FS
.
unlink
(
ofilename
);
}
return
{
Core
,
fileSize
};
};
module
.
exports
=
{
...
...
wasm/tests/wv.test.js
0 → 100644
View file @
58470441
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
{
TIMEOUT
}
=
require
(
'./config'
);
const
{
runFFmpeg
}
=
require
(
'./utils'
);
const
IN_FILE_NAME
=
'audio-1s.wav'
;
const
OUT_FILE_NAME
=
'audio.wv'
;
const
WV_24BIT_SIZE
=
23502
;
let
wavData
=
null
;
beforeAll
(()
=>
{
wavData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'convert wav to wv'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
wavData
,
args
,
OUT_FILE_NAME
);
expect
(
fileSize
).
toBe
(
WV_24BIT_SIZE
);
},
TIMEOUT
);
wasm/tests/
transcode-
x264.test.js
→
wasm/tests/x264.test.js
View file @
58470441
...
...
@@ -2,26 +2,17 @@ const fs = require('fs');
const
path
=
require
(
'path'
);
const
{
TIMEOUT
}
=
require
(
'./config'
);
const
{
runFFmpeg
}
=
require
(
'./utils'
);
const
aviFilePath
=
path
.
join
(
__dirname
,
'data'
,
'video-1s.avi'
);
const
IN_FILE_NAME
=
'video-1s.avi'
;
const
OUT_FILE_NAME
=
'video.mp4'
;
const
MP4_SIZE
=
38372
;
let
aviData
=
null
;
beforeAll
(
async
()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
aviFilePath
));
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)
));
});
test
(
'transcode avi to x264 mp4'
,
async
()
=>
{
const
Core
=
await
runFFmpeg
(
'video.avi'
,
aviData
,
[
'-i'
,
'video.avi'
,
'video.mp4'
]);
const
fileSize
=
Core
.
FS
.
readFile
(
'video.mp4'
).
length
;
Core
.
FS
.
unlink
(
'video.mp4'
);
const
args
=
[
'-i'
,
IN_FILE_NAME
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
);
expect
(
fileSize
).
toBe
(
MP4_SIZE
);
},
TIMEOUT
);
test
(
'transcode avi to x264 mp4 twice'
,
async
()
=>
{
for
(
let
i
=
0
;
i
<
2
;
i
++
)
{
const
Core
=
await
runFFmpeg
(
'video.avi'
,
aviData
,
[
'-i'
,
'video.avi'
,
'video.mp4'
]);
const
fileSize
=
Core
.
FS
.
readFile
(
'video.mp4'
).
length
;
Core
.
FS
.
unlink
(
'video.mp4'
);
expect
(
fileSize
).
toBe
(
MP4_SIZE
);
}
},
TIMEOUT
);
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