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
67036c79
Commit
67036c79
authored
Nov 13, 2020
by
Jerome Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add freetype2 and git tests
parent
0fdf4573
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
1 deletion
+44
-1
freetype2.test.js
wasm/tests/freetype2.test.js
+19
-0
gif.test.js
wasm/tests/gif.test.js
+18
-0
utils.js
wasm/tests/utils.js
+7
-1
No files found.
wasm/tests/freetype2.test.js
0 → 100644
View file @
67036c79
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
{
TIMEOUT
}
=
require
(
'./config'
);
const
{
runFFmpeg
,
b64ToUint8Array
}
=
require
(
'./utils'
);
const
ARIAL_TTF
=
require
(
'./data/arial.ttf.js'
);
const
IN_FILE_NAME
=
'video-1s.avi'
;
const
OUT_FILE_NAME
=
'video.mp4'
;
const
FILE_SIZE
=
37243
;
let
aviData
=
null
;
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'transcode avi to x264 mp4 with drawtext'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-vf'
,
'drawtext=fontfile=/arial.ttf:text=
\'
Artist
\'
:fontcolor=white:fontsize=24:x=(w-text_w)/2:y=(h-text_h)/2'
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
,
[{
name
:
'arial.ttf'
,
data
:
b64ToUint8Array
(
ARIAL_TTF
)
}]);
expect
(
fileSize
).
toBe
(
FILE_SIZE
);
},
TIMEOUT
);
wasm/tests/gif.test.js
0 → 100644
View file @
67036c79
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.gif'
;
const
FILE_SIZE
=
181674
;
let
aviData
=
null
;
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'transcode avi to gif'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-f'
,
'gif'
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
);
expect
(
fileSize
).
toBe
(
FILE_SIZE
);
},
TIMEOUT
);
wasm/tests/utils.js
View file @
67036c79
...
@@ -19,7 +19,7 @@ const ffmpeg = (Core, args) => {
...
@@ -19,7 +19,7 @@ const ffmpeg = (Core, args) => {
);
);
};
};
const
runFFmpeg
=
async
(
ifilename
,
data
,
args
,
ofilename
)
=>
{
const
runFFmpeg
=
async
(
ifilename
,
data
,
args
,
ofilename
,
extraFiles
=
[]
)
=>
{
let
resolve
=
null
;
let
resolve
=
null
;
let
file
=
null
;
let
file
=
null
;
let
fileSize
=
-
1
;
let
fileSize
=
-
1
;
...
@@ -31,6 +31,9 @@ const runFFmpeg = async (ifilename, data, args, ofilename) => {
...
@@ -31,6 +31,9 @@ const runFFmpeg = async (ifilename, data, args, ofilename) => {
}
}
},
},
});
});
extraFiles
.
forEach
(({
name
,
data
:
d
})
=>
{
Core
.
FS
.
writeFile
(
name
,
d
);
});
Core
.
FS
.
writeFile
(
ifilename
,
data
);
Core
.
FS
.
writeFile
(
ifilename
,
data
);
ffmpeg
(
Core
,
args
);
ffmpeg
(
Core
,
args
);
await
new
Promise
((
_resolve
)
=>
{
resolve
=
_resolve
});
await
new
Promise
((
_resolve
)
=>
{
resolve
=
_resolve
});
...
@@ -42,7 +45,10 @@ const runFFmpeg = async (ifilename, data, args, ofilename) => {
...
@@ -42,7 +45,10 @@ const runFFmpeg = async (ifilename, data, args, ofilename) => {
return
{
Core
,
file
,
fileSize
};
return
{
Core
,
file
,
fileSize
};
};
};
const
b64ToUint8Array
=
(
str
)
=>
(
Buffer
.
from
(
str
,
'base64'
));
module
.
exports
=
{
module
.
exports
=
{
runFFmpeg
,
runFFmpeg
,
b64ToUint8Array
,
ffmpeg
,
ffmpeg
,
};
};
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