How to stream screen recording with mjpg-streamer? - gstreamer

How to stream screen recording with mjpg-streamer which specified in below
https://github.com/jacksonliam/mjpg-streamer
In examples shows recording webcam or file, but I want to record current desktop to stream
./mjpg_streamer -i "./input_uvc.so -f -1 -r 320x240 -d /dev/video0 -n" -o "./output_http.so -w ./www -p 8080"
./mjpg_streamer -i "./input_opencv_file.so -f 60 -d cam0_0001.m4v" -o "./output_http.so -w ./www -p 8080"

Related

Emsripten compiled qt application does not show images

I have some Qt chess application. Everything works fine when i build it using VS compiler or gcc but I have problem with web assembly version using emscripten. When i run html with emrun everything is ok but images just does not show up.
My emscripten version is emcc (Emscripten gcc/clang-like replacement) 1.38.30 (commit d33f7a29002a2463a7956cd53a559b97a52f9560).
My qmake version: QMake version 3.1
My Qt version: Using Qt version 5.13.0
I am using official Qt binaries from online linux installer for wasm.
I am using emrun --no_browser .html command to set up server on localhost.
I tried different kinds of paths specification.
I ended up with this code example, works ok but not with web assembly version.
This is code to load an example image.
...
QDir::setSearchPaths("qrc", QStringList(":/"));
return QIcon(QUrl("qrc:///Images/king_white.svg").toString());
this is my .qrc file:
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>Images/king_black.svg</file>
...
</qresource>
</RCC>
in .pro file I also have:
RESOURCES = resources.qrc
It works okay when I am not using emscripten.
Thanks for help.
EDIT:
Build options (from Makefile generated by qmake)
CC = emcc
CXX = em++
DEFINES = -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
CFLAGS = -pipe -O3 -s ALLOW_MEMORY_GROWTH=1 -Wall -W $(DEFINES)
CXXFLAGS = -pipe -O3 -std=gnu++1y -s ALLOW_MEMORY_GROWTH=1 -Wall -W $(DEFINES)
INCPATH = -I. -I../../Qt513/5.13.0/wasm_32/include -I../../Qt513/5.13.0/wasm_32/include/QtWidgets -I../../Qt513/5.13.0/wasm_32/include/QtGui -I../../Qt513/5.13.0/wasm_32/include/QtCore -I. -I/home/somas/.emscripten_ports/openssl/include -I../../Qt513/5.13.0/wasm_32/mkspecs/wasm-emscripten
QMAKE = /home/somas/Qt513/5.13.0/wasm_32/bin/qmake
DEL_FILE = rm -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
COPY = cp -f
COPY_FILE = cp -f
COPY_DIR = cp -f -R
INSTALL_FILE = install -m 644 -p
INSTALL_PROGRAM = install -m 755 -p
INSTALL_DIR = cp -f -R
QINSTALL = /home/somas/Qt513/5.13.0/wasm_32/bin/qmake -install qinstall
QINSTALL_PROGRAM = /home/somas/Qt513/5.13.0/wasm_32/bin/qmake -install qinstall -exe
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
TAR = tar -cf
COMPRESS = gzip -9f
DISTNAME = ChessNewGeneration.js1.0.0
DISTDIR = /home/somas/ChessNewGeneration/ChessNewGeneration/.tmp/ChessNewGeneration.js1.0.0
LINK = em++
LFLAGS = -s WASM=1 -s FULL_ES2=1 -s USE_WEBGL2=1 -s NO_EXIT_RUNTIME=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 --bind -s "BINARYEN_TRAP_MODE='clamp'" -O3 -s ALLOW_MEMORY_GROWTH=1
LIBS = $(SUBLIBS) /home/somas/Qt513/5.13.0/wasm_32/plugins/platforms/libqwasm.a /home/somas/Qt513/5.13.0/wasm_32/lib/libQt5EventDispatcherSupport.a /home/somas/Qt513/5.13.0/wasm_32/lib/libQt5FontDatabaseSupport.a /home/somas/Qt513/5.13.0/wasm_32/lib/libqtfreetype.a /home/somas/Qt513/5.13.0/wasm_32/lib/libQt5EglSupport.a /home/somas/Qt513/5.13.0/wasm_32/plugins/imageformats/libqgif.a /home/somas/Qt513/5.13.0/wasm_32/plugins/imageformats/libqicns.a /home/somas/Qt513/5.13.0/wasm_32/plugins/imageformats/libqico.a /home/somas/Qt513/5.13.0/wasm_32/plugins/imageformats/libqjpeg.a /home/somas/Qt513/5.13.0/wasm_32/plugins/imageformats/libqtga.a /home/somas/Qt513/5.13.0/wasm_32/plugins/imageformats/libqtiff.a /home/somas/Qt513/5.13.0/wasm_32/plugins/imageformats/libqwbmp.a /home/somas/Qt513/5.13.0/wasm_32/plugins/imageformats/libqwebp.a /home/somas/Qt513/5.13.0/wasm_32/lib/libQt5Widgets.a /home/somas/Qt513/5.13.0/wasm_32/lib/libQt5Gui.a /home/somas/Qt513/5.13.0/wasm_32/lib/libqtlibpng.a /home/somas/Qt513/5.13.0/wasm_32/lib/libqtharfbuzz.a /home/somas/Qt513/5.13.0/wasm_32/lib/libQt5Core.a /home/somas/Qt513/5.13.0/wasm_32/lib/libqtpcre2.a
AR = emar cqs
RANLIB =
SED = sed
STRIP =
I presume that by "when I am not using emscripten" means the regular, dynamically-loaded Qt. Image format plugins included in such installations are dynamic libraries and can be loaded on demand by Qt - this is the mechanism used to load the svg format plugin if it is required.
The emscripten Qt builds are currently only static libraries - these must be linked together in advance as they cannot be dynamically loaded when required. In order to make qmake aware which plugins you will need, add
QTPLUGIN += qsvg
to your project file. You will probably want to make it wasm-specific to
avoid interference on other platforms:
wasm {
QTPLUGIN += qsvg
}

Launch tests normally when not in debug mode

For my C++ project have the following Makefile:
GDB=gdb
DEBUG ?= 1
ifeq ($(DEBUG), 1)
CCFLAGS =-DDEBUG
RUNPATH =${GDB}
else
CCFLAGS=-DNDEBUG
RUNPATH="/bin/sh -c"
endif
CPP=g++ ${CCFLAGS}
TESTGEN=cxxtestgen
CFLAGS_DBG=""
TEST_BUILD_PATH="./build/tests"
BUILD_PATH="./build"
TESTS_SRC_PATH="./tests"
SRC_PATH=""
# NORMAL TARGETS
# To Be filled
# RUN TESTS
test_command_parser_gen:
${TESTGEN} --error-printer -o ${TESTS_SRC_PATH}/CommandParser/runner.cpp ./tests/CommandParser/testCommandParser.h
test_command_parser_build: test_command_parser_gen
${CPP} -o ${TEST_BUILD_PATH}/commandParser ${TESTS_SRC_PATH}/CommandParser/runner.cpp ./src/tools/command_parser.cpp
test_command_parser_run: test_command_parser_build
${RUNPATH} ./build/tests/commandParser
clean:
find ./build ! -name '.gitkeep' -type f -exec rm -f {} + && find ./tests ! -name *.h -type f -exec rm -f {} +
When I launch the tests via the command:
make test_command_parser_run
As expected the gdb fires up and I can use it to debug the test. But sometimes I need just to run the test as is (eg. when in CI) therefore I use the following command to do so:
make test_command_parser_run DEBUG=0
But in that case I get the following error:
cxxtestgen --error-printer -o "./tests"/CommandParser/runner.cpp ./tests/CommandParser/testCommandParser.h
g++ -DNDEBUG -o "./build/tests"/commandParser "./tests"/CommandParser/runner.cpp ./src/tools/command_parser.cpp
"/bin/sh -c" ./build/tests/commandParser
/bin/sh: 1: /bin/sh -c: not found
Makefile:31: recipe for target 'test_command_parser_run' failed
make: *** [test_command_parser_run] Error 127
Therefore, I wanted to know how I can tell the make to execute the test without gdb when not in "debug" mode.
The whole idea behind this is somehow automatically debug my application without the need to remember the command and the compilation sequence to do so.
Remove quotes around /bin/sh -c, like so:
else
CCFLAGS=-DNDEBUG
RUNPATH=/bin/sh -c

Why is grep unable to match on string "-n" and "-e" in bash?

Long story short, narrowed my problem down to a one-liner:
for a in {a..z}; do echo "-$a" | grep "\-$a"; done
This prints all letters but -e and -n.
Looks like Linux version, bash version, flags to grep (-P, -E) etc do not matter!
Tested environments:
GNU bash, version 3.2.57(2)-release (x86_64-suse-linux-gnu) on SUSE Linux Enterprise Server 11 SP4
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin) on Cygwin (base-cygwin 3.8-1; cygwin32 2.10.0-1)
rextester (bash online compiler; GNU bash 4.3.46)
Why are not -e and -n printed?
(Removing the dashes in the code also removes the problem)
Problem is that -e, -n are valid echo options and echo is not printing them.
Moreover you should use -- in grep to separate options and pattern. Suggest you to use -F option in grep as well for fixed string search.
You may use:
for a in {a..z}; do grep -F -- "-$a" <<< "-$a"; done
-a
-b
-c
-d
-e
-f
-g
-h
-i
-j
-k
-l
-m
-n
-o
-p
-q
-r
-s
-t
-u
-v
-w
-x
-y
-z
Note that you may also use printf instead of echo:
for a in {a..z}; do printf -- '-%s\n' "$a" | grep -F -- "-$a"; done

make is truncating some compile commands under cygwin

I'm working on an electricity meter with a large existing code base and trying to introduce some automated testing. I've written a python script that decodes a Keil project file for ARM and generates a makefile. So most of the defines and include paths are actually defined in the keil project file. Well actually quite a few defines are added by me.
Said makefile is wonderful except it strips the first few characters from some compile commands. The two lines below are examples of a good compile command, and a bad one. It's easy to see "g++ -" has been stripped from the beginning of the compile command.
It's always those 5 characters. The one hint I have is that the files that fail have relatively long paths.
Defining SHELL=/bin/bash changes nothing.
g++ -c ../Project/External/HAL/src/HWRNG.cpp -o obj/HWRNG.o -D IO="" -D __I="" -D __packed="" -D ubyte8="unsigned long long" -std=c++11 -w -fpermissive -D __GNUC -D __USE_C99_MATH -D LOGICAL_NAME_REFERENCING -D EOSAL_NAMESPACE=CosemMeter -D USE_RTX -D STM32F412xG -D USE_STDPERIPH_DRIVER -D HSE_VALUE=24000000 -D DEBUG_UART -D OLD_MCOR -D ENABLE_LTE_MODEM -I ../trace -I ../trace/EOSAL/src -I patch/include -I ../Project -I ../Project/Hardware -I ../Project/External/CosemServerLib -I ../Project/External/CosemServerLib/Project -I ../Project/External/CosemServerLib/External -I ../Project/External/HAL/inc -I ../Project/External/HAL/STM/32F4xx/drivers/inc -I ../Project/External/STM32F4xx/CMSIS/Device/ST/STM32F4xx/Include -I ../Project/External/STM32F4xx/CMSIS/Include -I ../Project/External/STM32F4xx/STM32F4xx_StdPeriph_Driver/inc -I ../Project/lib -I ../Project/lib/RTX/inc -I ../Project/lib/RTX/inc/RTL -I ../Project/lib/Mocana/src -I ../Project/Middlewares/Segger/USBH -I ../Project/Middlewares/Segger/Inc -I ../Project/SeggerCfg -I ../Project/LTE/inc
c ../Project/External/HAL/STM/32F4xx/drivers/src/EXTI_Driver.c -o obj/EXTI_Driver.o -D __IO="" -D __I="" -D __packed="" -D ubyte8="unsigned long long" -D __USE_C99_MATH -D LOGICAL_NAME_REFERENCING -D EOSAL_NAMESPACE=CosemMeter -D USE_RTX -D STM32F412xG -D USE_STDPERIPH_DRIVER -D HSE_VALUE=24000000 -D DEBUG_UART -D OLD_MCOR -D ENABLE_LTE_MODEM -I ../trace -I ../trace/EOSAL/src -I patch/include -I ../Project -I ../Project/Hardware -I ../Project/External/CosemServerLib -I ../Project/External/CosemServerLib/Project -I ../Project/External/CosemServerLib/External -I ../Project/External/HAL/inc -I ../Project/External/HAL/STM/32F4xx/drivers/inc -I ../Project/External/STM32F4xx/CMSIS/Device/ST/STM32F4xx/Include -I ../Project/External/STM32F4xx/CMSIS/Include -I ../Project/External/STM32F4xx/STM32F4xx_StdPeriph_Driver/inc -I ../Project/lib -I ../Project/lib/RTX/inc -I ../Project/lib/RTX/inc/RTL -I ../Project/lib/Mocana/src -I ../Project/Middlewares/Segger/USBH -I ../Project/Middlewares/Segger/Inc -I ../Project/SeggerCfg -I ../Project/LTE/inc
/bin/sh: c: command not found
make: [Makefile:167: obj/EXTI_Driver.o] Error 127 (ignored)
I was on the road for the last few weeks and showed my problem to a colleague yesterday. He immediately noticed it was the C compiles so behaving and the C++ were behaving properly. I had misdefined the CC symbol for C comiles.

lcov, reporting 0% coverage for not tested headers

i will ask using an example. Let's suppose the following files:
root
- yes.h
- not.h
- test.cpp
"test.cpp" includes "yes.h"
when I run lcov shows the percentage covered in yes.h and in test.cpp, but (and here's my question) I want a zero coverage entry for "not.h", this way I can really have a valuable coverage metric. There's any way to achieve this?
Here's my lcov usage:
g++ --coverage test.cpp
lcov --directory . --zerocounters
lcov -c -i -d . -o app_base.info
./a.out
lcov -c -d . -o app_test.info
lcov -a app_base.info -a app_test.info -o app_total.info
geninfo app_total.info
thanks.
You might want to take a look at the --remove and --extract options for lcov (see the man page).
In your case, you might want to change
lcov -a app_base.info -a app_test.info -o app_total.info
geninfo app_total.info
with
lcov -a app_base.info -a app_test.info -o app_tmp.info
lcov --remove app_tmp.info */not.h --output app_total.info
geninfo app_total.info