Stuttering movie playback in QuickTime

xjarty

Cadet
Joined
Jan 31, 2021
Messages
8
Hi everyone! I'm new to TrueNAS and the community, so please be gentle. ;)

I recently set up a remote TrueNAS server to stream movies over the internet. I'm having trouble getting smooth playback, the movies tend to stutter. I'll explain my setup below, hopefully someone may have insight?

My goal is to play MP4 movies in QuickTime on my Mac over an AFP share. I know a lot of folks use Plex for this, but I'm hoping to keep it simpler. I'm just opening the movie files from the AFP share into QuickTime Player. When I first open a movie I can see that it buffers for a few seconds (observed in the network activity). I press play and playback is smooth for several seconds, then it starts to stutter. If I pause the movie for a few seconds to let it buffer it will start playing smoothly for a few more seconds, but then it starts to stutter again. Pausing for longer doesn't help, QuickTime won't buffer any further. It's not just a problem with QuickTime, I've seen the same behavior in VLC and when playing the movie in Safari using an HTML5 <video> tag.

I don't think my internet connection should be the problem. The remote server has a 100 Mbps uplink, I've confirmed this speed by downloading large files from the server to my Mac. My personal internet connection is close to 1 Gbps and I've confirmed I can truly achieve this speed. The remote server lives in the same city, and I get ping times of 15-25 ms.

I don't think my hardware is the problem. I have a brand new Supermicro server with a Xeon processor and 32 GB RAM. I have a multi-disk raidz2 array with enterprise-grade disks. The array is only 5% full and freshly copied, so capacity/fragmentation should not be an issue. The hardware is fully capable of reading/sending data quickly enough, I've confirmed this by downloading large files from the server to my Mac. My Mac is a recent model, plenty fast enough for the task. When I play the movies from my local disk, they're buttery smooth.

My TrueNAS OS is up to date, I'm running 12.0-U1.1.

I have noticed that the stuttering seems worse during the daytime, and better (though still not great) in the middle of the night. This suggests to me it might be related to network congestion. However the transfer speeds from the server should be plenty fast enough day or night. I've measured sustained real world speeds of at least 80 Mbps, which is >5x what I need to stream a simple 1080p movie. Given this I can't imagine how performance can be so bad.

Has anyone seen anything like this? Any suggestions for how to fix it? Thanks in advance for your help!
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
AFP over the WAN is notoriously bad. You'll do better to serve the movies via a web server in a jail with HLS streaming extensions. QuickTime can consume HLS streams.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
Part of the reason that things like Plex and clients exist is that there is a bit of specialization in the whole thing.

Using AFP is going to suck; it is hard enough to get basic TCP to work well "at a distance". @Samuel Tai has a reasonable suggestion in the form of HLS, at which point you are no longer dependent on a deprecated Apple protocol, but that will still lack the ability to do things like transcoding that Plex does very well at.

It's worth reconsidering.
 

Dan Tudora

Patron
Joined
Jul 6, 2017
Messages
276

ThreeDee

Guru
Joined
Jun 13, 2013
Messages
700
I don't know if this is applicable in your situation .. but I have encountered stuttering on some "smart" tv's and awhile back on PS4 and Xbox One's before they must have received an update or something .. with MP4's with H265 encoding. Converting same file to H264 and playback is nice and smooth like it should be.
 

Dan Tudora

Patron
Joined
Jul 6, 2017
Messages
276
I recently set up a remote TrueNAS server to stream movies over the internet
hello
provide more detail about connection/router/VPN or NOT/
hardware specs/network
inside LAN work correct with your NAS/AFP share with your MAC ??
something !!:smile:
 

xjarty

Cadet
Joined
Jan 31, 2021
Messages
8
Thanks @ThreeDee, I do get the sense that x265 movies play worse than H264 in my setup (but even H264 often stutters). I may explore some different codecs, maybe there's something out there that works well over AFP.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
I don't know if this is applicable in your situation .. but I have encountered stuttering on some "smart" tv's and awhile back on PS4 and Xbox One's before they must have received an update or something .. with MP4's with H265 encoding. Converting same file to H264 and playback is nice and smooth like it should be.

The biggest problem with "smart" TV's is that they tend to have very limited memory, and kernel configurations to match. Streaming tends to work better when there are free resources to handle the inherent burstiness of traffic across the Internet, and they often come up somewhat lacking.
 

ThreeDee

Guru
Joined
Jun 13, 2013
Messages
700
The biggest problem with "smart" TV's is that they tend to have very limited memory, and kernel configurations to match. Streaming tends to work better when there are free resources to handle the inherent burstiness of traffic across the Internet, and they often come up somewhat lacking.
The game consoles were using Plex (awhile back) .. the "smart" tv's where accessing files directly off of a thumb drive. (they don't have internet access)
..but I am in agreement about Plex or similar being a better solution for OP.
 

xjarty

Cadet
Joined
Jan 31, 2021
Messages
8
Update: I managed to resolve my issue, thanks to the helpful advice above. I thought I'd write up my solution in case someone else needs this in the future.

It turns out AFP really was the source of the stuttering. To get around it, I set up a web server in a jail to serve up a webpage with an HTML5 video, where the source was set to a movie on the NAS (locally, from context of the web server). I can navigate to the webpage from my Mac, and it will stream the movie in the browser. Playback is buttery smooth and perfect quality. There was no need for fancy transcoding like HLS or Plex. Granted I'm on a fast internet connection, playback from coffee shop wifi may benefit more from transcoding, but I doubt I'll ever need that. The web video does basically everything I needed from QuickTime, like full screen playback.

One limitation here is that it adds some friction when opening movies. I typically search/browse my movies in the Finder (over AFP). Once I find a movie to watch, I now have to translate it into a web address to load in the browser. I managed to script my way around this with a combination of Automator, Python and Javascript, so that opening a movie on my NAS AFP share automatically translates into a web URL and opens it in the browser. It now works like magic!

Anyway, thanks all for your help, and hope this solution is perhaps helpful for someone else in the future.
 
Top