When I use your module to make a transcoding I have an issue:
"Warning: preg_match() expects parameter 2 to be string, object given in FFMpeg\FFProbe\OptionsTester->has() (line 44 of vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\FFProbe\OptionsTester.php)."
This issue because the vendor has used "preg_match('/^'.$name.'/m', $output);" with $output is not a string.
Please help me resolve this issue.
I used your service in the IBM Watson module. https://www.drupal.org/node/2849173

Comments

trangunghoa created an issue. See original summary.

trangunghoa’s picture

Issue summary: View changes
pbuyle’s picture

Can you provide the full stack trace for the error?

robin.ingelbrecht’s picture

StatusFileSize
new137.36 KB

I have the same issue. This is the full stack trace:
Stacktrace

ultimike’s picture

StatusFileSize
new455 bytes

This is actually a bigger deal than it seems, as it can lead to ffprobe and ffmpeg not being loaded in certain circumstances.

I believe the issue is that this module provides a cache for the phpffmpeg library, but data being returned to ffmpeg needs to be a string, while Drupal's cache normally returns and object.

The attached patch fixed the issue for me.

-mike

berdir’s picture

Version: 8.x-1.0 » 8.x-1.x-dev
Status: Active » Needs work
+++ b/src/PHPFFMpegCache.php
@@ -41,7 +41,9 @@ class PHPFFMpegCache implements Cache {
   public function fetch($id) {
-    return $this->cache->get($this->getCid($id));
+    $return = $this->cache->get($this->getCid($id));
+    if (is_object($return)) return $return->data;
+    return $return;
   }

cache->get() either returns an object or nothing, there is no reason to ever return $return. The common pattern for this would be something like this:

if ($cache = $this->cache->get($this->getCid($id)) {
return $cache->data;
}

primsi’s picture

Status: Needs work » Needs review
StatusFileSize
new443 bytes

Updated the patch. I still left the return FALSE fallback because \Doctrine\Common\Cache\Cache seems to define it.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Yes, keeping that makes sense.

introfini’s picture

Applying the patch #11 fixes this crash. Thanks!

Fatal error: Uncaught Error: Call to undefined method stdClass::has() in /app/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Format/ProgressListener/AbstractProgressListener.php on line 254 ...

mhavelant’s picture

Status: Reviewed & tested by the community » Fixed

  • mhavelant committed efecf1f on 8.x-1.x authored by Primsi
    Issue #2851222 by Primsi, ultimike, robin.ingelbrecht, trangunghoa,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.