HEIC/MOV previews

Hello All,

i recently cleared the cache on my Nextcloud iOS app and realized that the previews are not being regenerated because they are HEIC pics or MOV videos.

The previews will only come on only when accessing the picture, not the mov video.

is there a way to generate previews like with JPEG/MP4?

im running Nextcloud on Ubuntu server 18.04.

Thanks in advance for your help/assistance.

Regards!

3 Likes

It is probably because of missing support in ffmpeg or Imagemagick. Check that.

i just installed both, restarted apache and nothing so far.

unless im missing something else on those 2.

Regards!

Safari works normally for MOV videos, but not preview HEIF.

Opera works only when downloading a plugin for MOV, but will not preview HEIF

Chrome does not play completely MOV files, will not preview HEIF files

Regards!

If you’ve installed the Preview Generator app you should be able to pre-generate new previews.

i do have the Preview Generator App and if im not mistaken, ive got a cron job to run it every 15 mins (need to confirm what is running).

Unless the cron job is not running the preview generator and is running something else.

so, these are the cron jobs running on my Nextcloud (taken from webmin) and they are running every 15 mins.

php -f /var/www/html/nextcloud/cron.php
php -f /var/www/html/nextcloud/occ preview:pre-generate

this is what the cron.php looks like for me:

require_once DIR . ‘/lib/versioncheck.php’;

try {

require_once __DIR__ . '/lib/base.php';

if (\OCP\Util::needUpgrade()) {
	\OC::$server->getLogger()->debug('Update required, skipping cron', ['app' => 'cron']);
	exit;
}
if ((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) {
	\OC::$server->getLogger()->debug('We are in maintenance mode, skipping cron', ['app' => 'cron']);
	exit;
}

// load all apps to get all api routes properly setup
OC_App::loadApps();

\OC::$server->getSession()->close();

// initialize a dummy memory session
$session = new \OC\Session\Memory('');
$cryptoWrapper = \OC::$server->getSessionCryptoWrapper();
$session = $cryptoWrapper->wrapSession($session);
\OC::$server->setSession($session);

$logger = \OC::$server->getLogger();
$config = \OC::$server->getConfig();

// Don't do anything if Nextcloud has not been installed
if (!$config->getSystemValue('installed', false)) {
	exit(0);
}

\OC::$server->getTempManager()->cleanOld();

// Exit if background jobs are disabled!
$appMode = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax');
if ($appMode === 'none') {
	if (OC::$CLI) {
		echo 'Background Jobs are disabled!' . PHP_EOL;
	} else {
		OC_JSON::error(array('data' => array('message' => 'Background jobs disabled!')));
	}
	exit(1);
}

if (OC::$CLI) {
	// set to run indefinitely if needed
	if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
		@set_time_limit(0);
	}

	// the cron job must be executed with the right user
	if (!function_exists('posix_getuid')) {
		echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL;
		exit(1);
	}
	$user = posix_getpwuid(posix_getuid());
	$configUser = posix_getpwuid(fileowner(OC::$configDir . 'config.php'));
	if ($user['name'] !== $configUser['name']) {
		echo "Console has to be executed with the same user as the web server is operated" . PHP_EOL;
		echo "Current user: " . $user['name'] . PHP_EOL;
		echo "Web server user: " . $configUser['name'] . PHP_EOL;
		exit(1);
	}

	// We call Nextcloud from the CLI (aka cron)
	if ($appMode !== 'cron') {
		$config->setAppValue('core', 'backgroundjobs_mode', 'cron');
	}

	// Work
	$jobList = \OC::$server->getJobList();

	// We only ask for jobs for 14 minutes, because after 15 minutes the next
	// system cron task should spawn.
	$endTime = time() + 14 * 60;

	$executedJobs = [];
	while ($job = $jobList->getNext()) {
		if (isset($executedJobs[$job->getId()])) {
			$jobList->unlockJob($job);
			break;
		}

		$job->execute($jobList, $logger);
		// clean up after unclean jobs
		\OC_Util::tearDownFS();

		$jobList->setLastJob($job);
		$executedJobs[$job->getId()] = true;
		unset($job);

		if (time() > $endTime) {
			break;
		}
	}

} else {
	// We call cron.php from some website
	if ($appMode === 'cron') {
		// Cron is cron :-P
		OC_JSON::error(array('data' => array('message' => 'Backgroundjobs are using system cron!')));
	} else {
		// Work and success :-)
		$jobList = \OC::$server->getJobList();
		$job = $jobList->getNext();
		if ($job != null) {
			$job->execute($jobList, $logger);
			$jobList->setLastJob($job);
		}
		OC_JSON::success();
	}
}

// Log the successful cron execution
$config->setAppValue('core', 'lastcron', time());
exit();

} catch (Exception $ex) {
\OC::$server->getLogger()->logException($ex, [‘app’ => ‘cron’]);
} catch (Error $ex) {
\OC::$server->getLogger()->logException($ex, [‘app’ => ‘cron’]);
}

thanks!

i also ran the command php -u www-data /var/www/nextcloud/occ preview:generate-all and the heic pictures taken from today didnt get the preview generated.

How are your preview settings in the config.php file look like? Have you explicitly set the “enabledPreviewProviders” parameter or are you using the default settings, like:

'enabledPreviewProviders' => array(
    'OC\Preview\PNG',
    'OC\Preview\JPEG',
    'OC\Preview\GIF',
    'OC\Preview\HEIC',
    'OC\Preview\BMP',
    'OC\Preview\XBitmap',
    'OC\Preview\MP3',
    'OC\Preview\TXT',
    'OC\Preview\MarkDown'
),

Could you find any related message in your Nextcloud log file if you run a scan command (make sure that “'loglevel' => 0,” is set)?

BTW, you can most likely speed-up your tests if you place some HEIC files in a dedicated directory and use the preview:generate --path=<path-to-dedicated-dir>" command as documented in the command help.

1 Like

after adding the enable_previews and the providers, i went ahead and checked the log and found this:

Memcache \OC\Memcache\APCu not available for local cache
Memcache \OC\Memcache\APCu not available for distributed cache

Regards!

i got those errors removed by executing the following command:

echo ‘apc.enable_cli=1’ >> /etc/php/7.2/mods-available/apcu.ini
sudo service apache2 restart

then i ran sudo -u www-data php -f /var/www/htm/nextcloud/occ preview:generate-all --path=path-to-heicphotos

no errors on the log so far, but still no previews of the HEIC photos on the gallery app via web.

1 Like

Nextcloud relies on the imagick program command line program to convert images. If this program supports the HEIC format, Nextcloud should also be able to create the preview files.

See how it could be enabled:

Afaik, the following command can be used to check if the HEIC format is supported:

# php -r 'phpinfo();' | grep HEIC

The imagick support can be checked by executing this command:

 convert --version
4 Likes

OMG, after following the link provided, i was able to get my Nextcloud to preview the HEIC files on the web browser!

Kudos to you sir for the amazing advise/help. :smiley:

Thanks a lot!!

2 Likes

Hi,

did not want to open another thread, hope its ok to post here.

I have nc 17.0.1 and imagemagic 7.x. I can see HEIC preview and when I right click and select details, I can see a picture on the right hand corner.

However, if I click on the name of the picture, or the small thumbnail of the HEIC itself, the browser attempts to download the image. If I do the same to an jpg or png file, the image opens nice and big and I can view it in browser. How can I have the same behaviour for the HEIC file as I get with a jpg or png file?

Thanks.

That happened to me as well and it got fixed after restarting the browser

I have setup the HEIC compatibility a few month ago already and have used various browsers on many different devices and platforms, and the behavior is the same.

Any other ideas?

I just replicated your issue.

This is what I did, if you open the “files/fotos and try to open an picture, web browser will download the picture.

If you go to the gallery and click on the picture, the browser will show it on it.

Displaying HEIC pictures seem not to be fully supported yet. See https://github.com/nextcloud/viewer/issues/4

@Dridhas
I have exactly the same behaviour. When I work with the pictures, its easier to do with the file view and not the gallery. Problem is, I like to preview the picture before I delete or download it. With JPEG and other older formats, its no problem, just HEIC.

@j-ed
Thank you. I hope this will be implemented soon. It seems like the preview is working in gallery view, it just needs to be “ported” to the file view. But I don’t know the inner workings of nextcloud …

Thanks to all!

you probably need to get the Preview Generator app and have a cron job run every so often to get the previews generated.

Also, this article will get imagick to work with HEIC/HEIF photos.

https://medium.com/@eplt/5-minutes-to-install-imagemagick-with-heic-support-on-ubuntu-18-04-digitalocean-fe2d09dcef1

now gallery and files show a small preview.

1 Like