Audio sync issues on Fire Stick for AC3 2 Channel (Stereo) (x265/HEVC codec)

Server Version#: 1.25.5.5492
Player Version#: (Latest version from Amazon App store, will update if I work out how to get a specific version)

I recently switched to using FireTV sticks for my Plex Client. Given that they support H265 (my previous Chromecasts didn’t) I decided to start using x265 encoded files to save space on my server.

This is all playing in “direct” mode, no transcoding.

I’ve noticed that after only a couple of seconds of play there is a massive audio sync issue for anything encoded in x265/HEVC that has 2 channel audio (snippet from plex info below):

Codec HEVC
Bitrate 634 kbps
Bit Depth 8
Chroma Location left
Chroma Subsampling 4:2:0
Coded Height 720
Coded Width 1280
Color Range tv
Frame Rate 23.976 fps
Height 720
Level 3.1
Profile main
Ref Frames 1
Scan Type progressive
Width 1280
Display Title 720p (HEVC Main)
Extended Display Title 720p (HEVC Main)
Codec AC3
Channels 2
Bitrate 192 kbps
Language English
Language Tag en
Audio Channel Layout stereo
Sampling Rate 44100 Hz
Display Title English (AC3 Stereo)
Extended Display Title English (AC3 Stereo)

However, identical files (also encoded with the same codec) with 6 channel audio play absolutely fine:

Codec HEVC
Bitrate 1030 kbps
Bit Depth 8
Chroma Location left
Chroma Subsampling 4:2:0
Coded Height 720
Coded Width 1280
Color Primaries bt709
Color Range tv
Color Space bt709
Color Trc bt709
Frame Rate 23.976 fps
Height 720
Level 3.1
Profile main
Ref Frames 1
Scan Type progressive
Width 1280
Display Title 720p (HEVC Main)
Extended Display Title 720p (HEVC Main)
Codec AC3
Channels 6
Bitrate 448 kbps
Language English
Language Tag en
Audio Channel Layout 5.1(side)
Sampling Rate 48000 Hz
Display Title English (AC3 5.1)
Extended Display Title English (AC3 5.1)

This is only an issue with Fire Sticks (I have a 4k and a non-4k one and they both have the same issue), but doesn’t happen in any other Plex client (Samsung Smart TV x 3, Web UI, Android Player).

Is anyone else experiencing this/able to re-produce it?

I’ve tried forcing it to transcode however the FireTV stick seems to ignore that setting every time I try and use it.

From what I can tell this doesn’t seem to affect H264 encoded files with 2 channel audio as they seem to use AAC audio instead.

EDIT: If there are a standard set of Plex test files I can/should use to reproduce this please let me know where they are and I’ll try and re-produce with those.

Hi, muppet_3000. I see the same problem. I’ve been doing exactly the same thing, e.g., converting to x265/HEVC encoded files to save space on my server. With your insight regarding the audio encoding, I changed to use audio passthru, rather than conversion to AC3 2-channel. So far, I’ve only tested this on one file, but it did fix the audio sync problem that I was seeing on my Fire cube and Fire sticks for that video.

Thanks for coming back to me. I completely forgot to come back and update this.

I re-encoded the files using ffmpeg with the following flags: -acodec aac -vcodec copy i.e. copy the video codec exactly as it was, but change the audio code to aac.
It takes up the same space and works perfectly.

I wrote a script that went through my media library and found all files that were: x265 and AC3 2-Channel and then re-encoded them accordingly.

Would you share the script? I’ve since converted a few other files (which also fixed their audio sync problems) and will have to check all my other files as you have done. Thanks for your post identifying the problem.

Sorry for the delayed response. Of course I’m happy to share my hacky AF script that I wrote.
I’ll share it with the following caveats though:

  1. I accept no responsibility if this causes damage to anybody’s media libraries
  2. It expects a path /mnt/storage/reencoded_originals to exist (you can just pick a different folder and replace it) because I was worried about losing the originals in case it destroyed it when re-encoding, you could just change this line though to do an rm on the original if you’re feeling adventurous.
  3. Approximately 5 lines into writing it I realised it would be better written in python, however, I’m stubborn so I just continued in bash
  4. It depends on ffmpeg being available and also ffprobe (which I believe is provided as part of the ffmpeg packages)
  5. Yeah it’s ugly, yeah it could probably be more efficient, maybe even parallelised, but at the end of the day, it did what it needed to and I left it running in a tmux session overnight so it didn’t matter how long it took

Anyway, without further ado, here is my masterpiece :stuck_out_tongue:

well, uploading a .sh file isn’t allowed apparently, so here’s a copy/pasted code-block…

#!/bin/bash

IFS=$'\n' video_files=( $(find . -type f \( -name "*.mkv" -o -name "*.avi" -o -name "*.mp4" \)) )

for line in "${video_files[@]}"
do
  channels=$(ffprobe -hide_banner -loglevel quiet -print_format json -show_format -show_streams "${line}" | grep channels | sed -e 's/^[ \t]*//' | cut -d ' ' -f2 | sed 's/,//g')
  h264_encoder=$(ffprobe -hide_banner -loglevel quiet -print_format json -show_format -show_streams "${line}" | grep codec_name | grep h264 | sed -e 's/^[ \t]*//')
  h265_encoder=$(ffprobe -hide_banner -loglevel quiet -print_format json -show_format -show_streams "${line}" | grep codec_name | grep hevc | sed -e 's/^[ \t]*//')
  mpeg4_encoder=$(ffprobe -hide_banner -loglevel quiet -print_format json -show_format -show_streams "${line}" | grep codec_name | grep mpeg4 | sed -e 's/^[ \t]*//')
  audio_codec=$(ffprobe -hide_banner -loglevel quiet -print_format json -show_format -show_streams "${line}" | grep codec_name | grep -e "aac" -e "ac3" -e "mp3" | sed -e 's/^[ \t]*//' | cut -d ' ' -f2 | sed 's/,//g' | sed 's/"//g')

  extension="${line##*.}"
  filename="${line%.*}"

  #echo "Name: ${filename}, Extension: ${extension}"

  if [[ "${channels}" == "2" ]]; then
    if [[ "${h264_encoder}" != "" ]]; then
      if [[ "${audio_codec}" == "aac" ]]; then
        #echo ${line}
        #echo "- 2 Channels, H264 - ${audio_codec}"
        #echo ""
        : #No action required
      fi
    elif [[ "${h265_encoder}" != "" ]]; then
      if [[ "${audio_codec}" == "ac3" ]]; then
        echo ${line}
        echo "- 2 Channels, H265 - ${audio_codec}"

        if [[ "$1" == "reencode" ]]; then
          echo "RE-ENCODING, original name: ${line}, new name: ${filename}-aac-reencoded.${extension}"
          echo "ffmpeg -i \"${line}\" -acodec aac -vcodec copy \"${filename}-aac-reencoded.${extension}\""
          ffmpeg -i "${line}" -acodec aac -vcodec copy "${filename}-aac-reencoded.${extension}"
          mv "${line}" /mnt/storage/reencoded_originals/
        fi
        echo ""
      fi
    elif [[ "${mpeg4_encoder}" != "" ]]; then
      : #No action required
      if [[ "${audio_codec}" == "aac" ]]; then
        echo ${line}
        echo "- 2 Channels, MPEG4 - ${audio_codec} - CHECK"
        echo ""
      fi
    else
      echo ${line}
      echo "- 2 Channels - Unknown Video codec - ${audio_codec}"
      ffprobe -hide_banner -loglevel quiet -print_format json -show_format -show_streams "${line}" | grep codec_name
      echo ""
    fi
  fi
done

Good luck & godspeed

Hi, muppet_3000.

Thanks for sharing. I haven’t studied your script yet. But over the weekend, I discovered Tdarr and Unmanic. I’m going to install Tdarr today. I expect it will simplify/centralize some other things I’m doing to process recordings and downloads, in addition to re-encoding my library to h.265 and AAC.

Thanks. Your original post, in particular, got me on the right track to fix the audio problem, and now a more general solution.

No problem at all.
To be honest, even if nobody else ever uses my script, it doesn’t matter. I care more that there’s a complete forum post about the problem and the subsequent work-around.
I’m surprised that there isn’t an official bug for this, but more than anything I’m glad that it’s not just me that has this issue!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.