Workaround for MKV/AC3-DTS transcoding

Please post your questions about using the web-based Photo, Music, Video Stations here.
Post Reply
Starting out
Posts: 14
Joined: Tue Jun 12, 2018 4:52 am

Workaround for MKV/AC3-DTS transcoding

Post by Theliel » Fri Jul 12, 2019 1:54 am


The story is well known, but for those who are not aware, we summarize it.

The problem:
-When we play content through the Web interface, we depend on the browser's codec. Given that there is a multitude of codecs and containers, we opt for real-time transcoding of the content, to a format and codec that most browsers accept
-Due to licensing problems with AC3 / DTS, QNAP eliminated the support for these codecs a few years ago, and so lost the ability to transcode content with these codecs. MKV is not the problem, it is just a container, the problem is the codecs used in the audio part of the container, the same happens with MP4

Code: Select all

[/share/CACHEDEV1_DATA] # ffmpeg
ffmpeg version 3.3.6 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --enable-cross-compile --arch=i686 --target-os=linux --disable-yasm --disable-static --enable-shared --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libsoxr --enable-version3 --enable-nonfree --enable-openssl -[b][color=#FF0000]-disable-decoder=ac3 --disable-decoder=ac3_fixed --disable-decoder=eac3 --disable-decoder=dca --disable-decoder=truehd --disable-encoder=ac3 --disable-encoder=ac3_fixed --disable-encoder=eac3 --disable-encoder=dca --disable-decoder=hevc --disable-decoder=hevc_cuvid --disable-encoder=hevc_nvenc --disable-encoder=nvenc_hevc[/color][/b] --extra-ldflags='-L/root/daily_build/64_14/4.4.x/LinkFS/usr/lib -L/root/daily_build/64_14/4.4.x/Model/TS-X72/build/RootFS/usr/local/medialibrary/lib -Wl,--rpath -Wl,/usr/local/medialibrary/lib' --extra-cflags='-I/root/daily_build/64_14/4.4.x/LinkFS/usr/include -I/root/daily_build/64_14/4.4.x/Model/TS-X72/build/RootFS/usr/local/medialibrary/include -D_GNU_SOURCE -DQNAP' --prefix=/root/daily_build/64_14/4.4.x/Model/TS-X72/build/RootFS/usr/local/medialibrary
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
-QNAP solved the problem with the QVHelper utility, which allowed us to use the local player (usually VLC) to be able to reproduce that content directly, not to play it in the browser, which does not require transcoding
-QNAP eliminated QVHelper a few months ago, so that until they re-implement the relevant codec, we can not visualize this content as well as

The Workaround:
QNAP uses an old name, ffmpeg, for transcoding. The current version using QNAP from ffmpeg is compiled effectively without support for some codecs. However, it would be (and is) possible to use another compilation of ffmpeg with much more extended support, and replace it with QNAP.

The most "simple" way is to install ffmpeg from a third-party repository, and make the change by accessing SSH. Of course you can use your own compilation, but you have to keep in mind that we have different architectures, and different hardware features. You could create an automatic script that did everything, but I'll leave it for someone else who wants to do it, since depending on the NAS, Disks installed and another stuff, the path/files to be modified will be different.

In my case, using a TS-253Be:

1º. Install ffmpeg statically compiled for your architecture (Maybe you can use ffmpeg from qnap club repository)

2º. Make a backup of old ffmpeg

Code: Select all

mv /usr/bin/ffmpeg /usr/bin/ffmpeg.bak
mv /share/CACHEDEV1_DATA/.qpkg/CodexPack/opt/cdx/bin/ffmpeg /share/CACHEDEV1_DATA/.qpkg/CodexPack/opt/cdx/bin/ffmpeg.bak
3º. Create a Symlink to the new ffmpeg

Code: Select all

ln -s /share/CACHEDEV1_DATA/.qpkg/ffmpeg/ffmpeg /usr/bin/ffmpeg
ln -s /share/CACHEDEV1_DATA/.qpkg/ffmpeg/ffmpeg /share/CACHEDEV1_DATA/.qpkg/CodexPack/opt/cdx/bin/ffmpeg

After a CodePack or system update, probably we have to make the change again.

To revert back, you only need to move again the original files:

Code: Select all

mv /usr/bin/ffmpeg.bak /usr/bin/ffmpeg
mv /share/CACHEDEV1_DATA/.qpkg/CodexPack/opt/cdx/bin/ffmpeg.bak /share/CACHEDEV1_DATA/.qpkg/CodexPack/opt/cdx/bin/ffmpeg
Is working now, but with some issues:

1º. qnap will continue to detect the video as not supported, but we can reproduce it anyway.
2º. by default, ffmpeg maybe dont use GPU to assist transcoding, so you will need a powerfull CPU, another ffmpeg, some tweaks or another ffmpeg after all
3º. I dont know why, but dont work for all videos (same codecs, same resolution...), maybe CPU transcoding limitation
4º. And in any case, transcoding will not be possible on high bitrate, at least in my hardware

Not all ffmpeg copies should be replaced, ffmpeg in /usr/local/medialibrary/bin/ffmpeg need to be the original one, only replace the two above
Last edited by Theliel on Fri Jul 12, 2019 2:00 am, edited 1 time in total.

Posts: 18982
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Workaround for MKV/AC3-DTS transcoding

Post by dolbyman » Fri Jul 12, 2019 1:59 am

or use plex it provides a web browser front-end too (even the non plexpass free variant)

Post Reply

Return to “Photo Station, Music Station, Video Station”