Skip to content

Commit

Permalink
Initial release with persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
pbatard committed Jan 2, 2023
1 parent b9b5414 commit 2d94015
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 2 deletions.
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

82 changes: 82 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
This archive contains libraries and scripts needed to restore DTS playback
on LG Smart TVs, such as OLED CX models.

See https://github.com/RootMyTV/RootMyTV.github.io/issues/72 for details.


License and disclaimers:
------------------------

GNU LGPL v2.1 or later (same as the GStreamer project and its plugins)

THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE
SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

THIS SOFTWARE IS *NOT* ENDORSED BY LG OR ANY OF ITS SUBSIDIARIES.


Limitations:
------------

- Root required (https://github.com/RootMyTV/RootMyTV.github.io/issues/85)
- Only mkv playback supported (no .mp4, no .dts).
- Only PCM stereo downmix supported (no multichannel, no passthrough).
- The libraries and scripts have been designed for LG OLED CX models.
While there is a good chance that, if your TV is not too dissimilar to
OLED CXs, you might also be able to restore DTS support there, any issue
that arises from not running this software on an OLED CX is entirely
yours to troubleshoot and support.


Installation:
-------------

- Open a root shell to your TV (e.g. using ssh)
- Download, extract and run the installer by issuing:
cd /home/root
wget https://github.com/lgstreamer/dts_restore/releases/download/1.0/dts_restore_1.0.tgz
tar -xzvf dts_restore_1.0.tgz
./dts_install.sh


Uninstallation:
---------------

- Open a root shell to your TV (e.g. using ssh)
- Run the command: ./home/root/dts_uninstall.sh
- Fully power off or reboot your TV.


Additional notes:
-----------------

- The DTS restoration process does not alter the original LG firmware
content. All changes are applied in a temporary manner which means that,
should you want reset media playback to its original behaviour, you can
just remove the /var/lib/webosbrew/init.d/restore_dts init script or run
dst_uninstall.sh.
- If you still see the "This video does not support audio" message on first
attempt, just close the video file and try again.
- If you want to adjust the stereo downmix settings, you can edit the
[downmix] section from /var/lib/webosbrew/init.d/restore_dts (permanent)
of /etc/gst/gstcool.conf (temporary).


Source code:
------------

- libgstmatroska.so was compiled from the 1.14.4 LG 'gst-plugins-good'
source for OLED CX models, with matroska audio DTS demuxing re-enabled.
The complete source for it, along with compilation instructions, can be
found at: https://github.com/lgstreamer/gst-plugins-good
- libgstlibav.so was compiled from the 1.14.4 LG 'gst-libav' source for
OLED CX models with the following changes applied for DTS (dca) decoding:
* Force stereo downmix always.
* Force integer output always.
* Allow the reading of downmix coefficient from gstcool.conf.
The complete source for it, along with compilation instructions, can be
found at: https://github.com/lgstreamer/gst-libav
114 changes: 114 additions & 0 deletions dts_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/bash

# DTS playback restoration script for LG OLED CX
# Copyright (c) 2022-2023 Pete Batard <[email protected]>
# See https://github.com/RootMyTV/RootMyTV.github.io/issues/72#issuecomment-1343204028

# Set the following to the directory where you have the GST plugins
GST_SRC=/home/root/gst

# Validate that we have the relevant init.d directory
INIT_DIR=/var/lib/webosbrew/init.d
if [[ ! -d $INIT_DIR ]]; then
echo "$INIT_DIR/ is missing - Aborting"
exit 1
fi

# Validate that there is a GStreamer registry to override
if [[ ! -f $GST_REGISTRY_1_0 ]]; then
echo "$GST_REGISTRY_1_0 is missing - Aborting"
exit 1
fi

# Validate that the media player isn't running
MEDIA_PLAYER_INSTANCES=`ps -ef | grep [s]tarfish-media | wc -l`
if [[ $MEDIA_PLAYER_INSTANCES -gt 1 ]]; then
echo "Cannot install while media player is running - Aborting"
exit 1
fi

# Validate that the libraries we need are there
for lib in libgstmatroska.so libgstlibav.so; do
if [[ ! -f "$GST_SRC/$lib" ]]; then
echo "$GST_SRC/$lib is missing - Aborting"
exit 1
fi
done

# Display a notice if not installing on the expected platform
GST_VERSION=`gst-inspect-1.0 --version | grep GStreamer | cut -d " " -f 2`
WEBOS_VERSION=`nyx-cmd OSInfo query webos_release`
MODEL_NAME=`nyx-cmd DeviceInfo query product_id`
if [[ "$GST_VERSION" != "1.14.4" || "${WEBOS_VERSION::1}" != "5" || "${MODEL_NAME::4}" != "OLED" || "${MODEL_NAME:6:2}" != "CX" ]]; then
echo
echo "This installer was designed specifically for LG OLED CX TVs running"
echo "webOS 5.x with Gstreamer 1.14.4. However, you are trying run it on a(n)"
echo "$MODEL_NAME TV with webOS $WEBOS_VERSION and GStreamer $GST_VERSION."
echo
echo "While installing this software on an incompatible platform should not"
echo "cause irreversible damage, if you choose to proceed, you do acknowlegde"
echo "that, because you are not using the relevant target system:"
echo "1. The software may not work as expected, it at all."
echo "2. You may lose existing features and/or functionality."
echo "3. The entire responsibility for trying this software on an unsupported"
echo " platform lies entirely with you."
echo
read -r -p "Do you wish to proceed? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
;;
*)
exit 1
;;
esac
fi

echo "Installing $INIT_DIR/restore_dts"

# The script must *NOT* have a .sh extension
cat <<EOS > $INIT_DIR/restore_dts
#!/bin/bash
# Override the GST plugins that were nerfed by LG
for lib in libgstmatroska.so libgstlibav.so; do
if [[ -f $GST_SRC/\$lib ]]; then
echo "Installing /usr/lib/gstreamer-1.0/\$lib override"
mount -n --bind -o ro $GST_SRC/\$lib /usr/lib/gstreamer-1.0/\$lib
fi
done
# Override the GST registry
if [[ -f $GST_REGISTRY_1_0 ]]; then
echo "Installing $GST_REGISTRY_1_0 override"
export GST_REGISTRY_1_0=/tmp/gst_1_0_registry.arm.bin
/usr/bin/gst-inspect-1.0 > /var/tmp/gst-inspect.log
chmod 666 \$GST_REGISTRY_1_0
chown :compositor \$GST_REGISTRY_1_0
mount -n --bind \$GST_REGISTRY_1_0 $GST_REGISTRY_1_0
fi
# Override /etc/gst/gstcool.conf
if [[ ! -f /tmp/gstcool.conf ]]; then
echo "Installing /etc/gst/gstcool.conf override"
if [[ -f /etc/gst/gstcool.conf ]]; then
sed "s/avdec_dca=0/avdec_dca=290/" /etc/gst/gstcool.conf > /tmp/gstcool.conf
cat <<EOT >> /tmp/gstcool.conf
[downmix]
front=1.25
center=0.75
lfe=0.75
rear=0.75
rear2=0.70
EOT
mount -n --bind /tmp/gstcool.conf /etc/gst/gstcool.conf
fi
fi
EOS

chmod 755 $INIT_DIR/restore_dts
if [[ ! -f /tmp/gstcool.conf ]]; then
echo "Running $INIT_DIR/restore_dts"
source $INIT_DIR/restore_dts
echo "DTS playback has been permanently re-enabled - Enjoy!"
fi
20 changes: 20 additions & 0 deletions dts_uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# DTS playback restoration script for LG OLED CX
# Copyright (c) 2022-2023 Pete Batard <[email protected]>
# See https://github.com/RootMyTV/RootMyTV.github.io/issues/72#issuecomment-1343204028

# Validate that we have the relevant init.d directory
INIT_DIR=/var/lib/webosbrew/init.d
if [[ ! -d $INIT_DIR ]]; then
echo "$INIT_DIR/ is missing - Aborting"
exit 1
fi

if [[ ! -f $INIT_DIR/restore_dts ]]; then
echo "$INIT_DIR/restore_dts is missing - Nothing to uninstall!"
exit 1
fi

rm $INIT_DIR/restore_dts
echo "DTS playback has been uninstalled - Please reboot your TV"
Binary file added gst/libgstlibav.so
Binary file not shown.
Binary file added gst/libgstmatroska.so
Binary file not shown.

0 comments on commit 2d94015

Please sign in to comment.