Help (Raspberry PI OS 32bit) video streaming on Safari iOS and iOS App >v2.22

Hi,

Can anyone report a working configuration for NC13 on Nginx for video (mp4) streaming on iOS Safari browser ?

So far I always have get the same result (see screenshot) : “The video could not be loaded, either because the server or network failed or because the format is not supported”
screenshot

Video streaming works with my config in windows pc browsers, with byte-range requests enabled.

Is it a video format issue? No, the issue occurs with the default Nextcloud.mp4 video.
Is it a network or server issue? No - everything works fine except videos on iOS Safari.
Is it the byte range request issue ? No, they are functional on my config.
Is it a NC13 issue? No or in conjunction with Nginx - I’m able to stream my videos on Safari/iOS from the NC13 Demo instance that runs with Apache.

So far I tried with the Nginx default configuration from NC13 Admin docs and the configuration proposed by C. Rieger (https://www.c-rieger.de/nextcloud-13-installation-guide/)

Nextcloud version : 13.0.0
Operating system and version : Raspbian stretch
PHP version : 7.0.27
Nginx version : nginx/1.13.9 built by gcc 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1+deb9u1) built with OpenSSL 1.1.0f 25 May 2017 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/usr/local/src/nginx-1.13.9=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' --add-module=/usr/local/src/nginx-1.13.9/debian/modules/ngx_cache_purge-2.3

EDIT : I tried with iOS 11.2.6 (iPhone7) and iOS 10.3.3 (iPad 4th Gen.)

Hi,

If the video can be played/ streamed by the HTML5 player used in Nextcloud depends on the Browser you are using. That is why, the browser on your desktop plays the videos, while the browser on your Apple devices do not.
So far that is the basic information to that to know about and to consider. If there are configurations to somehow work around missing file codec support? I don’t know.
If you can influence the codec which is used for the videos, you could do that as a probably quick solution.

Before all that have a look here:

As alternative solution: could you download another browser on your devices and try with them? You orientate yourself on the browser support list, which browser might suite you best - especially regarding the vdeo/ audio codecs you use in your videos.

Hi @Schmu,

Thanks for taking care of my demand, but as I wrote in my post, I am sure it is not a video format/encoding issue neither a browser compatibility issue. I made 2 tests to prove it:

  1. The default Nextcloud.mp4 video doesn’t play on iOS Safari browser, though it is supposed to be compatible.
  2. My own videos that I have uploaded in a demo NC13 instance do play well on Safari/iOS browser. But the exact same video won’t play from my own NC13 instance build with Nginx, using the same browser/iOS device.

So basically I now wonder if someone effectively managed to playback video using Safari/iOS browser from an NC13/Nginx instance?
If yes I would be immenselly grateful to that person to share his configuration. :heart_eyes:

I also tried with Chrome/iOS, it failed the same way.
My videos are mp4, h264, aac

I finally found the cause of this issue, that breaks video streaming playback within iOS Safari web UI or iOS Nextcloud App >v2.22.
This only occurs with Nextcloud server running on 32bit OS like mine (RPI3 Raspbian stretch).

It’s a Sabredav change (https://github.com/sabre-io/http/pull/74) meant to work around the 32bit OS filesize limitation, that unfortunately causes this bad side effect on byte range requests that are required by iOS to allow video playback.
It has nothing to do with PHP or Nginx configuration.
I opened this issue on Sabredav https://github.com/sabre-io/http/issues/108

While waiting for the official fix, here’s my quick fix proposal (32bit OS only, like Raspberry PI OS). Be warned that the max filesize would then be 2GBytes. This quickfix is valid for NC22 and below.

Go to your Nextcloud installation directory, e.g. /var/www/nextcloud
Make a backup copy of the file ./3rdparty/sabre/http/lib/Sapi.php in order to revert the fix if it causes unexpected issues.
Note that you will have to redo this after each Nextcloud upgrade as it is not officially fixed and will probably never be.

Edit this file ./3rdparty/sabre/http/lib/Sapi.php , lines 92:
Change

 if (PHP_INT_SIZE > 4) {

to

 if (PHP_INT_SIZE > 0) {

Save and done, no need to restart any process.

On older versions of Nextcloud, you might find another flavor of the code to change, same file ./3rdparty/sabre/http/lib/Sapi.php , lines 78-80.
Change

                if (PHP_INT_SIZE !== 4){
                     // use the dedicated function on 64 Bit systems
                     stream_copy_to_stream($body, $output, $contentLength);  

to

                if (PHP_INT_SIZE !== 0){
                    // use the dedicated function on 64 Bit systems
                    stream_copy_to_stream($body, $output, (int)$contentLength);  

This fix disable the INT size check, making it always true. I added the (int) cast, that is a fix from Sabre team.

3 Likes

This is an old thread, but I was facing the same issue: Video were playing fine in all browsers besides Safari. This includes video not running on iOS, due to all browsers on iOS having to use the Safari engine(s).

Since I also followed the manual by c-rieger at first, I saw the connection to the OP of this thread.

Long story short: Throwing my current nginx configuration overboard and going for the one from the official manual fixed my problems.

1 Like

You are right. c-rieger configuration used some nginx cache features that prevented byte-range requests to be served correctly. Correct byte-range requests are required by Apple OS html5 streaming implementation.
Disabling this cache configuration first solved streaming issue.
I believe c-rieger now fixed this in today’s tutorial.

Then I fell into this other issue I describe in this thread, which is specific to 32bit OS as is raspbian on a Raspberry.

rmufr,

Thanks for your fix above. I wanted to add another caveat. Your fix works for me up to a point. Using a RPi 3 B+ with NextCloudpi, when I use your fix above, the Nextcloud test mp4 will play in Safari on my Macbook and in the Nextcloud app on my iPhone XR. When I try a larger file, a 1.5 GB m4v video, it will not play in Safari or on the app on the iPhone. This same larger video will play through my Brave browser on the macbook and not through the Brave browser on my iPhone.

I assume this has to do with the file size and not the format.

(I did see your 2 postings related to this on Github.)

Hi @tripplc,

Sorry I missed your message notification, just seen it now.
Did you find the solution to your issue?

I expect the file size limit to be 2GB for this fix above, but to be honest, I did not make the test.
This is the theoretical limit of 32bits signed integer numbers.
On iOS, all browsers are forced by Apple policies to use Apple’s web API, so the behaviour is expected to be the same, be it Brave, Chrome, Opera , etc.

Did you test the same exact video format with a smaller size ? Have you tried different video sizes, in order to approximate the critical size that triggers the issue ?

@rmufr,

Thanks for the response.

Here is what I did and what I am running into. There continues to be a limit for videos with Mac and iOS.

Thinking that the 32 bit was the limitation, I purchased the Rock64 to try a 64bit system. I have installed Nextcloudpi. Everything is working well except the video streaming issue.

There seems to be some 50MB (approx) limit in size of video that will play.

  • A 46MB video I have in Nextcloud on the Rock64 will play on:
    • Macbook Pro - both through the Brave and Safari browser.
    • On iPhone XR - through the Safari Browser, Brave Browser and the Nextcloud app.
  • When I try a 69 MB video:
    • Won’t play at all on iPhone in any of those 3 places.
    • Won’t play on Macbook through Safari.
    • Will play on Macbook through the Brave Browser.

Just for comparison, I put the same 69 MB video in Dropbox. It played on the Macbook through Safari and also through the Dropbox App on the iPhone.

So, is this a Nextcloud issue, or a Nextcloudpi issue with not having a workaround for some limit that Apple set?

Hi @tripplc,

For sure, it’s not just a question of video file size. I can playback a 130MB video inline with NC App on a iPhone 7 (NC server on a RPI3/Raspbian)
Both NC App and NC web browser gui use HTML5.
Apple has some restrictions on the video format, make sure yours are compliant :
(source Apple Dev. Doc.)

Supported Media
Safari on the desktop supports any media the installed version of QuickTime can play. This includes media encoded using codecs QuickTime does not natively support, provided the codecs are installed on the user’s computer as QuickTime codec components.

Safari on iOS (including iPad) currently supports uncompressed WAV and AIF audio, MP3 audio, and AAC-LC or HE-AAC audio. HE-AAC is the preferred format.

Safari on iOS (including iPad) currently supports MPEG-4 video (Baseline profile) and QuickTime movies encoded with H.264 video (Baseline profile) and one of the supported audio types.

iPad and iPhone 3G and later support H.264 Baseline profile 3.1. Earlier versions of iPhone support H.264 Baseline profile 3.0.

I use the following 2 pass ffmpeg operations to make my videos compliant with most OS/Browsers, with a 5Mb/s rate cap (mp4/h.264/aac):
# Pass 1
ffmpeg -y -i <input_video_file> -acodec aac -vcodec libx264 -vb 5M -x264-params subq=4:bframes=2:b_pyramid=normal:weight_b -pass 1 -f mp4 /dev/null
# Pass 2
ffmpeg -i <input_video_file> -acodec aac -vcodec libx264 -vb 5M -x264-params subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid=normal:weight_b -pass 2 -movflags +faststart <output_file_name>.mp4