HaveAGitGat / Tdarr

Tdarr - Distributed transcode automation using FFmpeg/HandBrake + Audio/Video library analytics + video health checking (Windows, macOS, Linux & Docker)
Other
2.84k stars 89 forks source link

Tdarr Node M1 slow performance #605

Closed Aquenon closed 2 years ago

Aquenon commented 2 years ago

Hi, I don't know if the app isn't working right, if I made a mistake, or if this is just something the M1 isn't good at. I have an M1 Max 32GB Mac Studio that I let act as a node when I'm not using it. But it is painfully slow at 2 fps on one transcode. Slower than my server's own node (6700K CPU machine that was built in 2016), and even slower than a 2008 Mac Pro (which is still running at 2 fps but it does have 3 transcodes running).

I've verified I'm using the ARM version of Tdarr Node, as well as the ARM versions of HandbrakeCLI, FFmpeg, and MKVPropEdit.

❯ file /opt/homebrew/Cellar/handbrake/1.5.1/bin/HandBrakeCLI
/opt/homebrew/Cellar/handbrake/1.5.1/bin/HandBrakeCLI: Mach-O 64-bit executable arm64

❯ file /opt/homebrew/Cellar/ffmpeg/5.0.1/bin/ffmpeg
/opt/homebrew/Cellar/ffmpeg/5.0.1/bin/ffmpeg: Mach-O 64-bit executable arm64

❯ file /opt/homebrew/Cellar/mkvtoolnix/67.0.0/bin/mkvpropedit
/opt/homebrew/Cellar/mkvtoolnix/67.0.0/bin/mkvpropedit: Mach-O 64-bit executable arm64

Am I doing something wrong? Is this something the M1s don't perform well on? It runs great on everything else. I'll include my node's config file.

{
  "nodeID": "Mac Studio",
  "serverIP": "10.0.0.10",
  "serverPort": "8266",
  "handbrakePath": "/opt/homebrew/Cellar/handbrake/1.5.1/bin/HandBrakeCLI",
  "ffmpegPath": "/opt/homebrew/Cellar/ffmpeg/5.0.1/bin/ffmpeg",
  "mkvpropeditPath": "/opt/homebrew/Cellar/mkvtoolnix/67.0.0/bin/mkvpropedit",
  "pathTranslators": [
    {
      "server": "/mnt/media/",
      "node": "/Volumes/data/media/"
    },
    {
      "server": "/temp/",
      "node": "/Volumes/temp/tmp/"
    }
  ],
  "platform_arch": "darwin_arm64_docker_false",
  "logLevel": "INFO",
  "nodeIP": "10.0.0.20",
  "nodePort": "8267"
}

Thanks, Scott

supersnellehenk commented 2 years ago

ARM is a lot slower compared to x86 due to the missing AVX instructions. So lower speeds are expected. I don't know how slow, but I tested it on a M1 Pro and I also got like 1-3 FPS.

Aquenon commented 2 years ago

Thanks! I just wanted to make sure I didn't have anything set up wrong. It's not a big deal as I only let it act as a node when I'm not going to be on it.

HaveAGitGat commented 2 years ago

Yeah pretty common issue with M1: https://www.reddit.com/r/handbrake/comments/rbc0pc/speeds_pretty_slow_on_m1_macbook_pro_13in/

You can try using the hardware encoder (videotoolbox) which is 3 times faster or so: https://trac.ffmpeg.org/wiki/HWAccelIntro

VideoToolbox
[​VideoToolbox](https://developer.apple.com/documentation/videotoolbox), only supported on macOS. H.264 decoding is available in FFmpeg/libavcodec.

To use hardware encoding in macOS, just use the encoder -c:v h264_videotoolbox or -c:v hevc_videotoolbox for H.264 or HEVC respectively. Check ffmpeg -h encoder=... to see encoder options. It's worth noting that VideoToolbox does not support constant quality (CRF) encoding. Bit rate, -b:v ..., is your main lever to balance size vs quality.
johnnynunez commented 2 months ago

Yeah pretty common issue with M1: https://www.reddit.com/r/handbrake/comments/rbc0pc/speeds_pretty_slow_on_m1_macbook_pro_13in/

You can try using the hardware encoder (videotoolbox) which is 3 times faster or so: https://trac.ffmpeg.org/wiki/HWAccelIntro

VideoToolbox
[​VideoToolbox](https://developer.apple.com/documentation/videotoolbox), only supported on macOS. H.264 decoding is available in FFmpeg/libavcodec.

To use hardware encoding in macOS, just use the encoder -c:v h264_videotoolbox or -c:v hevc_videotoolbox for H.264 or HEVC respectively. Check ffmpeg -h encoder=... to see encoder options. It's worth noting that VideoToolbox does not support constant quality (CRF) encoding. Bit rate, -b:v ..., is your main lever to balance size vs quality.

but not exists harware decoding right?

HaveAGitGat commented 2 months ago

@johnnynunez according to here it does: https://trac.ffmpeg.org/wiki/HWAccelIntro#VideoToolbox

Not 100% sure on the command but think it's like this: https://trac.ffmpeg.org/ticket/7545

ffmpeg -hwaccel videotoolbox -i /Volumes/AkemiData/Downloads/sSKl.mp4 -f null -