EAC3 decoder not working

Hello everybody

I have problem with playing some files on some (most) devices. Unfortunately, I haven’t been able to get to narrow it down enough to pinpoint the source of the problem. But step by step:

Setup and versions:

I have PMS running in docker with 1.24.5.5173

Plex Web is version 4.63.0

OS: Ubuntu Server 20.04 LTS

The whole system runs on a core i5 with 32 GB of RAM

Symptoms:

  • On October 23rd. A friend of mine (I share my library) reported, that he cannot watch certain movies with his TV-app (until then there was never a problem). He confirmed that the same movies work on his phone-app.

  • Since then I gradually started noticing, that certain TV show episode are not played on certain devices. It got so bad, that by now, said episodes can only be watched on my 2015 TV plex app (last update 2018) and on plex client apps on windows (Media Server Downloads | Plex Media Server for Windows, Mac, Linux, FreeBSD and More) and linux (Plex Media Player for Linux | knapsu.eu) and on the later two only if I use direct play. AFAIK the TV Plex app is always using direct play. → Unforunately, the files affected are the more recent ones.

  • With the afore mentioned files playing on Android plex app or web browser are not possible even if they are set to direct play.

  • With “other” files transcoding and direct play is not an issue at all. Server ist nowhere near capacity even with 4 simultaneus transcodes.

Files

I wasn’t able do identify a common element in the “problematic” files. Appart from them being in general larger than the ones that work (not always consistent).

Observable Parameters

On the Dashboard in

  • Bandwith section the “working” files do show the “remote” line spiking to several Mbps. When I start a “problematic” file the “remote” line spikes to max 35 Kbps.

  • The top section “playing” will show that a problematic file is playing. After about 3 Minutes it stops.

I will try to figure out more specifics an will update the thread. If you can help in the meantime I’d appreciate it a lot.

Thanks

Okay I found the problem. Any file with a eac3 audio encoding is not playing (as described above).

This thread led me to check the codecs folder in the plexmedialibrary. I cannot find any eac3 decoder…

How do I add that one? Or better: where do I find it?

OK, there are some posts on the net that hint to the fact that this is an issue and the developers either cannot or will not do anything about it.

So I wrote a script, to convert all my eac3 encoded files to aac:

#!/bin/bash

############### DISCLAIMER ##################
# ######### USE AT YOUR OWN RISK! ###########
# I am not a professional programmer I have tested this script on my server and it is working.
# I DO NOT TAKE ANY RESPONSIBILITY FOR LOST OR CORRUPTED DATA!
# Read the code an undestand what it does before using it.

############### why and what ################
# No matter what I did inlcuding support by PLEX-Team I could not get eac3 files getting transcoded.
# Browser and Android-App do not have a eac3 decoder. Therfore you cannot play eac3 encoded files there.
# My solution: find all files with eac3 encoding and reencode them as aac while preserving all other streams.
# This is what this script does.
#
############### requirements ################
# in order for this script to work you need to install "mediainfo" from repositories.
# "sed" and "grep" should already be installed other whise do so:
# $ sudo apt install mediainfo sed grep
# copy this file to your preferred location.
#
############### good practice ###############
# since it is a script change owner and rights as follows
# $ sudo chown root:root
# $ sudo chmod 700
#
############### run it ###############
# I use crontab to run it once a day (at 11am)
# Caution: depending on the amount of files and your computer the first run can take VERY LONG
# $ sudo crontab -e
# add line:
# 0 11 * * * /my/location/convertscript.sh

# ############## SCRIPT ##############
# my tempfolders for generated files
tempfolder=/home/stefan/docker/admin/temp/
# change to tempfolder
cd $tempfolder

# note: if you have just one folder you want to check the first loop is an overkill (just run "mediainfo")
# an array for folders you want to check an populate it
folders=(Folder1 Folder2 Folder3)

# for every folder in the array get the mediainfo of the files (goes through subdirectories too)
for i in "${folders[@]}"
do
# write path/filename and audio encoding of all files in a csv file
mediainfo "--Inform=General;%CompleteName%,%Audio_Format_List%\r\n" /path/to/files/${i} >> List.csv
done

# find all path/filename (i.e. lines in the file) that are eac3 encoded and write them to a "toconvert" file that 
grep -E 'E-AC-3' List.csv > toconvert.csv
# line by line remove all text after (and including) the first coma and write it to a txt (you now have a file with path and filename of each mediafile you want to convert).
sed 's/,.*//' toconvert.csv > toconvert.txt
# set variable n to number of lines (i.e. files) to convert
n=$(grep "" -c toconvert.txt)

# converting files in a loop - changin ${n} to e.g. 10 you can control how many files get converted per run. If n < than your chosen number (e.g. 10) there will be errors but it will run.
for i in { seq 1 ${n} }
do
# set variable with the path/filename of the ith line
file=$(sed -n ${i}p toconvert.txt)
# convert the file to .temp file
ffmpeg -y -i "$file" -map 0:a? -map 0:s? -map 0:v -c:a aac -c:s copy -c:v copy -nostdin "${file}".mkv
# delete original
rm "${file}"
# rename the created *.mkv.mkv file to the just deleted one
mv "${file}".mkv "$file"
done

# delete all files in temp folder to have it empty for next run
rm $tempfolder/*.*

I am no linux expert. But I can tell you this:

EAC3 (among other codecs) is handled by the EasyAudioEncoder (EAE).
In order for EAE to work correctly, the transcoder temp folder needs to be mounted without the noexec parameter.
This is the most likely cause of it not working on your system.

To augment here,

This isn’t a developer problem. This is an administrator problem.

The problem exists because the docker container was placed on a local drive which was not mounted with the exec option -or- was specifically mounted with the noexec option.

Moving files to one’s home directory allows it to work because /home , being part of /, has exec privilege.

File permissions and ownership are owned by plex:plex so that the codec manager can update as new updates are installed.

Changing audio codecs is a rather brute-force solution to fixing a 10-second administrative change.

Thank you for the hints, believe me - i’d rather adjust my config instead of transcoding all data.

I use docker-compose (see below).

I have mounted the transcode volumes to home directory (APPDATADIR) or my preferred way: offload it to RAM. Both don’t work for eac3.

What do you mean by

I don’t know how to load a volume in docker with exec

plexms:
        container_name: plexms
        hostname: myhostname
        restart: always
        image: ghcr.io/linuxserver/plex
        volumes:
            - $APPDATADIR/plexms:/config
            - $APPDATADIR/plexms/transcode:/transcode2
            - $DATADIR/Music:/var/hda/files/Music
            ...
            - /dev/shm:/transcode # Offload transcoding to RAM if you have enough RAM
        ports:  
            - "$PLEX_PORT:32400/tcp"
           ...
            - "$PLEX_WEB_TOOLS_PORT:33400"
        environment:
            - PUID=$PUID
            - PGID=$PGID
            - TZ=${TZ}
            - HOSTNAME="myhostname"
            - PLEX_CLAIM_FILE=/run/secrets/plex_claim
            - ADVERTISE_IP=http://${SERVER_IP}:${PLEX_PORT}/
        secrets:
            - plex_claim
        ...

Can you help me out?

Thank you

I use docker run rather than compose. I find it far simpler

sudo docker run \
-d \
--name plex \
--network=host \
-e PLEX_CLAIM="claim-xxxxxxxx" \
-e TZ="EST" \
-e LANG="en_US.UTF-8" \
-e PLEX_UID=1000 \
-e PLEX_GID=1000 \
-e PUID=1000 \
-e PGID=1000 \
-h dockerplex \
-v /ssd/dockerplex:/config \
-v /ssd/dockerplex/tmp:/tmp \
-v /sata/dockerplex/transcode:/transcode \
-v /nas/media:/data \
--device=/dev/dri:/dev/dri \
plexinc/pms-docker:plexpass

Local host info:

  1. My UID/GID is 1000. No reason to mess with different UIDs
  2. HOST networking so it looks just like the native app on this host.
  3. /ssd is a 1TB NVMe SSD mounted in /etc/fstab with exec option (hint)
  4. /sata is a local HDD for transcode temp. No need to waste RAM
  5. /nas/media is the parent mount of all exported media (NFS) from the NAS.

IMHO – nothing fancy here.
All those variables only tend to obfuscate.

REMEMBER: The container uses the Host’s resources. The HOST partition must be mounted with exec for it to be also available to the container.

To further add,

You can manually install Webtools in the PMS-docker container if you wish for as long as the plug-in framework lasts.

Again thank you for your input.

I have currently 44 containers running - no way I keep up with the run command only :woozy_face:

While I further brooding about the problem, something didn’t make sense: Why would only EAE need seperate permissions? All others work just fine… (not sure if you can answer that).

I have checked fstab. All disks are mounted with defaults explicitly. AFAIK in defaults exec is the default value.

I do have a lot of RAM to spare (in every system I build - makes life easier). So in order to achieve fast transcoding I would like to be able to keep it there. Is this possible? Or do I have to create a RAM-disk (tmpfs /media/ramdisk tmpfs defaults,size=20% 0 0) for this? I’m going to check this next week in case you cannot answer this.

In addition, I also have hardware transcoding enabled (not shown in my code snippet).

@akreaxun

You can use docker run or docker compose to CREATE the container.
How you administer it after that is up to you because the container is registered with dockerd

EAE needs EXECUTE permission because it is a program. All the other codecs are shared library .SO files loaded into the transcoder.

.so files can be rw.
Executables must carry their own execute bit. (755) vs (644)

The EAE is a program created by Plex, tested and approved by Dolby, using the Dolby-licensed runtme libraries. It is a fully free-standing entity.

It is for these reasons, EAE must be executable as a program.

Thanks for all those insights. Very enlightening.

I found time to check if a RAMdisk works. The result so far is inconclusive, as it seems I cannot manage to load a RAMdisk properly. In fstab I have

tmpfs   /media/ramdisk  tmpfs   rw,auto,suid,dev,exec,nouser,async,size=50%     0       0

when I then check with mount I get

tmpfs on /media/ramdisk type tmpfs (rw,relatime,size=16403368k)

The only thing that is actually being read from the options in fstab is the size (rw was there before I added it to the options in fstab). Any thoughts on this or shall I check linux support forums?

# ramdisk
tmpfs /mnt/ramdisk tmpfs defaults,size=192G 0 0

This is a 256GB machine.

what are you trying to put on the ramdisk? Transcoder temp?

Exactly. Will try again.

Make sure to have an rc.local task to set the permissions so the Plex user can write to it.
By default, it will UID/GID root at every startup

Still no luck.

I copied your line (with adjusted RAM size) into fstab and changed owner of /ramdisk to my user:group for docker and permissions to 777. Still nothing.

mount gives me

tmpfs on /mnt/ramdisk type tmpfs (rw,relatime,size=16403368k)

still no exec.

So I thought I try to transcode it in my APPDATA directory which is on my main drive (should have exec right?) and shoud have the right owner and permissions… Or am I wrong with my assumption?

Transcoder temp data is not executable .

What are you trying to accomplish ?

The container’s /config itself must be on a volume which is mounted with the exec privilege so PMS itself runs correctly.

Transcoder temporary directory only contains video output data

May I see the container config and fstab ?

Sure.

fstab:

UUID=1 / ext4 defaults 0 0 #main drive (Samsung V-NAND SSD 883 DCT)
UUID=2 /boot/efi vfat defaults 0 0 #this was there when I setup the system, so I left it
/swap.img       none    swap    sw      0       0 #this was there when I setup the system, so I left it
UUID=3 /var/hda/files ext4 defaults 1 2 #data storage: 4 disks 40 TB in RAID 10 i.e. 20 TB effectively
tmpfs /mnt/ramdisk tmpfs defaults,size=50% 0 0

docker-compose of plexms container (without “Service” and “Network” definition).

plexms:
        container_name: plexms
        hostname: my_hostname
        restart: always
        image: ghcr.io/linuxserver/plex #plexinc/pms-docker:plexpass
        volumes:
            - $APPDATADIR/plexms:/config #APPDATADIR is on /home/my_user/docker/appdata
            - $APPDATADIR/plexms/transcode:/transcode2 #Testfolder to see if transcoding with EAE works on the main drive - so far no luck.
            - $DATADIR/Music:/var/hda/files/Music
            - $DATADIR/Pictures:/var/hda/files/Pictures
            - $DATADIR/Serien:/var/hda/files/Serien
            - $DATADIR/Dokus:/var/hda/files/Dokus
            - $DATADIR/Audiobooks:/var/hda/files/Audiobooks
            - $DATADIR/Movies:/var/hda/files/Movies
#            - /dev/shm:/transcode # transcoding with EAE on RAM without specific RAM disk, "normal" transcoding works.
            - /mnt/ramdisk:/transcode # transcoding with EAE on RAM with specific disk - no luck so far, "normal" transcoding works.
        ports:  
            - "$PLEX_PORT:32400/tcp"
            - "3005:3005/tcp" #probably a good idea to review these open ports.
            - "8324:8324/tcp"
            - "32469:32469/tcp"
            - "1900:1900/udp"
            - "32410:32410/udp"
            - "32412:32412/udp"
            - "32413:32413/udp"
            - "32414:32414/udp"
            - "$PLEX_WEB_TOOLS_PORT:33400"
        environment:
            - PUID=$PUID
            - PGID=$PGID
            - TZ=${TZ}
            - HOSTNAME="my_hostname"
            - PLEX_CLAIM_FILE=/run/secrets/plex_claim
            - ADVERTISE_IP=http://${SERVER_IP}:${PLEX_PORT}/
        secrets:
            - plex_claim
        networks:
            - t2_proxy
        # security_opt: #only for now. as soon as the current issue is resolved I'll enable this option again.
        #    - no-new-privileges:true               
        devices:
            - /dev/dri:/dev/dri # for hardware transcoding
        labels:
            - "traefik.enable=true"
            ## HTTP Routers
            - "traefik.http.routers.my_hostname-rtr.entrypoints=https"
            - "traefik.http.routers.my_hostname-rtr.rule=Host(`plex.$DOMAINNAME`)"
            ## Middlewares
            - "traefik.http.routers.my_hostname-rtr.middlewares=chain-authelia@file"
            ## HTTP Services
            - "traefik.http.routers.my_hostname-rtr.service=my_hostname-svc"
            - "traefik.http.services.my_hostname-svc.loadbalancer.server.port=$PLEX_PORT"

Transcoder settings on server right now:

  • Transcode quality: automatic
  • temp folder for transcoder: /transcode2
  • default … buffer for transcoder: 60
  • background reencoding x264 preset: fast
  • activate HDR tone mapping: check
  • deactivate video transcoding: uncheck
  • hardware acceleration: check
  • hardware accelerated video-encoding: check
  • max simultaneous video transcodings: unlimited

thanks for your efforts and merry christmas!

Stop Plex
Go into the Codecs directory
Remove everything for the EasyAccessEncoder (all things Dolby)
Start

Having the container in /home, which is the same partition as / , gives exec by default when the kernel boots.

Therefore, this must be a permissions / corruption problem of the EAE which exists on disk.

No luck

I did:

  • stop plex
  • delete EAE folder including all subfolders
  • start plex
  • play eac3 encoded mediafile (still not working)
  • checked owner user:group on mediafile, transcoder folder (and subsolders) and even EAE folder and files - they are identical. Moreover I changed all afore metioned folders and files to chmod 777 (just to be sure; including session folder once created; I know, only necessary for folders and files that need to be written to).

Is the rabbit hole going deeper or did we explore all options by now? If so, I’ll go with my brute-force method.

Again thank you for your time and efforts - much appreciated! :thanks: :trophy: :+1:

→ adjusted title of thread to reflect the issue more precisely

I have no idea why yours is failing.
There are countless other containers working without issue on Linux and NAS systems.

Even the unforgiving DSM 7 has docker overlaying the native package data without issue and using the same codecs.

This is my docker container. No frills or complexity.

for reference:

Here’s the /sata mount (1TB SSD in the NUC)

/dev/sda1 on /sata type xfs (rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota)
[chuck@lizum docker.2003]$ grep /sata /etc/fstab
/dev/sda1              /sata                  xfs     defaults,auto,noatime    0   3
[chuck@lizum docker.2004]$ 

The docker run. bare bones minimal

sudo docker run \
-d \
--name plex \
--network=host \
-e TZ="EST" \
-e LANG="en_US.UTF-8" \
-e PLEX_UID=1000 \
-e PLEX_GID=1000 \
-e PUID=1000 \
-e PGID=1000 \
-h dockerplex \
-v /sata/dockerplex:/config \
-v /sata/dockerplex/tmp:/tmp \
-v /sata/dockerplex/transcode:/transcode \
-v /nas:/data \
--device=/dev/dri:/dev/dri \
plexinc/pms-docker:plexpass

#docker start plex
#docker update --restart=unless-stopped plex
[chuck@lizum docker.2002]$ 

You have all those extras about load balancing, etc – to what gain?