Trouble playing videos on web interface

Nextcloud version (eg, 20.0.5): 23.0.2
Operating system and version (eg, Ubuntu 20.04): Debian 11 (Bullseye)
Apache or nginx version (eg, Apache 2.4.25): lighttpd 1.4.59
PHP version (eg, 7.4): 8.0.16

The issue you are facing:

If I click an mp4 video from the file browser or gallery to view it, I will almost always get an error: ‘Error loading <filename.mp4>’. Smaller mp4 files (<25MB or so) will play correctly sometimes, but larger ones almost never do. If the sidebar is open, sometimes I’ll get an error toast ‘Server connection lost.’ I am able to download the files no problem, and there are correct previews generated for them. Sometimes if I click a file, I’ll see one frame (like what’s shown in the preview) for an instant before the error message appears.

There are no new lines in the Nextcloud log file when this happens. The error message happens very quickly, not like it’s timing out or anything. I have a very fast and reliable connection with the server.

INTERESTING NOTE: If I have a directory with multiple mp4 files, I can click any one of them, and whether or not it successfully plays, if I go to the next video by clicking the > or < arrows on the sides of the screen, the videos seem to play just fine. For example: I have a directory with 5 videos in it, and no other files. I can click any one of them, and maybe it will play or (probably) it won’t. Then if I click the right arrow, I can play all 5 of the videos no problem, just looping through them, but if I click the X to exit the player and just click another video, I’ll probably get the error.

There’s an error that pops up in the lighttpd error log when this happens (pasted below). But, related to the interesting note above: if I click on a video and it plays without error, I don’t get the lighttpd error message; if I click on a video and see the error on the screen, lighttpd throws the error message. BUT if I click a video and then go to the next one using the arrow buttons, the lighttpd error happens sometimes, but not always, even though the video plays successfully every time.

Is this the first time you’ve seen this error? (Y/N): Yes

I have a second NC 23.0.2 instance running on a different computer (on CentOS instead of Debian, plus various other differences) and don’t see this behavior. I can also play the offending videos just fine from the Android app.

Steps to replicate it:

  1. Have a directory with multiple mp4 video files, ideally >25MB
  2. Click one of the video files in the web interface to view it (likely failure in my case)
  3. Click the > or < buttons to increment to the next video file (guaranteed success in my case)

The output of your Nextcloud log in Admin > Logging:

(Nothing shows up in the Nextcloud log when this happens)

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'gibberish',
  'passwordsalt' => 'gibberish',
  'secret' => 'gibberish',
  'trusted_domains' => 
  array (
    0 => 'my.domain.com',
  ),
  'datadirectory' => '/data/nextcloud',
  'dbtype' => 'mysql',
  'version' => '23.0.2.1',
  'overwrite.cli.url' => 'https://my.domain.com',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'gibberish',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' =>.
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'default_phone_region' => 'US',
  'allow_local_remote_servers' => true,
  'theme' => '',
  'preview_max_memory' => 6144,
  'enable_previews' => true,
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\PDF',
    1 => 'OC\\Preview\\Image',
    2 => 'OC\\Preview\\Photoshop',
    3 => 'OC\\Preview\\TIFF',
    4 => 'OC\\Preview\\SVG',
    5 => 'OC\\Preview\\MP3',
    6 => 'OC\\Preview\\Movie',
    7 => 'OC\\Preview\\MKV',
    8 => 'OC\\Preview\\MP4',
    9 => 'OC\\Preview\\AVI',
  ),
  'loglevel' => 2,
  'maintenance' => false,
  'mail_smtpmode' => 'sendmail',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'admin',
  'mail_domain' => 'my.domain.com',
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' => 
  array (
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
);

The output of your Apache/nginx/system log in /var/log/____:

A representative lighttpd error that comes up in lighttpd’s error.log:

2022-03-14 19:20:17: chunk.c.891) open failed: /tmp/lighttpd-upload-s0o1up: No such file or directory
2022-03-14 19:20:17: connections.c.466) connection closed: write failed on fd 12

… as a note, the web server is able to write to /tmp. /tmp is mounted with options like NOEXEC so to be sure, I created another temp directory with no unusual restrictions, pointed lighttpd to it (with server.upload-dirs in the lighttpd config file) and re-tested, with no change in behavior. Also, as noted above, sometimes playing videos works on the first try and this error isn’t generated; also, sometimes the error happens even if the video plays successfully using the > or < buttons.

The huge preview_max_memory in the config.php file above is something I added during troubleshooting, but the previews all get generated without any problems.

Any hints would be appreciated! I’m especially interested in what the difference might be between clicking a thumbnail to view the video vs clicking the > arrow to view it. If there’s some difference there maybe that will help identify where to look next.

Thanks!

Hi all,

I guess nobody had any ideas on this 6 months ago but I am hoping that maybe today someone has a thought? This server is now running Nextcloud 24.0.3 (yes I need to upgrade) with php 8.1.9, but still has the same problem playing videos.

As before, the only error message on the server side that I get is the one generated by lighttpd that a temporary file failed to be read/written.

Also as before, two other servers (running CentOS 7 instead of Debian 11) play the same videos just fine, and I can play the video using the Android app from the offending Debian server with no problems; it’s only the web interface on the Debian server that gives a problem.

A new bit of information: I watched the Javascript console on the browser while I tried to play the video.

On one of the older CentOS servers, this happens without drama: in the console I see a message from Viewer.vue:

"Opening viewer for file [file]"

On the offending server, I get a bunch of additional stuff:

[INFO] viewer: Opening viewer for file  
Object { app: "viewer", uid: "elliott", path: "[path]" }
ConsoleLogger.js:33:16
HTTP “Content-Type” of “video/3gpp” is not supported. Load of media resource [url] failed. files
Error loading [path] 
error { target: div.plyr.plyr--full-ui.plyr--video.plyr--html5.plyr--fullscreen-enabled.plyr--paused.plyr--stopped, isTrusted: false, detail: {…}, srcElement: div.plyr.plyr--full-ui.plyr--video.plyr--html5.plyr--fullscreen-enabled.plyr--paused.plyr--stopped, currentTarget: div.viewer__file--hidden.viewer__file
, eventPhase: 3, bubbles: true, cancelable: false, returnValue: true, defaultPrevented: false, … }
Mime.js:98:11
[DEBUG] viewer: Closing video stream 
Object { app: "viewer", uid: "elliott", filename: "[path]" }
Error loading [path]
error { target: div.plyr.plyr--full-ui.plyr--video.plyr--html5.plyr--fullscreen-enabled.plyr--paused.plyr--stopped, isTrusted: false, detail: {…}, srcElement: div.plyr.plyr--full-ui.plyr--video.plyr--html5.plyr--fullscreen-enabled.plyr--paused.plyr--stopped, currentTarget: div.viewer__file--hidden.viewer__file
, eventPhase: 3, bubbles: true, cancelable: false, returnValue: true, defaultPrevented: false, … }
Mime.js:98:11
[DEBUG] viewer: Closing video stream 
Object { app: "viewer", uid: "elliott", filename: "[path]" }
Error loading [path]
error { target: div.plyr.plyr--full-ui.plyr--video.plyr--html5.plyr--fullscreen-enabled.plyr--paused.plyr--stopped, isTrusted: false, detail: {…}, srcElement: div.plyr.plyr--full-ui.plyr--video.plyr--html5.plyr--fullscreen-enabled.plyr--paused.plyr--stopped, currentTarget: div.viewer__file.viewer__file--active
, eventPhase: 3, bubbles: true, cancelable: false, returnValue: true, defaultPrevented: false, … }
Mime.js:98:11
[DEBUG] viewer: Closing video stream 
Object { app: "viewer", uid: "elliott", filename: "[path]" }
HTTP “Content-Type” of “video/3gpp” is not supported. Load of media resource [url] failed. files
HTTP “Content-Type” of “text/html” is not supported. Load of media resource https://data.osdap.com/index.php/apps/files/blank.mp4 failed.

This is the same exact video that plays successfully on the other server. An interesting point is that the video format is not 3gpp? VLC says it’s “H264 - MPEG-4 AVC (part 10) (avc1).”

I turned on all of the lighttpd logging I could find but don’t see anything helpful preceding the temporary file failure:

2022-09-20 11:35:40: mod_access.c.139) -- mod_access_uri_handler called
2022-09-20 11:35:40: gw_backend.c.2571) handling it in mod_gw
2022-09-20 11:35:40: h2.c.1788) fd:16 id:81 resp: :status: 206
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: x-powered-by: PHP/8.1.9
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: expires: Thu, 19 Nov 1981 08:52:00 GMT
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: cache-control: no-store, no-cache, must-revalidate
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: pragma: no-cache
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: referrer-policy: no-referrer
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: x-content-type-options: nosniff
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: x-frame-options: SAMEORIGIN
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: x-permitted-cross-domain-policies: none
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: x-robots-tag: none
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: x-xss-protection: 1; mode=block
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: content-security-policy: default-src 'none';
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: content-type: video/mp4
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: last-modified: Tue, 05 Jul 2016 22:40:50 GMT
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: etag: "gibberish"
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: content-length: 7735913
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: content-range: bytes 0-7735912/7735913
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: x-request-id: gibberish
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: oc-etag: "gibberish"
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: x-debug-token: gibberish
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: content-disposition: attachment; filename*=UTF-8''[filename]; filename="[filename]"
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: x-accel-buffering: no
2022-09-20 11:35:40: h2.c.1777) fd:16 id:81 resp: strict-transport-security: max-age=63072000; includeSubdomains;
2022-09-20 11:35:40: h2.c.1788) fd:16 id:81 resp: date: Tue, 20 Sep 2022 16:35:40 GMT
2022-09-20 11:35:40: h2.c.1788) fd:16 id:81 resp: server: lighttpd/1.4.59
2022-09-20 11:35:40: chunk.c.891) open failed: /data/tmp/lighttpd-upload-Hw0e3T: No such file or directory
2022-09-20 11:35:40: connections.c.466) connection closed: write failed on fd 16

I can not tell if the failure to write the temporary file is a cause or a symptom of the problem. I confirmed that the web server user is able to write to the temporary directory (it’s reserved just for web services and full of files anyway).

Any ideas?

Thanks!