Is X11 required for adding text overlay? - mlt

I'm trying to run the below command in a script and it seems it's not adding any text layout to the video, I'm sure I didn't it before and it was fine.
My question is, do I need to set up X11 environment in order to use dynamictext or text filters?
Thanks in advance.
/usr/bin/melt \
"/var/www/html/test/nkLcBPkebo/t-1.mp4" \
-audio-track \
"/var/www/html/test/nkLcBPkebo/t-1_sound.mp4" \
-attach-track \
"text:This is my best video" \
-0 \
in=0 out=0 fgcolour="#004fed" bgcolour=0 olcolour="#fff200" outline=3 pad="50x0" size=80 weight=700 style="italic" halign="center" valign="top" family="Ubuntu" \
-profile hdv_720_25p -progress \
-consumer avformat:"/var/www/html/test/nkLcBPkebo/1.mp4" \
vcodec="libx264" vb="5000k" acodec="aac" ab="128k" frequency=44100 deinterlace=1

I think I found the issue! it's was all about the order of the parameters :)
Having the text right after the video (before the audio) should fix it
/usr/bin/melt \
"/var/www/html/test/nkLcBPkebo/t-1.mp4" \
-attach-track \
"text:This is my best video" \
-0 \
in=0 out=0 fgcolour="#004fed" bgcolour=0 olcolour="#fff200" outline=3 pad="50x0" size=80 weight=700 style="italic" halign="center" valign="top" family="Ubuntu" \
-audio-track \
"/var/www/html/test/nkLcBPkebo/t-1_sound.mp4" \
-profile hdv_720_25p -progress \
-consumer avformat:"/var/www/html/test/nkLcBPkebo/1.mp4" \
vcodec="libx264" vb="5000k" acodec="aac" ab="128k" frequency=44100 deinterlace=1

Related

Crop filter isn't applied to mixing transitions?

When I apply a -filter crop parameter to my melt script, it only seems to crop each clip - not the -mix mixing between clips.
melt \
clip1.mp4 in=180 out=360 \
-mix 20 -mixer luma -mixer mix:-1 \
clip2.mp4 in=660 out=960 \
-mix 20 -mixer luma -mixer mix:-1 \
clip3.mp4 in=1080 out=1300 \
-filter crop left=420 right=420 \
-consumer avformat:"output.mp4" ab=128k crf=23 -profile "./square_profile.txt"
Is there some other way I can apply a crop that works with -mix transitions?
Solving my own problem:
The solution is to add a crop for each file, using -attach instead of -filter
melt \
clip1.mp4 in=180 out=360 \
-attach crop left=420 right=420 \
-mix 20 -mixer luma -mixer mix:-1 \
clip2.mp4 in=660 out=960 \
-attach crop left=420 right=420 \
-mix 20 -mixer luma -mixer mix:-1 \
clip3.mp4 in=1080 out=1300 \
-attach crop left=420 right=420 \
-consumer avformat:"output.mp4" ab=128k crf=23 -profile "./square_profile.txt"

Array to strings of index value pairs

I would like to create a string of index and value pairs. This is to be used in dialog menu.
declare -r -a arr=(
piano
table
chair
)
dialog \
--backtitle "Launcher" \
--title "App" \
--ok-label 'Select' \
--cancel-label "Back" \
--menu "Select an application" \
$dialog_height $dialog_width 4 \
"1" "piano" \
"2" "table" \
"3" "chair"
So I'm looking to have the:
"1" "piano" \
"2" "table" \
"3" "chair"
generated automatically from array.
There's a similar question pass an array to dialog menu I tried what's there I couldn't get it to work for me.
To auto-generate the tags 1, 2, 3 in front of every array entry, use
items=(piano table chair)
taggedItems=()
for ((i=1; i<="${#items[#]}"; ++i)); do
taggedItems+=("$i" "${items[i-1]}")
done
# then use "${taggedItems[#]}"
Opposed to your linked awk solution, this works with arbitrary items that may contain spaces, special symbols like * and even linebreaks.
declare -a arr=(
''
piano
table
chair
)
unset 'arr[0]'
declare -ar arr
# Remove the echo below once ready for the fun.
echo dialog \
--backtitle "Launcher" \
--title "App" \
--ok-label 'Select' \
--cancel-label "Back" \
--menu "Select an application" \
$dialog_height $dialog_width 4 \
$(for i in "${!arr[#]}"; do echo "$i" "${arr[i]}"; done)
OPTIONS=(1 "table"
2 "piano"
3 "......")
dialog \
--backtitle "Launcher" \
--title "App" \
--ok-label 'Select' \
--cancel-label "Back" \
--menu "Select an application" \
$dialog_height $dialog_width 4 \
"${OPTIONS[#]}" \
2>&1 >/dev/tty
There are two ways, using simple array:
#!/bin/bash
declare -r -a arr=(
piano
table
chair
)
options=$(printf '%s\n' "${arr[#]}" | awk '{print v++,$arr}')
dialog \
--backtitle "Test" \
--title "Test" \
--menu "Test" \
0 0 4 \
$options \
2>&1 >/dev/tty
Or with associative array:
#!/bin/bash
declare -r -A arr=(
piano
table
chair
)
options=$(printf '%s\n' "${!arr[#]}" | awk '{print v++,$arr}')
dialog \
--backtitle "Test" \
--title "Test" \
--menu "Test" \
0 0 4 \
$options \
2>&1 >/dev/tty
To start menu numbers at 1:
#!/bin/bash
declare -r -a arr=(
piano
table
chair
)
options=$(printf '%s\n' "${arr[#]}" | awk -v v=1 '{print v++,$arr}')
dialog \
--backtitle "Test" \
--title "Test" \
--menu "Test" \
0 0 4 \
$options \
2>&1 >/dev/tty
To use both key and value of associative array in menu:
#!/bin/bash
declare -r -A arr=(
[piano]=piano
[table]=mesa
[chair]=cadeira
)
options=$(printf "%s\n" "${!arr[#]} " "${arr[#]}")
dialog \
--backtitle "Test" \
--title "Test" \
--menu "Test" \
0 0 4 \
$options \
2>&1 >/dev/tty
Correct answer works both with normal and associative arrays of entries, using numerical index or associative key as menu key:
Normal array of menu entries, using numerical index as menu key:
#!/usr/bin/env bash
arr=(
piano
table
chair
)
options=()
for k in "${!arr[#]}"; do
options+=( "$k" "${arr[$k]}" )
done
dialog \
--backtitle "Test" \
--title "Test" \
--menu "Test" \
0 0 4 \
"${options[#]}" \
>/dev/tty 2>&1
Full example with associative array:
#!/usr/bin/env bash
declare -A assoc=(
[p]=piano
[t]=table
[c]=chair
)
options=()
for k in "${!assoc[#]}"; do
options+=("$k" "${assoc[$k]}")
done
choice="$(
dialog \
--backtitle "Test" \
--title "Test" \
--menu "Test" \
0 0 4 \
"${options[#]}" \
2>&1 >/dev/tty
)"
clear
case $choice in
t)
printf %s\\n "Let's set the table."
;;
p)
printf %s\\n "Let's play piano."
;;
c)
printf %s\\n "Let's sit dow."
;;
*)
printf %s\\n "Let's decide later."
;;
esac

Spark SQL JDBC empty dataframe

I'm trying to load the query result from one table to another. It connects fine and execute a query to get the metadata but no data is returned.
from pyspark.sql import SQLContext, Row, SparkSession
spark = SparkSession.builder.config("spark.driver.extraClassPath", "C:\\spark\SQL\\sqljdbc_7.0\\enu\\mssql-jdbc-7.0.0.jre10.jar").getOrCreate()
SQL = "Select [InvoiceID],[CustomerID],[BillToCustomerID],[OrderID],[DeliveryMethodID],[ContactPersonID],[AccountsPersonID],[SalespersonPersonID],[PackedByPersonID],[InvoiceDate],[CustomerPurchaseOrderNumber],[IsCreditNote],[CreditNoteReason],[Comments],[DeliveryInstructions],[InternalComments],[TotalDryItems],[TotalChillerItems],[DeliveryRun],[RunPosition],[ReturnedDeliveryData],[ConfirmedDeliveryTime],[ConfirmedReceivedBy],[LastEditedBy],[LastEditedWhen] FROM [Sales].[Invoices]"
pgDF = spark.read \
.format("jdbc") \
.option("url", "jdbc:sqlserver://Localhost") \
.option("query", SQL) \
.option("user", "dp_admin") \
.option("Database", "WideWorldImporters") \
.option("password", "password") \
.option("fetchsize", 1000) \
.load(SQL)
pgDF.write \
.format("jdbc") \
.option("url", "jdbc:sqlserver://Localhost") \
.option("dbtable", "wwi.Sales_InvoiceLines") \
.option("user", "dp_admin") \
.option("Database", "DW_Staging") \
.option("password", "password") \
.option("mode", "overwrite")
Looking at the sql server profiler :
exec sp_executesql N'SELECT * FROM (Select [InvoiceID],[CustomerID],[BillToCustomerID],[OrderID],[DeliveryMethodID],[ContactPersonID],[AccountsPersonID],[SalespersonPersonID],[PackedByPersonID],[InvoiceDate],[CustomerPurchaseOrderNumber],[IsCreditNote],[CreditNoteReason],[Comments],[DeliveryInstructions],[InternalComments],[TotalDryItems],[TotalChillerItems],[DeliveryRun],[RunPosition],[ReturnedDeliveryData],[ConfirmedDeliveryTime],[ConfirmedReceivedBy],[LastEditedBy],[LastEditedWhen] FROM [Sales].[Invoices]) __SPARK_GEN_JDBC_SUBQUERY_NAME_0 WHERE 1=0'
the where 1= 0 gets added and no data is returned, why and how to remove it?

can not build Qt5 framework by Yocto project for qemuarm

I'm trying to run Qt5 framework through eglfs instead of X11 or wayland.
I'm trying to install Qt5 for qemuarm emualting Raspberry pi 3 based on yocto Rocko.
This is my bblayers.conf:
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
SRCPATH = "/home/yocto/yocto"
BBFILES ?= ""
BBLAYERS ?= " \
${SRCPATH}/meta \
${SRCPATH}/meta-poky \
${SRCPATH}/meta-openembedded/meta-oe \
${SRCPATH}/meta-openembedded/meta-multimedia \
${SRCPATH}/meta-openembedded/meta-networking \
${SRCPATH}/meta-openembedded/meta-perl \
${SRCPATH}/meta-openembedded/meta-python \
${SRCPATH}/meta-qt5 \
${SRCPATH}/meta-raspberrypi \
${SRCPATH}/meta-security \
and this is my local.conf:
MACHINE ??= "qemuarm"
DL_DIR ?= "${TOPDIR}/../downloads"
DISTRO ?= "poky"
PACKAGE_CLASSES ?= "package_deb"
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
USER_CLASSES ?= "buildstats image-mklibs image-prelink"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS = "\
STOPTASKS,${TMPDIR},1G,100K \
STOPTASKS,${DL_DIR},1G,100K \
STOPTASKS,${SSTATE_DIR},1G,100K \
STOPTASKS,/tmp,100M,100K \
ABORT,${TMPDIR},100M,1K \
ABORT,${DL_DIR},100M,1K \
ABORT,${SSTATE_DIR},100M,1K \
ABORT,/tmp,10M,1K"
LICENSE_FLAGS_WHITELIST = "commercial"
CONF_VERSION = "1"
PREFERRED_VERSION_linux-raspberrypi = "4.%"
DISTRO_FEATURES_remove = "x11 wayland"
DISTRO_FEATURES_append = " systemd opengl pam ${DISTRO_FEATURES_LIBC}"
VIRTUAL-RUNTIME_init_manager = "systemd"
EXTRA_IMAGE_FEATURES += "package-management splash"
INHERIT+="toaster buildhistory"
CORE_IMAGE_EXTRA_INSTALL += "openssh"
ENABLE_UART="1"
#PACKAGECONFIG_append_qtbase = " accessibility eglfs fontconfig gles2 linuxfb"
################### QT ######################
QT_DEV_TOOLS = " \
qtbase-dev \
qtbase-mkspecs \
qtbase-plugins \
qtbase-tools \
qtserialport-dev \
qtserialport-mkspecs \
"
QT_TOOLS = " \
qtbase \
qtserialport \
"
FONTS = " \
fontconfig \
fontconfig-utils \
ttf-bitstream-vera \
"
TSLIB = " \
tslib \
tslib-conf \
tslib-calibrate \
tslib-tests \
tspress \
"
QT5_PKGS = " \
qt3d \
qtcharts \
qtdeclarative \
qtdeclarative-plugins \
qtdeclarative-qmlplugins \
qtgraphicaleffects \
qtlocation-plugins \
qtmultimedia \
qtquickcontrols2 \
qtsensors-plugins \
qtserialbus \
qtsvg \
qtwebsockets-qmlplugins \
qtvirtualkeyboard \
qtxmlpatterns \
"
QML_APPS = " \
qqtest \
"
CORE_IMAGE_EXTRA_INSTALL += " \
${FONTS} \
${QT_TOOLS} \
${QT5_PKGS} \
cinematicexperience \
"
I'm trying to build this image bitbake rpi-hwup-image
the problem is with qtbase, it fails with this error:
| ERROR: Feature 'opengl-desktop' was enabled, but the pre-condition '(config.win32 && !config.winrt && !features.opengles2 && (config.msvc || libs.opengl))
| || (!config.watchos && !config.win32 && libs.opengl)' failed.
|
| ERROR: The OpenGL functionality tests failed!
| You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2],
| QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.
Update
This problem is solved by uncommenting PACKAGECONFIG_append_qtbase and it has a typo so, it's been updated to be PACKAGECONFIG_append_pn-qtbase.
I added those lines too:
PACKAGECONFIG_append_pn-qemu-native = " sdl"
PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl".
I comment out this line LICENSE_FLAGS_WHITELIST = "commercial".
but it fails again at qtbase build by this error (this is the tail of the log file) (I deleted the tmp folder and started bitbake rpi-hwup-image again but it went to the same error)
| cd windowflags/ && ( test -e Makefile || /home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/recipe-sysroot-native/usr/bin/qt5/qmake -o Makefile /home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/git/examples/widgets/widgets/windowflags/windowflags.pro -qtconf /home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/build/bin/qt.conf ) && make -f Makefile
| make[4]: Entering directory '/home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/build/examples/widgets/widgets/windowflags'
| compiling /home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/git/examples/widgets/widgets/windowflags/controllerwindow.cpp
| compiling /home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/git/examples/widgets/widgets/windowflags/previewwindow.cpp
| linking wiggly
| make[4]: Leaving directory '/home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/build/examples/widgets/widgets/wiggly'
| compiling /home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/git/examples/widgets/widgets/windowflags/main.cpp
| linking validators
| generating .moc/moc_predefs.h
| moc /home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/git/examples/widgets/widgets/windowflags/controllerwindow.h
| make[4]: Leaving directory '/home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/build/examples/widgets/widgets/validators'
| moc /home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/git/examples/widgets/widgets/windowflags/previewwindow.h
| compiling .moc/moc_controllerwindow.cpp
| compiling .moc/moc_previewwindow.cpp
| linking windowflags
| make[4]: Leaving directory '/home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/build/examples/widgets/widgets/windowflags'
| make[3]: Leaving directory '/home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/build/examples/widgets/widgets'
| make[2]: Leaving directory '/home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/build/examples/widgets'
| make[1]: Leaving directory '/home/yocto/yocto/build/RP3_Qt/tmp/work/armv5e-poky-linux-gnueabi/qtbase/5.9.3+gitAUTOINC+4d8ae444c2-r0/build/examples'
| ERROR: oe_runmake failed
| WARNING: exit code 1 from a shell command.
I found the solution according to this page.
The configuration part -at this page- says something about ommiting the tests part at this option -nomake tests, it's the same part that fails at the compiling stage of qtbase.
so after cleaning qtbase and adding this part to my local.conf
PACKAGECONFIG_remove_pn-qtbase = " tests gl"
gl is omitted too because we want to build qtbase for eglfs not for desktop.

Using variables for shell script in C

I have a shell script in C which is defined as
#define SHELLSCRIPT "\
sed 's/./& \
inserted text \
/20' fileA.txt > fileB.txt \
"
When this shell script is run on terminal, it inserts the text inserted text in fileB.txt at offset 20. Now, I want this 20 fileA.txt and fileB.txt to be fetched from a variable.
How should I do that? I tried the following
#define SHELLSCRIPT "\
sed 's/./& \
inserted text \
/$i' fileA.txt > fileB.txt \
"
and in C before I run the above shell script, I run system("i=20"); but then I get this error below
sed: 1: "s/./& this comment has ...": bad flag in substitute command: '$'
How can I achieve this?
When you run system(), it starts up a fresh shell each time. So the shell that i=20 runs in is not the same shell that the sed command runs in.
Instead of $i in the script text, put %d there instead. Then you can use it as a format string to sprintf which can format the command into a separate variable.
#define SHELLSCRIPT "\
sed 's/./& \
inserted text \
/%d' fileA.txt > fileB.txt \
"
char command[500];
sprintf(command, SHELLSCRIPT, 20);
system(command);
how about you replace your script command
#define SHELLSCRIPT "\
sed 's/./& \
inserted text \
/%d' %s > %s \
"
and then you replace by your variables, before executing the command:
char cmd[100 +1];
sprintf(cmd, SHELLSCRIPT , 20, "file1", "file2");
system(cmd)

Resources