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!