Thank you for your interest in contributing to Livepeer Media Server.
If your goal is making changes solely to Go part of the codebase, just follow Requirements section and make sure you have all dependencies to build Go scripts successfully. Debugging with Delve, GDB, or, visually, with IDE (e.g. JetBrains GoLand, Microsoft VS Code) should work fine.
When working on CGO interface, or FFmpeg fork, chances are you might want to create a separate debug build of all components. While production build links with static libraries of Ffmpeg, it's more convenient to use shared libraries for debugging, because this way there's no need to re-build GO executable after every change in Ffmpeg code.
- Copy
~/compiled
dir created byinstall_ffmpeg.sh
tocompiled_debug
- If you want to keep system-wide Ffmpeg installation, remove/rename system
pkg-config
(.pc) files of Ffmpeg libs (located in/usr/local/lib/pkgconfig/
on most Linux distros). Otherwise,pkg-config
will prioritize system libs without debug information. - FFmpeg should be already cloned after running
install_ffmpeg.sh
. Navigate to FFmpeg dir and runconfigure
as below, making sure all paths are correct.export ROOT=/projects/livepeer/src export PATH="$ROOT/compiled_debug/bin":$PATH export PKG_CONFIG_PATH="${PKG_CONFIG_PATH:-}:$ROOT/compiled_debug/lib/pkgconfig" ./configure --fatal-warnings \ --enable-gnutls --enable-libx264 --enable-gpl \ --enable-protocol=https,http,rtmp,file,pipe \ --enable-muxer=mpegts,hls,segment,mp4,null --enable-demuxer=flv,mpegts,mp4,mov \ --enable-bsf=h264_mp4toannexb,aac_adtstoasc,h264_metadata,h264_redundant_pps,extract_extradata \ --enable-parser=aac,aac_latm,h264 \ --enable-filter=abuffer,buffer,abuffersink,buffersink,afifo,fifo,aformat,format \ --enable-filter=aresample,asetnsamples,fps,scale,hwdownload,select,livepeer_dnn,signature \ --enable-encoder=aac,libx264 \ --enable-decoder=aac,h264 \ --extra-cflags="-I${ROOT}/compiled_debug/include -g3 -ggdb -fno-inline" \ --extra-ldflags="-L${ROOT}/compiled_debug/lib ${EXTRA_LDFLAGS}" \ --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvenc --enable-decoder=h264_cuvid --enable-filter=scale_cuda --enable-encoder=h264_nvenc \ --enable-libtensorflow \ --prefix="$ROOT/compiled_debug" \ --enable-debug=3 \ --disable-optimizations \ --disable-stripping --disable-static --enable-shared
- Run
make install
- Build Go apps with debug information. Use absolute path in
PKG_CONFIG_PATH
to point tocompiled_debug
dir:PKG_CONFIG_PATH=/projects/livepeer/src/compiled_debug/lib/pkgconfig go build -a -gcflags all="-N -l" cmd/scenedetection/scenedetection.go
- Finally, run the binary with GDB.
LD_LIBRARY_PATH
should point tocompiled_debug
dir:LD_LIBRARY_PATH="../compiled_debug/lib/" gdb --args scenedetection 0 ../bbb/source.m3u P144p30fps16x9 nv 0
- Optionally, you can install
gdbgui
withpip install gdbgui
and use it in place ofgdb
for visual debugging.
Make sure that:
- Your executable is linked against (can find) correct libraries
LD_LIBRARY_PATH="../compiled_debug/lib/" ldd ./scenedetection
- Your executable / libraries has debug information
objdump --syms compiled_debug/lib/libavcodec.so
Unfortunately, this is a limitation of GDB when debugging GO code. A workaround is to set separate breakpoints and navigate between them with continue
.