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
1099b3f5
Commit
1099b3f5
authored
Oct 30, 2020
by
Jerome Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pkg-config and x265 multilib issue
parent
6f5211d1
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
119 additions
and
22 deletions
+119
-22
README.md
README.md
+1
-0
build.sh
build.sh
+2
-2
configure
configure
+3
-0
build-ffmpeg.sh
wasm/build-scripts/build-ffmpeg.sh
+1
-1
build-vorbis.sh
wasm/build-scripts/build-vorbis.sh
+3
-2
build-x265.sh
wasm/build-scripts/build-x265.sh
+70
-10
install-deps.sh
wasm/build-scripts/install-deps.sh
+1
-1
var.sh
wasm/build-scripts/var.sh
+5
-1
x265.html
wasm/examples/browser/x265.html
+2
-2
config.js
wasm/tests/config.js
+1
-1
utils.js
wasm/tests/utils.js
+4
-2
x265.test.js
wasm/tests/x265.test.js
+26
-0
No files found.
README.md
View file @
1099b3f5
...
...
@@ -43,6 +43,7 @@ If nothing goes wrong, you can find JavaScript files in `wasm/dist`.
#### Video
-
x264 (mp4): 0.160.x
-
x265 (mp4): 3.4 (only works with
`-pix_fmt yuv420p10le`
and
`-pix_fmt yuv420p12le`
)
-
libvpx (webm): 1.9.0
#### Audio
...
...
build.sh
View file @
1099b3f5
...
...
@@ -10,8 +10,8 @@ emcc -v
$SCRIPT_ROOT
/install-deps.sh
# build x264
$SCRIPT_ROOT
/build-x264.sh
# build x265
(WIP)
#
$SCRIPT_ROOT/build-x265.sh
# build x265
$SCRIPT_ROOT
/build-x265.sh
# build libvpx
$SCRIPT_ROOT
/build-libvpx.sh
# build WavPack
...
...
configure
View file @
1099b3f5
...
...
@@ -7,6 +7,9 @@
# Copyright (c) 2005-2008 Mans Rullgard
#
# Set PKG_CONFIG_PATH manually
export
PKG_CONFIG_PATH
=
/src/build/lib/pkgconfig
# Prevent locale nonsense from breaking basic text processing.
LC_ALL
=
C
export
LC_ALL
...
...
wasm/build-scripts/build-ffmpeg.sh
View file @
1099b3f5
...
...
@@ -9,7 +9,7 @@ FLAGS=(
-I
.
-I
./fftools
-I
$BUILD_DIR
/include
-Llibavcodec
-Llibavdevice
-Llibavfilter
-Llibavformat
-Llibavresample
-Llibavutil
-Llibpostproc
-Llibswscale
-Llibswresample
-L
$BUILD_DIR
/lib
-Wno-deprecated-declarations
-Wno-pointer-sign
-Wno-implicit-int-float-conversion
-Wno-switch
-Wno-parentheses
-Qunused-arguments
-lavdevice
-lavfilter
-lavformat
-lavcodec
-lswresample
-lswscale
-lavutil
-lpostproc
-lm
-lx264
-lvpx
-lwavpack
-lmp3lame
-lfdk-aac
-pthread
-lavdevice
-lavfilter
-lavformat
-lavcodec
-lswresample
-lswscale
-lavutil
-lpostproc
-lm
-lx264
-l
x265
-l
vpx
-lwavpack
-lmp3lame
-lfdk-aac
-pthread
fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c fftools/cmdutils.c fftools/ffmpeg.c
-o
wasm/dist/ffmpeg-core.js
-s
USE_SDL
=
2
# use SDL2
...
...
wasm/build-scripts/build-vorbis.sh
View file @
1099b3f5
...
...
@@ -4,13 +4,14 @@ set -euo pipefail
source
$(
dirname
$0
)
/var.sh
LIB_PATH
=
third_party/vorbis
CFLAGS
=
"-s USE_PTHREADS=1
$OPTIM_FLAGS
-I
$BUILD_DIR
/include
-Qunused-arguments
"
CFLAGS
=
"-s USE_PTHREADS=1
$OPTIM_FLAGS
-I
$BUILD_DIR
/include"
LDFLAGS
=
"-L
$BUILD_DIR
/lib"
CONF_FLAGS
=(
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--host
=
i686-linux
# use i686 linux
--
disable-shared
# disable shared library
--
enable-shared
=
no
# disable shared library
--disable-oggtest
# disable tests
--enable-fast-install
=
no
)
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
(
cd
$LIB_PATH
&&
\
...
...
wasm/build-scripts/build-x265.sh
View file @
1099b3f5
...
...
@@ -4,15 +4,75 @@ set -euo pipefail
source
$(
dirname
$0
)
/var.sh
LIB_PATH
=
third_party/x265/source
C
ONF_FLAGS
=(
-DCMAKE_INSTALL_PREFIX
=
$BUILD_DIR
C
XXFLAGS
=
"-s USE_PTHREADS=1
$OPTIM_FLAGS
"
BASE_FLAGS
=(
-DCMAKE_TOOLCHAIN_FILE
=
$TOOLCHAIN_FILE
-DENABLE_SHARED
:bool
=
off
-DENABLE_CLI
:bool
=
off
-DENABLE_LIBNUMA
=
OFF
-DENABLE_SHARED
=
OFF
-DENABLE_CLI
=
OFF
)
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
rm
-rf
$LIB_PATH
/build
mkdir
-p
$LIB_PATH
/build
(
cd
$LIB_PATH
/build
&&
emmake cmake ..
"
${
CONF_FLAGS
[@]
}
"
)
emmake make
-C
$LIB_PATH
/build clean
emmake make
-C
$LIB_PATH
/build
install
-j
FLAGS_12BIT
=(
${
BASE_FLAGS
[@]
}
-DHIGH_BIT_DEPTH
=
ON
-DEXPORT_C_API
=
OFF
-DMAIN12
=
ON
)
FLAGS_10BIT
=(
${
BASE_FLAGS
[@]
}
-DHIGH_BIT_DEPTH
=
ON
-DEXPORT_C_API
=
OFF
)
FLAGS_MAIN
=(
${
BASE_FLAGS
[@]
}
-DEXTRA_LIB
=
"x265_main10.a;x265_main12.a"
-DEXTRA_LINK_FLAGS
=
-L
.
-DLINKED_10BIT
=
ON
-DLINKED_12BIT
=
ON
)
cd
$LIB_PATH
rm
-rf
build
mkdir
-p
build
cd
build
mkdir
-p
main 10bit 12bit
cd
12bit
emmake cmake ../..
-DCMAKE_CXX_FLAGS
=
"
$CXXFLAGS
"
${
FLAGS_12BIT
[@]
}
emmake make
-j
cd
../10bit
emmake cmake ../..
-DCMAKE_CXX_FLAGS
=
"
$CXXFLAGS
"
${
FLAGS_10BIT
[@]
}
emmake make
-j
cd
../main
ln
-sf
../10bit/libx265.a libx265_main10.a
ln
-sf
../12bit/libx265.a libx265_main12.a
emmake cmake ../..
-DCMAKE_CXX_FLAGS
=
"
$CXXFLAGS
"
${
FLAGS_MAIN
[@]
}
emmake make
-j
mv
libx265.a libx265_main.a
# Merge static libraries
emar
-M
<<
EOF
CREATE libx265.a
ADDLIB libx265_main.a
ADDLIB libx265_main10.a
ADDLIB libx265_main12.a
SAVE
END
EOF
# Copy files to build directory
mkdir
-p
$BUILD_DIR
mkdir
-p
$BUILD_DIR
/include
mkdir
-p
$BUILD_DIR
/lib
mkdir
-p
$BUILD_DIR
/lib/pkgconfig
cp
x265_config.h
$BUILD_DIR
/include
cp
../../x265.h
$BUILD_DIR
/include
cp
libx265.a
$BUILD_DIR
/lib
cp
x265.pc
$BUILD_DIR
/lib/pkgconfig
cd
$ROOT_DIR
wasm/build-scripts/install-deps.sh
View file @
1099b3f5
...
...
@@ -3,7 +3,7 @@
cmds
=()
# Detect what dependencies are missing.
for
cmd
in
autoconf automake libtool
for
cmd
in
autoconf automake libtool
pkg-config
do
if
!
command
-v
$cmd
&> /dev/null
then
...
...
wasm/build-scripts/var.sh
View file @
1099b3f5
...
...
@@ -24,8 +24,11 @@ fi
# Convert array to string
OPTIM_FLAGS
=
"
${
OPTIM_FLAGS
[@]
}
"
# Root directory
ROOT_DIR
=
$PWD
# Directory to install headers and libraries
BUILD_DIR
=
$
PWD
/build
BUILD_DIR
=
$
ROOT_DIR
/build
# Toolchain file path for cmake
TOOLCHAIN_FILE
=
/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
...
...
@@ -44,6 +47,7 @@ FFMPEG_CONFIG_FLAGS_BASE=(
--enable-gpl
# required by x264
--enable-nonfree
# required by fdk-aac
--enable-libx264
# enable x264
--enable-libx265
# enable x265
--enable-libvpx
# enable libvpx / webm
--enable-libwavpack
# enable libwavpack
--enable-libmp3lame
# enable libmp3lame
...
...
wasm/examples/browser/
next/
x265.html
→
wasm/examples/browser/x265.html
View file @
1099b3f5
...
...
@@ -14,7 +14,7 @@
</style>
</head>
<body>
<h3>
Upload a video to transcode to mp4 (x265)
and play
!
</h3>
<h3>
Upload a video to transcode to mp4 (x265)!
</h3>
<video
id=
"output-video"
controls
></video><br/>
<input
type=
"file"
id=
"uploader"
>
<p
id=
"message"
>
Upload a video
</p>
...
...
@@ -24,7 +24,7 @@
const
transcode
=
async
({
target
:
{
files
}
})
=>
{
const
IN_FILE_NAME
=
'video.avi'
;
const
OUT_FILE_NAME
=
'video.mp4'
;
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-c:v'
,
'libx265'
,
'-c:a'
,
'copy'
,
OUT_FILE_NAME
];
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-c:v'
,
'libx265'
,
'-
pix_fmt'
,
'yuv420p10le'
,
'-
c:a'
,
'copy'
,
OUT_FILE_NAME
];
message
.
innerHTML
=
'Writing file to MEMFS'
;
const
data
=
new
Uint8Array
(
await
readFromBlobOrFile
(
files
[
0
]));
const
now
=
Date
.
now
();
...
...
wasm/tests/config.js
View file @
1099b3f5
module
.
exports
=
{
TIMEOUT
:
3
0000
,
TIMEOUT
:
6
0000
,
};
wasm/tests/utils.js
View file @
1099b3f5
...
...
@@ -21,6 +21,7 @@ const ffmpeg = (Core, args) => {
const
runFFmpeg
=
async
(
ifilename
,
data
,
args
,
ofilename
)
=>
{
let
resolve
=
null
;
let
file
=
null
;
let
fileSize
=
-
1
;
const
Core
=
await
createFFmpegCore
({
printErr
:
()
=>
{},
...
...
@@ -34,10 +35,11 @@ const runFFmpeg = async (ifilename, data, args, ofilename) => {
ffmpeg
(
Core
,
args
);
await
new
Promise
((
_resolve
)
=>
{
resolve
=
_resolve
});
if
(
typeof
ofilename
!==
'undefined'
)
{
fileSize
=
Core
.
FS
.
readFile
(
ofilename
).
length
;
file
=
Core
.
FS
.
readFile
(
ofilename
);
fileSize
=
file
.
length
;
Core
.
FS
.
unlink
(
ofilename
);
}
return
{
Core
,
fileSize
};
return
{
Core
,
file
,
file
Size
};
};
module
.
exports
=
{
...
...
wasm/tests/
next/x265
.js
→
wasm/tests/
x265.test
.js
View file @
1099b3f5
...
...
@@ -4,15 +4,23 @@ 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
;
const
MP4_10BIT_SIZE1
=
22507
;
const
MP4_10BIT_SIZE2
=
22520
;
const
MP4_12BIT_SIZE
=
22718
;
let
aviData
=
null
;
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'transcode avi to x265 mp4'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-c:v'
,
'libx265'
,
OUT_FILE_NAME
];
test
(
'transcode avi to x265
10bit
mp4'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-c:v'
,
'libx265'
,
'-pix_fmt'
,
'yuv420p10le'
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
);
expect
(
fileSize
).
toBe
(
MP4_SIZE
);
expect
(
fileSize
===
MP4_10BIT_SIZE1
||
fileSize
===
MP4_10BIT_SIZE2
).
toBe
(
true
);
},
TIMEOUT
);
test
(
'transcode avi to x265 12bit mp4'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-c:v'
,
'libx265'
,
'-pix_fmt'
,
'yuv420p12le'
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
);
expect
(
fileSize
).
toBe
(
MP4_12BIT_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