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
c808d567
Commit
c808d567
authored
May 03, 2021
by
Jerome Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update libass build scripts and add test cases
parent
7255c577
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
11 deletions
+61
-11
build-fribidi.sh
wasm/build-scripts/build-fribidi.sh
+1
-4
build-libass.sh
wasm/build-scripts/build-libass.sh
+1
-2
configure-ffmpeg.sh
wasm/build-scripts/configure-ffmpeg.sh
+4
-2
var.sh
wasm/build-scripts/var.sh
+3
-2
libass.test.js
wasm/tests/libass.test.js
+48
-0
utils.js
wasm/tests/utils.js
+4
-1
No files found.
wasm/build-scripts/build-fribidi.sh
View file @
c808d567
...
...
@@ -11,13 +11,10 @@ CONF_FLAGS=(
--enable-shared
=
no
# not to build shared library
--enable-static
--disable-dependency-tracking
--disable-debug
--without-glib
--disable-docs
)
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
(
cd
$LIB_PATH
&&
\
emconfigure ./autogen.sh
&&
\
CFLAGS
=
$CFLAGS
emconfigure ./configure
"
${
CONF_FLAGS
[@]
}
"
)
emmake make
-C
$LIB_PATH
clean
emmake make
-C
$LIB_PATH
install
-j
1
emmake make
-C
$LIB_PATH
install
-j
wasm/build-scripts/build-libass.sh
View file @
c808d567
...
...
@@ -4,7 +4,6 @@ set -euo pipefail
source
$(
dirname
$0
)
/var.sh
LIB_PATH
=
third_party/libass
LIBASS_PC_PATH
=
"
$BUILD_DIR
/lib/pkgconfig"
CONF_FLAGS
=(
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--host
=
i686-gnu
# use i686 linux
...
...
@@ -15,6 +14,6 @@ CONF_FLAGS=(
--disable-require-system-font-provider
)
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
(
cd
$LIB_PATH
&&
./autogen.sh
&&
EM_PKG_CONFIG_PATH
=
$
LIBASS_PC
_PATH
emconfigure ./configure
"
${
CONF_FLAGS
[@]
}
"
)
(
cd
$LIB_PATH
&&
./autogen.sh
&&
EM_PKG_CONFIG_PATH
=
$
EM_PKG_CONFIG
_PATH
emconfigure ./configure
"
${
CONF_FLAGS
[@]
}
"
)
emmake make
-C
$LIB_PATH
clean
emmake make
-C
$LIB_PATH
install
-j
wasm/build-scripts/configure-ffmpeg.sh
View file @
c808d567
...
...
@@ -3,7 +3,6 @@
set
-euo
pipefail
source
$(
dirname
$0
)
/var.sh
FFMPEG_WEBM_PC_PATH
=
"
$BUILD_DIR
/lib/pkgconfig"
FLAGS
=(
"
${
FFMPEG_CONFIG_FLAGS_BASE
[@]
}
"
--enable-gpl
# required by x264
...
...
@@ -20,7 +19,10 @@ FLAGS=(
--enable-libfreetype
# enable freetype
--enable-libopus
# enable opus
--enable-libwebp
# enable libwebp
--enable-libass
# enable libass
--enable-libfribidi
# enable libfribidi
# --enable-filter=subtitles,overlay
# --enable-libaom # enable libaom
)
echo
"FFMPEG_CONFIG_FLAGS=
${
FLAGS
[@]
}
"
EM_PKG_CONFIG_PATH
=
${
FFMPEG_WEBM_PC
_PATH
}
emconfigure ./configure
"
${
FLAGS
[@]
}
"
EM_PKG_CONFIG_PATH
=
${
EM_PKG_CONFIG
_PATH
}
emconfigure ./configure
"
${
FLAGS
[@]
}
"
wasm/build-scripts/var.sh
View file @
c808d567
...
...
@@ -30,6 +30,9 @@ ROOT_DIR=$PWD
# Directory to install headers and libraries
BUILD_DIR
=
$ROOT_DIR
/build
# Directory to look for pkgconfig files
EM_PKG_CONFIG_PATH
=
$BUILD_DIR
/lib/pkgconfig
# Toolchain file path for cmake
TOOLCHAIN_FILE
=
$EMSDK
/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
...
...
@@ -58,8 +61,6 @@ FFMPEG_CONFIG_FLAGS_BASE=(
--cxx
=
em++
--objcc
=
emcc
--dep-cc
=
emcc
--enable-libass
--enable-filter
=
subtitles,overlay
)
echo
"EMSDK=
$EMSDK
"
...
...
wasm/tests/libass.test.js
0 → 100644
View file @
c808d567
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
SRT_FILE
=
`
1
00:00:00,000 --> 00:00:01,000
ffmpeg.wasm test
`
;
const
ASS_FILE
=
`
[Script Info]
; Script generated by FFmpeg/Lavc58.91.100
ScriptType: v4.00+
PlayResX: 240
PlayResY: 256
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:01.00,Default,,0,0,0,,ffmpeg.wasm test
`
;
const
IN_FILE_NAME
=
'video-1s.avi'
;
const
OUT_FILE_NAME
=
'video.mp4'
;
const
MP4_WITH_SRT_FILE_SIZE
=
38695
;
const
MP4_WITH_ASS_FILE_SIZE
=
38532
;
let
aviData
=
null
;
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'transcode avi to x264 mp4 with *.srt subtitle'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-vf'
,
'subtitles=test.srt:fontsdir=/fonts:force_style="Fontname=Arial"'
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
,
[{
name
:
'/fonts/arial.ttf'
,
data
:
b64ToUint8Array
(
ARIAL_TTF
)
},
{
name
:
'test.srt'
,
data
:
SRT_FILE
}],
[
'/fonts'
]);
expect
(
fileSize
).
toBe
(
MP4_WITH_SRT_FILE_SIZE
);
},
TIMEOUT
);
test
(
'transcode avi to x264 mp4 with *.ass subtitle'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-vf'
,
'ass=test.ass:fontsdir=/fonts'
,
OUT_FILE_NAME
];
const
{
fileSize
,
file
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
,
[{
name
:
'/fonts/arial.ttf'
,
data
:
b64ToUint8Array
(
ARIAL_TTF
)
},
{
name
:
'test.ass'
,
data
:
ASS_FILE
}],
[
'/fonts'
]);
fs
.
writeFileSync
(
'subtitle.mp4'
,
file
);
expect
(
fileSize
).
toBe
(
MP4_WITH_ASS_FILE_SIZE
);
},
TIMEOUT
);
wasm/tests/utils.js
View file @
c808d567
...
...
@@ -19,7 +19,7 @@ const ffmpeg = (Core, args) => {
);
};
const
runFFmpeg
=
async
(
ifilename
,
data
,
args
,
ofilename
,
extraFiles
=
[])
=>
{
const
runFFmpeg
=
async
(
ifilename
,
data
,
args
,
ofilename
,
extraFiles
=
[]
,
extraFolders
=
[]
)
=>
{
let
resolve
=
null
;
let
file
=
null
;
let
fileSize
=
-
1
;
...
...
@@ -31,6 +31,9 @@ const runFFmpeg = async (ifilename, data, args, ofilename, extraFiles = []) => {
}
},
});
extraFolders
.
forEach
((
f
)
=>
{
Core
.
FS
.
mkdir
(
f
);
});
extraFiles
.
forEach
(({
name
,
data
:
d
})
=>
{
Core
.
FS
.
writeFile
(
name
,
d
);
});
...
...
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