Skip to content

Instantly share code, notes, and snippets.

@xaiki
Created May 1, 2014 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xaiki/c30e0700cdcf377a69f3 to your computer and use it in GitHub Desktop.
Save xaiki/c30e0700cdcf377a69f3 to your computer and use it in GitHub Desktop.
hacks to produce libffmpegsumo.so

building ffmpegsumo is a PITA, you need to fight with chromium’s build system, but so far this seems to work:

GYP_DEFINES=”proprietary_codecs=1 target_arch=x64 branding=Chrome” ./build/gyp_chromium build/all.gyp

–> use the hacks to produce the ffmpegsumo and ffmpeg_yasm ninja files <–

./depot_tools/ninja -v -j4 -C out/Release ffmpegsumo

rm cfilez
rm afilez
for i in `find build.x64.linux/Chromium -name '*.o' | sed s/Chromium/' '/ | cut -d' ' -f2`; do
d=`dirname $i`;
f=`basename $i | sed s/'\.o$'// | egrep -oe '[^ ]+$'`;
[ -f ./${d}/${f}.c ] && echo "${d} ${f}" >> cfilez
[ -f ./${d}/${f}.asm ] && echo "${d} ${f}" >> afilez
done
sh make-sumo.sh > ffmpegsumo.ninja
sh make-yasm.sh > ffmpeg_yasm.ninja
#!/bin/sh
cat<<EOF
defines = -DV8_DEPRECATION_WARNINGS -D_FILE_OFFSET_BITS=64 -DCHROMIUM_BUILD $
-DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_DEFAULT_RENDER_THEME=1 $
-DUSE_LIBJPEG_TURBO=1 -DUSE_NSS=1 -DUSE_X11=1 -DENABLE_ONE_CLICK_SIGNIN $
-DGTK_DISABLE_SINGLE_INCLUDES=1 -DUSE_XI2_MT=2 -DENABLE_REMOTING=1 $
-DENABLE_WEBRTC=1 -DENABLE_PEPPER_CDMS -DENABLE_CONFIGURATION_POLICY $
-DENABLE_INPUT_SPEECH -DENABLE_NOTIFICATIONS -DUSE_UDEV $
-DENABLE_EGLIMAGE=1 -DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 $
-DENABLE_PLUGIN_INSTALLATION=1 -DENABLE_PLUGINS=1 $
-DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_BACKGROUND=1 $
-DENABLE_AUTOMATION=1 -DENABLE_GOOGLE_NOW=1 -DCLD_VERSION=2 $
-DENABLE_FULL_PRINTING=1 -DENABLE_PRINTING=1 -DENABLE_SPELLCHECK=1 $
-DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_MANAGED_USERS=1 $
-DENABLE_MDNS=1 -DHAVE_AV_CONFIG_H -D_POSIX_C_SOURCE=200112 $
-D_XOPEN_SOURCE=600 -DPIC -D_ISOC99_SOURCE -D_LARGEFILE_SOURCE -DNDEBUG $
-DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0
includes = -I../../third_party/ffmpeg/chromium/config/Chromium/linux/x64 $
-I../../third_party/ffmpeg
cflags = -fstack-protector --param=ssp-buffer-size=4 -pthread $
-fno-exceptions -fno-strict-aliasing -Wno-unused-parameter $
-Wno-missing-field-initializers -pipe -fPIC -Wno-unused-local-typedefs $
-fPIC -fomit-frame-pointer -w -std=c99 -pthread -fno-math-errno $
-fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer $
-Wno-deprecated-declarations -Wno-format -fuse-ld=gold $
-Wno-unused-result -O2 -fno-ident -fdata-sections -ffunction-sections $
-funwind-tables
cflags_c =
cflags_cc = -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden $
-Wno-deprecated
EOF
cat cfilez | while read d f; do
cat <<EOF
build obj/third_party/ffmpeg${d}/ffmpegsumo.${f}.o: cc $
../../third_party/ffmpeg${d}/${f}.c || $
obj/third_party/ffmpeg/ffmpeg_yasm.actions_rules_copies.stamp
EOF
done
cat<<EOF
ldflags = -Wl,-z,now -Wl,-z,relro -fuse-ld=gold -pthread -Wl,-z,noexecstack $
-fPIC $
-B/media/xaiki/7e67bbed-44fb-4f14-a59e-1a9cc2b6a7ca/build-area/chromium-browser-34.0.1847.116/src/third_party/gold $
-Wl,-Bsymbolic -Lgen/third_party/ffmpeg -Wl,--icf=none -Wl,-O1 $
-Wl,--as-needed -Wl,--gc-sections
libs = -lz
build libffmpegsumo.so libffmpegsumo.so.TOC: solink_module $
EOF
cat cfilez | while read d f; do
cat <<EOF
obj/third_party/ffmpeg${d}/ffmpegsumo.${f}.o $
EOF
done
cat<<EOF
obj/third_party/ffmpeg/libffmpeg_yasm.a
soname = libffmpegsumo.so
lib = libffmpegsumo.so
EOF
#!/bin/sh
cat<<EOF
rule ffmpeg_yasm_target_assemble_0e7c357cbd4da6a91e9b60305e71c941
command = cd ../../third_party/ffmpeg; ../../out/Release/yasm -DPIC $
-DARCH_X86_64 -I chromium/config/Chromium/linux/x64 -I $
libavcodec/x86/ -I libavutil/x86/ -I . -w -P config.asm -DPIC -felf64 $
-m amd64 -o "../../out/Release/gen/third_party/ffmpeg/yasm/\${root}.o" $
"${source}"
description = RULE Compile assembly \${source}
restat = 1
EOF
cat afilez | while read d f; do
u=`md5sum ./${d}/${f}.asm | cut -d' ' -f1`;
D=`echo $d | sed s/'^\/'//`;
cat <<EOF
build gen/third_party/ffmpeg/yasm/${f}.o: $
ffmpeg_yasm_target_assemble_0e7c357cbd4da6a91e9b60305e71c941 $
../../third_party/ffmpeg${d}/${f}.asm | yasm || yasm
source = ${D}/${f}.asm
root = ${f}
unique_name = ${u}
EOF
done
cat<<EOF
build obj/third_party/ffmpeg/ffmpeg_yasm.actions_rules_copies.stamp: stamp $
EOF
cat afilez | while read d f; do
cat<<EOF
gen/third_party/ffmpeg/yasm/${f}.o $
EOF
done
cat<<EOF
defines = -DV8_DEPRECATION_WARNINGS -D_FILE_OFFSET_BITS=64 -DCHROMIUM_BUILD $
-DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_DEFAULT_RENDER_THEME=1 $
-DUSE_LIBJPEG_TURBO=1 -DUSE_NSS=1 -DUSE_X11=1 -DENABLE_ONE_CLICK_SIGNIN $
-DGTK_DISABLE_SINGLE_INCLUDES=1 -DUSE_XI2_MT=2 -DENABLE_REMOTING=1 $
-DENABLE_WEBRTC=1 -DUSE_PROPRIETARY_CODECS -DENABLE_PEPPER_CDMS $
-DENABLE_CONFIGURATION_POLICY -DENABLE_INPUT_SPEECH $
-DENABLE_NOTIFICATIONS -DUSE_UDEV -DENABLE_EGLIMAGE=1 $
-DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 $
-DENABLE_PLUGIN_INSTALLATION=1 -DENABLE_PLUGINS=1 $
-DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_BACKGROUND=1 $
-DENABLE_AUTOMATION=1 -DENABLE_GOOGLE_NOW=1 -DCLD_VERSION=2 $
-DENABLE_FULL_PRINTING=1 -DENABLE_PRINTING=1 -DENABLE_SPELLCHECK=1 $
-DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_MANAGED_USERS=1 $
-DENABLE_MDNS=1 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0
includes =
cflags = -fstack-protector --param=ssp-buffer-size=4 -pthread $
-fno-exceptions -fno-strict-aliasing -Wno-unused-parameter $
-Wno-missing-field-initializers -fvisibility=hidden -pipe -fPIC $
-Wno-unused-local-typedefs -Wno-format -fuse-ld=gold -Wno-unused-result $
-O2 -fno-ident -fdata-sections -ffunction-sections -funwind-tables
cflags_c =
cflags_cc = -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden $
-Wno-deprecated
build obj/third_party/ffmpeg/ffmpeg_yasm.xcode_hack.o: cc $
../../third_party/ffmpeg/xcode_hack.c || $
obj/third_party/ffmpeg/ffmpeg_yasm.actions_rules_copies.stamp
build obj/third_party/ffmpeg/libffmpeg_yasm.a: alink_thin $
obj/third_party/ffmpeg/ffmpeg_yasm.xcode_hack.o $
EOF
cat afilez | while read d f; do
cat<<EOF
gen/third_party/ffmpeg/yasm/${f}.o $
EOF
done
cat<<EOF
gen/third_party/ffmpeg/yasm/lls.o || $
obj/third_party/ffmpeg/ffmpeg_yasm.actions_rules_copies.stamp
EOF
Copy link

ghost commented May 3, 2014

Why All the hacks? Why not just modify the build_ffmpeg.sh script, run it, then run copy_config.sh then just ninja -C out/Release -j8 ffmpegsumo.

That will build all dependencies of FFmpeg and will give you a libffmpegsumo.so in your out/Release folder.

@xaiki
Copy link
Author

xaiki commented May 3, 2014

it didn't work for me, not that nor generate_gyp.py

Copy link

ghost commented Jul 28, 2014

Hai again :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment