tp-link Smart Plugs with Energy Monitoring

Several years ago I picked up a TP-Link HS110 switch so that I could turn lights on and off on a schedule. It had an interesting feature of being able to monitor energy usage as well.

The HS110 has an unfortunate design that covers the second socket in a wall outlet and makes it unusable. I purchased several HS105 units over time because two can be plugged into a standard outlet with the only drawback being the extra distance the normal plug extends from the wall. The HS105 was on sale as multipack on a somewhat regular basis. The drawback of the HS105 is that it doesn’t offer energy monitoring.

I came across the HS300 power strip that offers six switched outlets plus energy monitoring for each outlet. It has a flat angled plug, allowing two devices to fit in a standard wall outlet.

Each of these devices seems to be rated at 15A (1875W) total. That should be fine, since most of the standard wall plugs they would be plugged into aren’t rated for more than that, but it’s interesting that the current handling of the largest devices is the same as the smallest.

The energy monitoring was an interesting feature, and I was hoping to get around to doing more than glancing at it from my phone occasionally. Nearly three years after my first purchase I finally got around to writing a program to do what I wanted to log the energy usage.

I’d come across https://www.softscheck.com/en/reverse-engineering-tp-link-hs110/ when I first bought the HS110, and thought I would get around to doing what I wanted quickly, but as with so many projects, it was set aside as less important. With the transient nature of the web, I’m glad that this site is still visible, and the resulting github repository tools proved invaluable for me getting my project working. https://github.com/softScheck/tplink-smartplug

There are several python projects for communicating with these devices which I also found useful, but I was hoping to build a small program with very few dependencies. Part of what I wanted to know was the communication protocol over the ethernet, and that took the most time to decipher.

https://github.com/wcbonner/KasaEnergyLogger is my project, with all of the work done in a single threaded C++ file. I’ll hopefully describe what I know of the protocol in the future. As it is, I’m pulling data from multiple devices and logging it using MRTG. I know there are significantly better graphics dashboards available, but this requires very little infrastructure, and I’m logging the raw data in case I ever really want to revisit it.

MRTG graph of AC Power Usage

For most people these devices connect to Alexa or Google Home and the scheduling plus voice controls are all that they will ever use.

I was very happy with having lamps set to turn on at sunset and turn off at specific times. The fact that I live at a latitude where sunset changes from after 9pm in the peak of summer to before 5pm midwinter was plenty for me. I also use them for controlling fans to adjust the climate in my home when I’m not relying on air conditioning.

From a system monitoring perspective I’ve considered having two Raspberry Pi, each plugged into a HS105, monitoring each other and power cycling the other device if it can’t be reached for a designated period of time.

Here are some of the other sites I found useful in getting to my current state:

GoveeBTTempLogger as a Debian Package

After getting my program to listen and log Bluetooth Low Energy advertisements from Govee thermometers running reliably, I needed to figure out how to make the program automatically start when my Raspberry was rebooted. I was led down two paths to get things working, systemd unit files, and debian package files created with dpkg-deb.

The final file structure I came up with is visible in https://github.com/wcbonner/GoveeBTTempLogger but still can use some explanation as to what I did.

To create the debian package, I created a file structure under my source repository that mimicked what I wanted to put on the target system.

\GOVEEBTTEMPLOGGER\GOVEEBTTEMPLOGGER
├───DEBIAN
│       control
│       postinst
│       postrm
│       prerm
│
├───etc
│   └───systemd
│       └───system
│               goveebttemplogger.service
│
├───usr
│   └───local
│       └───bin
│               goveebttemplogger
│
└───var
    └───log
        └───goveebttemplogger
                gvh507x.txt

I had decided I wanted my executable to be located in /usr/local/bin. It’s the file named goveebttemplogger. I wanted it to write log files into /var/log/goveebttemplogger/ and the easiest way to make sure that directory was created was to put a zero length file in that directory, gvh507x.txt.

The files in the DEBIAN directory are used by the dpkg-deb program when building the distributable package. More on those later.

To get the program configured to automatically run when the machine boots, and properly stop when it shuts down, I settled on the systemd unit files as the both the easiest and most reliable method. I’ve been around linux long enough to first think of /etc/rc.local manipulation, then script files for various runlevels in the /etc/init.d/ directories, and was amazed at both the power and ease of setting up to use the systemd unit files. The hardest part was figuring out what other services my program must have already started. I knew it was dependent on Bluetooth, but the specific services was a bit of a guess.

# Contents of /etc/systemd/system/goveebttemplogger.service
[Unit]
Description=GoveeBTTempLogger service
After=bluetooth.target dbus-org.bluez.service network.target
Requires=bluetooth.target
KillSignal=SIGINT

[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/goveebttemplogger -v 0 -l /var/log/goveebttemplogger/

[Install]
WantedBy=multi-user.target

After creating that file in the specified location, I was able to issue the following commands to make systemd start the program.

sudo systemctl daemon-reload
sudo systemctl enable goveebttemplogger.service
sudo systemctl start goveebttemplogger.service

The most unique bit of my unit file is that I specifically want my program to be sent the SIGINT signal to kill it, since I will recognize that and flush the log files before exiting. The ExecStart line is the command line to run my program, which I’m also specifying the log directory as one of the parameters.

I had the systemd unit file and the initial DEBIAN/control file figured out pretty easily. I’d come across this https://linuxconfig.org/easy-way-to-create-a-debian-package-and-local-package-repository article which helped understanding the control file.

Package: GoveeBTTempLogger
Version: 1.20200725-1
Section: custom
Priority: optional
Architecture: armhf
Essential: no
Installed-Size: 95
Maintainer: wcbonner@users.noreply.github.com
Description: Listen and log Govee Thermometer Bluetooth Low Energy Advertisments
Depends: libbluetooth3

What took me a while to figure out was how to get the systemctl commands to be run after the files were put in place by the package manager. There are four script commands, which I’m using three. preinst, postinst, prerm, and postrm. Each of them is a simple script and needs to be marked executable in the file system. They are each run at various stages by the package manager, Pre-Installation, Post-Installation, Pre-Removal, and Post-Removal.

#!/bin/sh
# POSTINST script for goveebttemplogger

echo "\033[36m HI I'M A POSTINST SCRIPT `date +"%s"` \033[39m"
systemctl daemon-reload
systemctl enable goveebttemplogger.service
systemctl start goveebttemplogger.service

exit 0

After installation of my program and the systemd unit file, I reload the systemd database, enable my service, and start my service.

#!/bin/sh
# PRERM script for goveebttemplogger

echo "\033[36m HI I'M A PRERM SCRIPT `date +"%s"` \033[39m"
systemctl stop goveebttemplogger.service
systemctl disable goveebttemplogger.service

exit 0

Before removal of my program, I stop the service and disable the service.

#!/bin/sh
# POSTRM script for goveebttemplogger

echo "\033[36m HI I'M A POSTRM SCRIPT `date +"%s"` \033[39m"
systemctl daemon-reload

exit 0

After removal of my program, I reload the systemd database, to make sure it’s not got my unit file in its database any longer.

When I retrieve a copy of my code with the command git clone https://github.com/wcbonner/GoveeBTTempLogger I then have a subdirectory below the GoveeBTTempLogger that is also named GoveeBTTempLogger. That deeper directory is the structure that will be created into the package.


GoveeBTTempLogger/usr/local/bin/goveebttemplogger: goveebttemplogger.cpp
        mkdir -p GoveeBTTempLogger/usr/local/bin
        g++ -lbluetooth goveebttemplogger.cpp -o GoveeBTTempLogger/usr/local/bin/goveebttemplogger

deb: GoveeBTTempLogger/usr/local/bin/goveebttemplogger GoveeBTTempLogger/DEBIAN/control GoveeBTTempLogger/etc/systemd/system/goveebttemplogger.service
        mkdir -p GoveeBTTempLogger/var/log/goveebttemplogger
        touch GoveeBTTempLogger/var/log/goveebttemplogger/gvh507x.txt
        chmod a+x GoveeBTTempLogger/DEBIAN/postinst GoveeBTTempLogger/DEBIAN/postrm GoveeBTTempLogger/DEBIAN/prerm
        dpkg-deb --build GoveeBTTempLogger

I made the very simple makefile above to both compile the code and build the debian package with the simple command of make deb. It produces the package ‘goveebttemplogger’ in ‘GoveeBTTempLogger.deb’.

I can then install the package and start it running with the command sudo apt-get install ./GoveeBTTempLogger.deb

I can stop and either remove it or purge it with the command sudo apt-get remove goveebttemplogger or sudo apt-get purge goveebttemplogger.

FlightAware and MRTG

Continuing to work on graphing data with MRTG, I finally figured out a valid script for graphing FlightAware messages from my PiAware. This is especially interesting to me because I have been playing around with different antennas and running on a couple of different Raspberry Pi platforms. On one of the platforms I’ve got two receivers, the primary one that listens on the 1090MHz frequency, and the secondary that listens on 978MHz. I’ve been especially interested in knowing how many reports come in on the secondary frequency.

Using the in and out property of MRTG graphs, I’ve got the In (green) representing 978 messages and the Out (blue) representing 1090 messages.

I added the following section to my /etc/snmp/snmpd.conf file:

pass .1.3.6.1.2.1.25.1.9 /bin/sh /usr/local/bin/snmp-dump1090
pass .1.3.6.1.2.1.25.1.10 /bin/sh /usr/local/bin/snmp-dump978
view systemonly included .1.3.6.1.2.1.25

I created two files in the /usr/local/bin directory that snmp references. /usr/local/bin/snmp-dump1090:

#!/bin/bash
if [ "$1" = "-g" ]; then
        echo .1.3.6.1.2.1.25.1.9
        echo gauge
        /bin/grep "dump1090-fa.*5m).*FlightAware" /var/log/piaware.log | /usr/bin/tail -n 1 | /usr/bin/cut -f2 -d"(" | /usr/bin/cut -f1 -d" "
fi

and /usr/local/bin/snmp-dump978:

#!/bin/bash
if [ "$1" = "-g" ]; then
        echo .1.3.6.1.2.1.25.1.10
        echo gauge
        /bin/grep "dump978-fa.*5m).*FlightAware" /var/log/piaware.log | /usr/bin/tail -n1 | cut -f2 -d"(" | /usr/bin/cut -f1 -d" "
fi

I added the following section to my /etc/mrtg.conf file:

######################################################################
#       FlightAware messages
######################################################################
Options[_]: gauge, nopercent, transparent, pngdate
Factor[_]:
MaxBytes[_]: 12500000
YLegend[_]: Messages
ShortLegend[_]: Messages
LegendO[_]: dump1090 messages
LegendI[_]: dump978 messages

# Target[WimPi4_piaware]: `/home/wim/MRTG-PiAware.sh`
Target[WimPi4_piaware]: .1.3.6.1.2.1.25.1.10&.1.3.6.1.2.1.25.1.9:public@WimPi4
Title[WimPi4_piaware]: Pi4 FlightAware messages
PNGTitle[WimPi4_piaware]: Pi4 FlightAware Messages
PageTop[WimPi4_piaware]: Pi4 FlightAware messages

Target[WimPiZeroCamera_dump1090]: .1.3.6.1.2.1.25.1.9&.1.3.6.1.2.1.25.1.9:public@WimPiZeroCamera
Options[WimPiZeroCamera_dump1090]: gauge, nopercent, transparent, pngdate, noi
Title[WimPiZeroCamera_dump1090]: PiZero FlightAware messages
PNGTitle[WimPiZeroCamera_dump1090]: PiZero FlightAware Messages
PageTop[WimPiZeroCamera_dump1090]: PiZero FlightAware messages

I was testing that snmp was responding with data using the snmpget commands, but I was getting zeros back. I could run the scripts directly while I was logged in with my regular account and they were producing results so I was scratching my head.

pi@WimPi4:~ $ snmpget -v 2c -c public wimpi4 .1.3.6.1.2.1.25.1.9
iso.3.6.1.2.1.25.1.9 = Gauge32: 130
pi@WimPi4:~ $ snmpget -v 2c -c public wimpi4 .1.3.6.1.2.1.25.1.10
iso.3.6.1.2.1.25.1.10 = Gauge32: 0

The extra complication that added about six hours to my figuring things out was that the /var/log/piaware.log log files were not all readable, only owner and group. The snmp daemon was not running as a member of any group that had access to that file. I verified the problem with the command:

sudo -u Debian-snmp cat /var/log/piaware.log

I fixed the problem with the quick hack of:

sudo chmod a+r /var/log/pi*

 

Govee H5075 and H5074, Bluetooth Low Energy, and MRTG

I have been wanting a method of keeping track of temperatures for a long time. Last week I acquired a Govee H5075 Bluetooth Thermometer Hygrometer. It communicates with an app from Govee on my iPhone using Bluetooth Low Energy (BLE).

I’ve now learned some details on BLE, and have written a program that listens for BLE advertisements from either type of thermometer and logs the temperature and humidity in a text file. The code for my project is available on GitHub. https://github.com/wcbonner/GoveeBTTempLogger

The same program can also be called to get the last value from the log and produce output compatible with MRTG. MRTG is not the best method for graphing these temperatures, because all graphs start with zero on the Y axis, and neither the temperature or humidity is likely to be near zero.

MRTG graph of Temperature and Relative Humidity

My program seems to receive advertisements from each thermometer about every ten seconds. I’ve had a friend running the code in his location with a different set of thermometers and it doesn’t get advertisements nearly as frequently. I don’t know if that’s just because environment is different, or if there’s something else going on.

Govee GVH5075 Thermometer Hygrometer

Last week I came across a deal on a small thermometer with display and Bluetooth access for under $10 so I had to give it a try. The fact that the data is available via bluetooth instead of via a web service was a major selling point for me. I am hoping to be able to to log the data via a Raspberry Pi4.

GVH5070 near my Raspberry Pi4

I installed the Govee Home app on my iPhone and it was able to find the device, communicate with it, and pull both current and accumulated data.

When I attempted to find it from my Pi4 it was much more difficult. I live in an apartment with units all around. I’m not just dealing with my own devices that may be visible, but my neighbors as well.

I managed to find the device using linux command line tools, but was not able to successfully connect. A friend suggested BLE Scanner 4.0 for my iPhone for discovering the details, and it was at least able to confirm what I should be looking for using the linux command line tools. I still had timeout issues with the iPhone app, but at least was able to confirm that I could connect to the device and retrieve GUID information.

This is my first time attempting to gather data from a Bluetooth device. I’m still in the research and test phase. I’m listing a bunch of the URLS I’ve found that have been helpful.

https://www.reddit.com/r/Govee/comments/e8ljbp/work_to_access_data_from_a_govee_h5075_indoor/
https://www.jaredwolff.com/get-started-with-bluetooth-low-energy/
https://github.com/neilsheps/GoveeTemperatureAndHumidity
https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=241686
https://www.cnet.com/how-to/how-to-setup-bluetooth-on-a-raspberry-pi-3/
https://www.real-world-systems.com/docs/hcitool.1.html

From the command line on my Pi4 I already had the tools installed to try several Bluetooth commands. I believe they were installed as part of the bluez package. The first two commands below get details on the Raspberry Pi Bluetooth hardware, then the hcitool lescan command produced a lot of devices, and I found the line referencing the GVH5075 so I could use the address in further commands.

pi@WimPi4:~ $ sudo hcitool dev
Devices:
        hci0    DC:A6:32:1C:B5:74

pi@WimPi4:~ $ sudo hciconfig -a
hci0:   Type: Primary  Bus: UART
        BD Address: DC:A6:32:1C:B5:74  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING 
        RX bytes:21284 acl:25 sco:0 events:791 errors:0
        TX bytes:4401 acl:26 sco:0 commands:172 errors:0
        Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
        Link policy: RSWITCH SNIFF 
        Link mode: SLAVE ACCEPT 
        Name: 'WimPi4'
        Class: 0x000000
        Service Classes: Unspecified
        Device Class: Miscellaneous, 
        HCI Version: 5.0 (0x9)  Revision: 0x13b
        LMP Version: 5.0 (0x9)  Subversion: 0x6119
        Manufacturer: Cypress Semiconductor Corporation (305)

pi@WimPi4:~ $ sudo hcitool lescan
LE Scan ...
7B:F9:68:96:C4:92 (unknown)
57:FA:0A:E7:61:A4 (unknown)
A4:C1:38:37:BC:AE GVH5075_BCAE
A4:C1:38:37:BC:AE (unknown)
15:FF:0C:3F:E7:35 (unknown)
57:FA:0A:E7:61:A4 (unknown)

pi@WimPi4:~ $ sudo hcitool leinfo A4:C1:38:37:BC:AE
Requesting information ...
        Handle: 64 (0x0040)
        LMP Version: 4.2 (0x8) LMP Subversion: 0x22bb
        Manufacturer: Telink Semiconductor Co. Ltd (529)
        Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

Another command that I attempted before I used the hcitool command was the bluetoothctl command. It scrolls a lot of data, but now that I have an idea what I’m looking at, I may be able to see announcement data from the thermometer periodically in the stream by filtering just to see the data coming from the MAC address.

pi@WimPi4:~ $ sudo bluetoothctl
Agent registered
[bluetooth]# scan on
Discovery started
[CHG] Controller DC:A6:32:1C:B5:74 Discovering: yes
[NEW] Device 57:75:EA:B6:EC:2B 57-75-EA-B6-EC-2B
[NEW] Device E7:E7:B4:AB:4A:1F 846B219FB80338A3E9
[NEW] Device 48:56:2E:FF:59:45 48-56-2E-FF-59-45
[NEW] Device 46:53:2F:D4:6F:A1 46-53-2F-D4-6F-A1
[NEW] Device 5C:C9:C5:C9:70:5F 5C-C9-C5-C9-70-5F
[NEW] Device 48:CF:F7:19:4A:3A 48-CF-F7-19-4A-3A
[NEW] Device 4E:30:D1:5D:0F:48 4E-30-D1-5D-0F-48
[NEW] Device 7D:4A:A3:81:32:22 7D-4A-A3-81-32-22
[NEW] Device 7E:0F:63:2B:DC:3E 7E-0F-63-2B-DC-3E
[NEW] Device 7F:5D:37:A2:4E:BA 7F-5D-37-A2-4E-BA
[NEW] Device 7F:6B:44:CD:3A:E5 7F-6B-44-CD-3A-E5
[NEW] Device 00:07:80:37:BD:35 00-07-80-37-BD-35
[NEW] Device 04:52:C7:BC:1C:E3 LE-Bose Revolve SoundLink
[NEW] Device 4F:84:D2:AC:59:FF 4F-84-D2-AC-59-FF
[NEW] Device 4E:F0:6A:DD:3D:7E 4E-F0-6A-DD-3D-7E
[NEW] Device 75:25:34:3F:B9:29 75-25-34-3F-B9-29
[NEW] Device 60:EC:A4:49:B6:67 60-EC-A4-49-B6-67
[NEW] Device 98:D6:BB:20:EB:3B 98-D6-BB-20-EB-3B
[NEW] Device 78:13:28:A8:0A:FF 78-13-28-A8-0A-FF
[NEW] Device 56:6F:B2:E0:40:E3 56-6F-B2-E0-40-E3
[NEW] Device 69:D9:38:44:5C:04 69-D9-38-44-5C-04
[NEW] Device 56:63:50:90:82:D6 56-63-50-90-82-D6
[CHG] Device A4:C1:38:37:BC:AE RSSI: -43
[CHG] Device A4:C1:38:37:BC:AE ManufacturerData Key: 0xec88
[CHG] Device A4:C1:38:37:BC:AE ManufacturerData Value:
00 03 32 62 64 00 ..2bd.
[CHG] Device A4:C1:38:37:BC:AE ManufacturerData Key: 0x004c
[CHG] Device A4:C1:38:37:BC:AE ManufacturerData Value:
02 15 49 4e 54 45 4c 4c 49 5f 52 4f 43 4b 53 5f ..INTELLI_ROCKS_
48 57 50 75 f2 ff c2 HWPu…
[CHG] Device 75:25:34:3F:B9:29 RSSI: -83
[NEW] Device 47:10:2F:15:99:2E 47-10-2F-15-99-2E
[NEW] Device B8:31:B5:8B:12:D2 ETOBAN386
[NEW] Device F0:6E:0B:D1:1B:BF ELRWLK345
[CHG] Device 75:25:34:3F:B9:29 RSSI: -72
[CHG] Device 7D:4A:A3:81:32:22 RSSI: -89
[CHG] Device 7D:4A:A3:81:32:22 RSSI: -81
[CHG] Device 98:D6:BB:20:EB:3B RSSI: -94
[NEW] Device A4:83:E7:20:06:5B A4-83-E7-20-06-5B
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Key: 0x05a7
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Value:
03 13 31 68 39 63 51 6f 4b 76 54 34 00 ..1h9cQoKvT4.
[NEW] Device 00:07:80:37:CA:7D 00-07-80-37-CA-7D
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Key: 0x05a7
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Value:
03 12 78 4d 32 49 31 6d 31 6a 6f 32 67 ..xM2I1m1jo2g
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Key: 0x05a7
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Value:
03 10 01 99 44 de ad be ef 00 0a 00 ca ….D……..
[CHG] Device 4E:30:D1:5D:0F:48 ManufacturerData Key: 0x004c
[CHG] Device 4E:30:D1:5D:0F:48 ManufacturerData Value:
10 06 10 1e b0 2a e1 be …..*..
[CHG] Device 98:D6:BB:20:EB:3B RSSI: -85
[NEW] Device 00:07:80:37:BE:C9 523
[CHG] Device 5C:C9:C5:C9:70:5F ManufacturerData Key: 0x004c
[CHG] Device 5C:C9:C5:C9:70:5F ManufacturerData Value:
10 06 5a 1e 56 a0 e1 eb ..Z.V…
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Key: 0x05a7
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Value:
03 13 31 68 39 63 51 6f 4b 76 54 34 00 ..1h9cQoKvT4.
[CHG] Device 75:25:34:3F:B9:29 RSSI: -81
[NEW] Device 6B:C2:D2:28:1E:A5 6B-C2-D2-28-1E-A5
[CHG] Device 5C:C9:C5:C9:70:5F ManufacturerData Key: 0x004c
[CHG] Device 5C:C9:C5:C9:70:5F ManufacturerData Value:
0c 0e 00 41 32 56 c8 79 5a 01 9d 63 d5 79 c7 80 …A2V.yZ..c.y..
10 06 56 1e 56 a0 e1 eb ..V.V…
[CHG] Device A4:C1:38:37:BC:AE RSSI: -35
[CHG] Device A4:C1:38:37:BC:AE ManufacturerData Key: 0xec88
[CHG] Device A4:C1:38:37:BC:AE ManufacturerData Value:
00 03 32 61 64 00 ..2ad.
[CHG] Device A4:C1:38:37:BC:AE ManufacturerData Key: 0x004c
[CHG] Device A4:C1:38:37:BC:AE ManufacturerData Value:
02 15 49 4e 54 45 4c 4c 49 5f 52 4f 43 4b 53 5f ..INTELLI_ROCKS_
48 57 50 75 f2 ff c2 HWPu…
[CHG] Device 48:CF:F7:19:4A:3A RSSI: -76
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Key: 0x05a7
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Value:
03 10 01 99 44 de ad be ef 00 0a 00 ca ….D……..
[NEW] Device 78:11:F9:E8:7A:DA 78-11-F9-E8-7A-DA
[CHG] Device 47:10:2F:15:99:2E RSSI: -84
[CHG] Device 69:D9:38:44:5C:04 RSSI: -83
[CHG] Device 47:10:2F:15:99:2E ManufacturerData Key: 0x004c
[CHG] Device 47:10:2F:15:99:2E ManufacturerData Value:
10 06 1c 1e 9a e0 28 9b ……(.
[CHG] Device 5C:C9:C5:C9:70:5F ManufacturerData Key: 0x004c
[CHG] Device 5C:C9:C5:C9:70:5F ManufacturerData Value:
0c 0e 00 42 32 7b fc b2 b6 a1 46 31 82 0f 67 02 …B2{….F1..g.
10 06 56 1e 56 a0 e1 eb ..V.V…
[CHG] Device 75:25:34:3F:B9:29 RSSI: -73
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Key: 0x05a7
[CHG] Device E7:E7:B4:AB:4A:1F ManufacturerData Value:
03 13 31 68 39 63 51 6f 4b 76 54 34 00 ..1h9cQoKvT4.
[CHG] Device 47:10:2F:15:99:2E ManufacturerData Key: 0x004c
[CHG] Device 47:10:2F:15:99:2E ManufacturerData Value:
10 06 14 1e 9a e0 28 9b ……(.
[NEW] Device 5C:53:86:8D:A4:61 5C-53-86-8D-A4-61
[NEW] Device 42:32:EC:5F:59:C5 42-32-EC-5F-59-C5
[bluetooth]# scan off
Discovery stopped
[CHG] Device E7:E7:B4:AB:4A:1F TxPower is nil
[CHG] Device E7:E7:B4:AB:4A:1F RSSI is nil
[DEL] Device E7:E7:B4:AB:4A:1F 846B219FB80338A3E9
[CHG] Controller DC:A6:32:1C:B5:74 Discovering: no
[CHG] Device 42:32:EC:5F:59:C5 TxPower is nil
[CHG] Device 42:32:EC:5F:59:C5 RSSI is nil
[CHG] Device 5C:53:86:8D:A4:61 RSSI is nil
[CHG] Device 78:11:F9:E8:7A:DA TxPower is nil
[CHG] Device 78:11:F9:E8:7A:DA RSSI is nil
[CHG] Device 6B:C2:D2:28:1E:A5 TxPower is nil
[CHG] Device 6B:C2:D2:28:1E:A5 RSSI is nil
[CHG] Device 00:07:80:37:BE:C9 RSSI is nil
[CHG] Device 00:07:80:37:CA:7D RSSI is nil
[CHG] Device A4:83:E7:20:06:5B RSSI is nil
[CHG] Device F0:6E:0B:D1:1B:BF TxPower is nil
[CHG] Device F0:6E:0B:D1:1B:BF RSSI is nil
[CHG] Device B8:31:B5:8B:12:D2 TxPower is nil
[CHG] Device B8:31:B5:8B:12:D2 RSSI is nil
[CHG] Device 47:10:2F:15:99:2E TxPower is nil
[CHG] Device 47:10:2F:15:99:2E RSSI is nil
[CHG] Device A4:C1:38:37:BC:AE RSSI is nil
[CHG] Device 56:63:50:90:82:D6 RSSI is nil
[CHG] Device 69:D9:38:44:5C:04 TxPower is nil
[CHG] Device 69:D9:38:44:5C:04 RSSI is nil
[CHG] Device 56:6F:B2:E0:40:E3 TxPower is nil
[CHG] Device 56:6F:B2:E0:40:E3 RSSI is nil
[CHG] Device 78:13:28:A8:0A:FF TxPower is nil
[CHG] Device 78:13:28:A8:0A:FF RSSI is nil
[CHG] Device 98:D6:BB:20:EB:3B RSSI is nil
[CHG] Device 60:EC:A4:49:B6:67 TxPower is nil
[CHG] Device 60:EC:A4:49:B6:67 RSSI is nil
[CHG] Device 75:25:34:3F:B9:29 TxPower is nil
[CHG] Device 75:25:34:3F:B9:29 RSSI is nil
[CHG] Device 4E:F0:6A:DD:3D:7E TxPower is nil
[CHG] Device 4E:F0:6A:DD:3D:7E RSSI is nil
[CHG] Device 4F:84:D2:AC:59:FF TxPower is nil
[CHG] Device 4F:84:D2:AC:59:FF RSSI is nil
[CHG] Device 04:52:C7:BC:1C:E3 TxPower is nil
[CHG] Device 04:52:C7:BC:1C:E3 RSSI is nil
[CHG] Device 00:07:80:37:BD:35 RSSI is nil
[CHG] Device 7F:6B:44:CD:3A:E5 TxPower is nil
[CHG] Device 7F:6B:44:CD:3A:E5 RSSI is nil
[CHG] Device 7F:5D:37:A2:4E:BA TxPower is nil
[CHG] Device 7F:5D:37:A2:4E:BA RSSI is nil
[CHG] Device 7E:0F:63:2B:DC:3E TxPower is nil
[CHG] Device 7E:0F:63:2B:DC:3E RSSI is nil
[CHG] Device 7D:4A:A3:81:32:22 TxPower is nil
[CHG] Device 7D:4A:A3:81:32:22 RSSI is nil
[CHG] Device 4E:30:D1:5D:0F:48 TxPower is nil
[CHG] Device 4E:30:D1:5D:0F:48 RSSI is nil
[CHG] Device 48:CF:F7:19:4A:3A TxPower is nil
[CHG] Device 48:CF:F7:19:4A:3A RSSI is nil
[CHG] Device 5C:C9:C5:C9:70:5F TxPower is nil
[CHG] Device 5C:C9:C5:C9:70:5F RSSI is nil
[CHG] Device 46:53:2F:D4:6F:A1 TxPower is nil
[CHG] Device 46:53:2F:D4:6F:A1 RSSI is nil
[CHG] Device 48:56:2E:FF:59:45 TxPower is nil
[CHG] Device 48:56:2E:FF:59:45 RSSI is nil
[CHG] Device 57:75:EA:B6:EC:2B TxPower is nil
[CHG] Device 57:75:EA:B6:EC:2B RSSI is nil
[DEL] Device 57:75:EA:B6:EC:2B 57-75-EA-B6-EC-2B
[DEL] Device 48:56:2E:FF:59:45 48-56-2E-FF-59-45
[DEL] Device 46:53:2F:D4:6F:A1 46-53-2F-D4-6F-A1
[DEL] Device 5C:C9:C5:C9:70:5F 5C-C9-C5-C9-70-5F
[DEL] Device 48:CF:F7:19:4A:3A 48-CF-F7-19-4A-3A
[DEL] Device 4E:30:D1:5D:0F:48 4E-30-D1-5D-0F-48
[DEL] Device 7D:4A:A3:81:32:22 7D-4A-A3-81-32-22
[DEL] Device 7E:0F:63:2B:DC:3E 7E-0F-63-2B-DC-3E
[DEL] Device 7F:5D:37:A2:4E:BA 7F-5D-37-A2-4E-BA
[DEL] Device 7F:6B:44:CD:3A:E5 7F-6B-44-CD-3A-E5
[DEL] Device 00:07:80:37:BD:35 00-07-80-37-BD-35
[DEL] Device 04:52:C7:BC:1C:E3 LE-Bose Revolve SoundLink
[DEL] Device 4F:84:D2:AC:59:FF 4F-84-D2-AC-59-FF
[DEL] Device 4E:F0:6A:DD:3D:7E 4E-F0-6A-DD-3D-7E
[DEL] Device 75:25:34:3F:B9:29 75-25-34-3F-B9-29
[DEL] Device 60:EC:A4:49:B6:67 60-EC-A4-49-B6-67
[DEL] Device 98:D6:BB:20:EB:3B 98-D6-BB-20-EB-3B
[DEL] Device 78:13:28:A8:0A:FF 78-13-28-A8-0A-FF
[DEL] Device 56:6F:B2:E0:40:E3 56-6F-B2-E0-40-E3
[DEL] Device 69:D9:38:44:5C:04 69-D9-38-44-5C-04
[DEL] Device 56:63:50:90:82:D6 56-63-50-90-82-D6
[DEL] Device 47:10:2F:15:99:2E 47-10-2F-15-99-2E
[DEL] Device B8:31:B5:8B:12:D2 ETOBAN386
[DEL] Device F0:6E:0B:D1:1B:BF ELRWLK345
[DEL] Device A4:83:E7:20:06:5B A4-83-E7-20-06-5B
[DEL] Device 00:07:80:37:CA:7D 00-07-80-37-CA-7D
[DEL] Device 00:07:80:37:BE:C9 523
[DEL] Device 6B:C2:D2:28:1E:A5 6B-C2-D2-28-1E-A5
[DEL] Device 78:11:F9:E8:7A:DA 78-11-F9-E8-7A-DA
[DEL] Device 5C:53:86:8D:A4:61 5C-53-86-8D-A4-61
[DEL] Device 42:32:EC:5F:59:C5 42-32-EC-5F-59-C5
[bluetooth]# exit

I’m posting all of this here and hopefully will be able to make progress on retrieving the data in the next few days.

Using FFMPEG to Concatenate and Embed Subtitles

I recently upgraded my drone to a DJI Mavic Air 2. Among other things, it can create h.265 videos directly. It still uses the MP4 container format and the separate SRT format for storing video subtitles, the flight data. Following most camera standards, it creates video files that are individually smaller than 4 GB, which works out to be about five minutes in 4k video.

If I want to upload a longer raw video to social media, the video files need to be concatenated before uploading.

Concatenating the video with FFMPEG has been something I’ve known how to do for a long time using either of two methods. Today I learned how to properly embed the subtitles in either the MKV or MP4 container format.

The MP4 format is more widely supported than the MKV format, but is less flexible as to what it can contain.  The MKV (Matroska Multimedia Container) container format can hold almost any type of media, and so I’m able to copy the SRT format directly. The MP4 (MPEG-4 Part 14) container format only supports a limited selection of subtitle formats, so I’m required to have FFMPEG convert the SRT stream to a MP4 compatible stream.  If you are interested in video container formats, these tables are very helpful.

I’ll give several examples using the two video files and their associated subtitle files created by the drone named DJI00001.MP4, DJI00002.MP4, DJI00001.SRT, and DJI00002.SRT. The method I’m using should work for any number of files, up to the largest filesize you can store on your filesystem.

To simply concatenate the video files, create a text input file (I’m using mp4files.txt) with the contents as follows

file DJI00001.MP4
file DJI00001.MP4

then use the ffmpeg command to create a new concatenated file.

ffmpeg -f concat -safe 0 -i mp4files.txt -c copy ConcatenatedVideo.MP4

If you want to embed the subtitles, you need to create a second text file, do some stream mapping, and specify what format the subtitles should be. In this case I’m using srtfiles.txt

file DJI00001.SRT
file DJI00002.SRT

My FFMPEG command to create an MP4 file gets a lot more involved because now I’m specifying multiple inputs and have to specify the subtitle format.

ffmpeg -f concat -safe 0 -i mp4files.txt -f concat -safe 0 -i srtfiles.txt -map 0:v -map 1 -c:v copy -c:s mov_text ConcatenatedVideo.MP4

The FFMPEG command to create an MKV command is only a tiny bit different, and the resulting file is only a tiny bit smaller.

ffmpeg -f concat -safe 0 -i mp4files.txt -f concat -safe 0 -i srtfiles.txt -map 0:v -map 1 -c:v copy -c:s copy ConcatenatedVideo.MKV

When playing the ConcatenatedVideo files on my local machine, I can now enable or disable the closed caption track properly in the player for either format. Unfortunately in my initial testing with YouTube, neither format maintains the second stream of subtitles.

This is not all a waste of time and effort, because an advantage of embedding the subtitles into the container format is that the timing has been matched to the video, and can now be extracted in a concatenated form for use with YouTube.

ffmpeg -i ConcatenatedVideo.MKV -c copy ConcatenatedVideo.SRT

You can exclude the “-c copy” when extracting the subtitles and FFMPEG fill run it through its subrip codec and produce nearly identical results. It will only work with the MKV file because the subtitle format stored in the MP4 file is not easily converted to a SRT file.

Using the -f concat option invokes the concat demuxer in FFMPEG, which has the limitation that the format needs to be exactly the same for each file. If there are any changes between files you want to concatenate, you must use a more involved command invoking the concat filter. In a different project I ran into a command issue with the concat filter command when the command got to be much over 900 characters long.

 

iTunes, Microsoft Store, COM Interface Type Library

Several years ago I’d written a program to manipulate data in the iTunes library using the approved Apple COM API. Part of the way this works in a C program is to include a type library in the headers defining all of the function calls. When iTunes is installed in the traditional way, Apple embedded the type library in the executable, and the executable was installed in a traditional location.

#import "C:/Program Files (x86)/iTunes/iTunes.exe"
using namespace iTunesLib;

With the installation of iTunes from the Microsoft store, the iTunes executable no longer lives in that location. Today my application builds properly with the following import command, but it may change mysteriously with version changes and automatic updates via the store.

#import "C:/Program Files/WindowsApps/AppleInc.iTunes_12093.3.37141.0_x64__nzyj5cx40ttqa/iTunes.exe"
using namespace iTunesLib;

My program builds and runs more reliably than it used to, which I’m assuming is in part due to the fact that I appear to now be using a 64 bit version of iTunes, and all the extra work Apple put in to make iTunes more reliable on windows in general.

Finding the iTunes application itself was the hardest part of the transition. I’m happy the API still exists because Apple no longer hosts easy access to the documentation for the API, and http://www.joshkunz.com/iTunesControl/ seems to be the most complete and searchable information.

vcpkg, OpenCV, and Visual Studio

Several years ago I was playing around with a Logitech C920 webcam using OpenCV on Linux.

Recently I decided I wanted to get the same basic functionality under windows with minimal effort, so looked into what it would take to get OpenCV running on windows. I was amazed to come across a YouTube video showing the use of vcpkg as a library package manager under windows that allowed downloading, building, and installing many common libraries quite easily.

I was nicely amazed at how it worked..  Issuing just a few commands in powershell I was able to quickly download and build both vcpkg and OpenCV.

cd .\Source\Repos\
git clone https://github.com/Microsoft/vcpkg.git
cd .\vcpkg\
.\bootstrap-vcpkg.bat
.\vcpkg.exe integrate install
.\vcpkg.exe install opencv
.\vcpkg.exe install opencv:x64-windows

The one thing that bothers me the most is that I now have used over 7GB of space on my local drive on my 256GB SSD. That estimate is according to a quick change directory into the vcpkg directory and running the command dir /s /w it returned:

     Total Files Listed:
36549 File(s)  7,296,147,088 bytes
21911 Dir(s)  79,514,853,376 bytes free

My old program from Linux was able to run in my current Windows 10 environment with the only code change required being replacing the unix sleep() command with an appropriate windows command.

Here’s what the entire install process looked like in the shell:

vcpkg-1vcpkg-2vcpkg-3vcpkg-4vcpkg-5vcpkg-6

Part 3 of ROAV Dash Cam C1 Pro

After getting the video files from my dashcam strung together at high speed I realized I was just as interested in the GPS data that was stored in .info files alongside each .mp4 file.

Some digging around in forums led me to believe that the files were fairly simple comma separated files with the headers working out to be Datetime, Latitude, Longitude, FixType, SatCount, Altitude, SpeedKph, Heading, AccelerometerX, AccelerometerY, AccelerometerZ. The Datetime field is it’s own special format, but easy enough to interpret.

Because I’ve written a GPS data app in the past, I’d learned how to write Keyhole Markup Language (KML) files, as well as learning to use ZIP routines to package them into KMZ files. My original code had hard coded the KML tags because I didn’t want to rely on an external library requirement on a limited platform. In re-using the code I updated to use the XMLLite API. Microsoft may be discontinuing support for this API as well, but at least now it’s still included with current operating systems. The advantage of using the XML API to create the XML is knowing that all of the tags are properly and consistently formed and closed. A secondary feature was that it made it much simpler to explore different data formatting options for the folders in the KML structure.

ROAV-ConCatStructureI worked on the basic idea that the most interesting data from the source files was based on speed and altitude. Then I broke the data into segments by the day, so if I store multiple days worth of files the kml will automatically have reasonable breaks in it. I create a Placemark that includes a LineString with all the GPS coordinates for the day. I calculate the distance by multiplying the reported speed by the time between points.

The calculated distance isn’t as accurate as I’d like, but the code I had from years ago didn’t seem to get more accurate distances. My web references from years ago no longer work, which is the frustrating thing about pointing to documentation on the web. The code I’d used years before was used in a bicycle gps program, which meant that the speeds were slower and the distance traveled between points may have been smaller. The data the ROAV is writing to the log file may not have as many significant digits as the raw data available from the the GPS chip itself.

I create three more Placemarks for each day, each with a simple Point defined. Max Speed, Max Altitude, and Min Altitude. Each of those data points is selected from a simple scan of the input data.

ROAV-ConCatVideo

By creating a large KML file and then converting it to a KMZ, it becomes a manageable size. KMZ files load into google earth significantly faster then KML files. One of the interesting things that you can do in Google Earth is display the elevation profile of a path.

ROAV-ConCatVideoElevation

On this day you can see that I started at just under 4500 feet, drove over 6000 feet, then down to 1733 feet before ending the day near 2500 feet. When playing with the desktop app, you can drag a marker along the path and it will coordinate a marker along the elevation profile.

I’ve added this code to my ROAV-Concat program, as well as parameters that can tell the program to not output KML or MP4. this allows me to run the program and just generate the KMZ or MP4 file, though beyond during debugging I can’t think of a reason I’d not want both files generated.

I’m hoping that understanding all of this data will allow me to generate text to overlay the video with GPS data beyond what was embedded by the original dashcam.

Part 2 of FFMPEG and ROAV Dash Cam C1 Pro

While writing my software to concatenate and speed up the video files from my ROAV Dashcam I ran into an interesting issue with FFMPEG.

The -filter_complex option seems to stop parsing it’s parameters somewhere above 960 characters on the command line. I didn’t narrow down the exact point, or go digging in the FFMPEG source code to find the size. I expect this is an arbitrary buffer size in FFMPEG. I may contribute to the source code since it fails with no explanation, even when generating a report file. Learning the FFMPEG source structure in itself is a large task, meaning that I’ve not found time to do anything beyond find a workaround.

My workaround was to recognize when the command size will get long and fall back to using the -f concat option with a temporary file listing the input files instead of using the complex filtergraph.

The advantage of the complex filtergraph is twofold. It does not require a secondary input file or any cleanup. It can deal with input files that change resolution if necessary.

Here’s an example of the complex filtergraph:

ffmpeg.exe -report -i 2018_0705_101335_006.MP4 -i 2018_0705_101635_007.MP4 -i 2018_0705_101935_008.MP4 -i 2018_0705_102235_009.MP4 -i 2018_0705_102535_010.MP4 -i 2018_0705_102835_011.MP4 -i 2018_0705_103135_012.MP4 -i 2018_0705_103435_013.MP4 -i 2018_0705_103613_014A.MP4 -i 2018_0705_103615_015A.MP4 -i 2018_0705_104449_016A.MP4 -i 2018_0705_104750_017A.MP4 -i 2018_0705_105050_018A.MP4 -i 2018_0705_105350_019A.MP4 -i 2018_0705_105650_020A.MP4 -i 2018_0705_105950_021A.MP4 -i 2018_0705_110250_022A.MP4 -i 2018_0705_110550_023A.MP4 -i 2018_0705_110850_024A.MP4 -i 2018_0705_143415_025.MP4 -i 2018_0705_143716_026.MP4 -i 2018_0705_144016_027.MP4 -i 2018_0705_144316_028.MP4 -i 2018_0705_144616_029.MP4 -i 2018_0705_144916_030.MP4 -i 2018_0705_145216_031.MP4 -i 2018_0705_145516_032.MP4 -i 2018_0705_145816_033.MP4 -i 2018_0705_150116_034.MP4 -i 2018_0705_150416_035.MP4 -i 2018_0705_150716_036.MP4 -i 2018_0705_151016_037.MP4 -i 2018_0705_151316_038.MP4 -i 2018_0705_151616_039.MP4 -i 2018_0705_151916_040.MP4 -i 2018_0705_152216_041.MP4 -i 2018_0705_152516_042.MP4 -i 2018_0705_152816_043.MP4 -i 2018_0705_153116_044.MP4 -i 2018_0705_153416_045.MP4 -i 2018_0705_153716_046.MP4 -i 2018_0705_154016_047.MP4 -i 2018_0705_154316_048.MP4 -i 2018_0705_154616_049.MP4 -i 2018_0705_154916_050.MP4 -i 2018_0705_155216_051.MP4 -i 2018_0705_155516_052.MP4 -i 2018_0705_155816_053.MP4 -i 2018_0705_160116_054.MP4 -i 2018_0705_160416_055.MP4 -i 2018_0705_160716_056.MP4 -i 2018_0705_161016_057.MP4 -i 2018_0705_161316_058.MP4 -i 2018_0705_161616_059.MP4 -i 2018_0705_161916_060.MP4 -i 2018_0705_162216_061.MP4 -i 2018_0705_162516_062.MP4 -i 2018_0705_162816_063.MP4 -i 2018_0705_163116_064.MP4 -i 2018_0705_163416_065.MP4 -i 2018_0705_163716_066.MP4 -i 2018_0705_164016_067.MP4 -i 2018_0705_164316_068.MP4 -i 2018_0705_164616_069.MP4 -i 2018_0705_164916_070.MP4 -i 2018_0705_165215_071.MP4 -i 2018_0705_165516_072.MP4 -i 2018_0705_165815_073.MP4 -i 2018_0705_170115_074.MP4 -i 2018_0705_170415_075.MP4 -i 2018_0705_170715_076.MP4 -i 2018_0705_171015_077.MP4 -i 2018_0705_171315_078.MP4 -i 2018_0705_171615_079.MP4 -i 2018_0705_171915_080.MP4 -i 2018_0705_172216_081.MP4 -i 2018_0705_172515_082.MP4 -i 2018_0705_172815_083.MP4 -i 2018_0705_173115_084.MP4 -i 2018_0705_173415_085.MP4 -i 2018_0705_173715_086.MP4 -i 2018_0705_174015_087.MP4 -i 2018_0705_174315_088.MP4 -i 2018_0705_174615_089.MP4 -i 2018_0705_174915_090.MP4 -i 2018_0705_175215_091.MP4 -i 2018_0705_175515_092.MP4 -i 2018_0705_175815_093.MP4 -i 2018_0705_180115_094.MP4 -i 2018_0705_180415_095.MP4 -i 2018_0705_180715_096.MP4 -i 2018_0705_181015_097.MP4 -i 2018_0705_181315_098.MP4 -i 2018_0705_181615_099.MP4 -i 2018_0705_181915_100.MP4 -i 2018_0705_182215_101.MP4 -i 2018_0705_182515_102.MP4 -i 2018_0705_182815_103.MP4 -i 2018_0705_183115_104.MP4 -i 2018_0705_183415_105.MP4 -i 2018_0705_183715_106.MP4 -i 2018_0705_184015_107.MP4 -i 2018_0705_184315_108.MP4 -i 2018_0705_184615_109.MP4 -i 2018_0705_184915_110.MP4 -i 2018_0705_185215_111.MP4 -i 2018_0705_185515_112.MP4 -i 2018_0705_185815_113.MP4 -i 2018_0705_190115_114.MP4 -i 2018_0705_190415_115.MP4 -filter_complex [0:v][1:v][2:v][3:v][4:v][5:v][6:v][7:v][8:v][9:v][10:v][11:v][12:v][13:v][14:v][15:v][16:v][17:v][18:v][19:v][20:v][21:v][22:v][23:v][24:v][25:v][26:v][27:v][28:v][29:v][30:v][31:v][32:v][33:v][34:v][35:v][36:v][37:v][38:v][39:v][40:v][41:v][42:v][43:v][44:v][45:v][46:v][47:v][48:v][49:v][50:v][51:v][52:v][53:v][54:v][55:v][56:v][57:v][58:v][59:v][60:v][61:v][62:v][63:v][64:v][65:v][66:v][67:v][68:v][69:v][70:v][71:v][72:v][73:v][74:v][75:v][76:v][77:v][78:v][79:v][80:v][81:v][82:v][83:v][84:v][85:v][86:v][87:v][88:v][89:v][90:v][91:v][92:v][93:v][94:v][95:v][96:v][97:v][98:v][99:v][100:v][101:v][102:v][103:v][104:v][105:v][106:v][107:v][108:v][109:v]concat=n=110:v=1[v];[v]setpts=(1/60)*PTS,drawtext=fontfile=C\\:/WINDOWS/Fonts/consola.ttf:fontcolor=white:fontsize=80:y=main_h-text_h-50:x=50:text=WimsWorld[o] -map [o] -c:v libx265 -crf 23 -preset veryfast -movflags +faststart -bf 2 -g 15 -pix_fmt yuv420p -y “Output.mp4”

Here’s an example of the command where all the input files are defined in the temporary file:

ffmpeg.exe -report -f concat -safe 0 -i C:\Users\Wim\AppData\Local\Temp\Wim4BD3.tmp -vf setpts=(1/60)*PTS,drawtext=fontfile=C\\:/WINDOWS/Fonts/consola.ttf:fontcolor=white:fontsize=80:y=main_h-text_h-50:x=50:text=WimsWorld -an -c:v libx265 -crf 23 -preset veryfast -movflags +faststart -bf 2 -g 15 -pix_fmt yuv420p -y “Output.mp4”