V8-archive: ffprobe.exe (XAMPP & Windows) seems to be not executed properly

Created on 3 Sep 2019  ยท  5Comments  ยท  Source: directus/v8-archive

Bug Report

When uploading files of type video/mp4, fprobe (see Files.php#L299) seems to not extrude width/height and metadata from the file, resulting in empty fields (width/height) inside the CMS.

Steps to Reproduce

  1. Install XAMPP on Windows 10 (Version 10.0.17134 Build 17134)
  2. Clone Directus via git, setup up a virtual host on the Apache config:
<VirtualHost *:80>
    DocumentRoot "path/to/directus/public/"
    ServerName api 
    <Directory "/">
      Options Indexes FollowSymLinks Includes ExecCGI
     AllowOverride All
      Order allow,deny
     Allow from all
     Require all granted
    </Directory>
</VirtualHost>
  1. Set post_max_size=200M and upload_max_filesize=200M in php.ini
  2. Try to upload a video
  3. width/height are empty

Expected Behavior

ffprobe should extract meta data (width/height) of the video.

Actual Behavior

width/height are empty

Other Context & Screenshots

I was able to fix it by downloading ffmpeg from here: https://ffmpeg.zeranoe.com/builds/, put it into E:\\XAMPP\\ffmpeg\\ffprobe.exe and replace the code in Files.php with:

        # Updates for file meta data tags
        $script = "E:\\XAMPP\\ffmpeg\\ffprobe.exe";
        if (strpos($fileData['type'],'video') !== false) {
            #use ffprobe on local file, can't stream data to it or reference
            $output = shell_exec("{$script} {$tmp} -show_entries format=duration:stream=height,width -v quiet -of json");
            #echo($output);
            $media = json_decode($output);
            $width = $media->streams[0]->width;
            $height = $media->streams[0]->height;
            $duration = $media->format->duration;   #seconds

        } elseif (strpos($fileData['type'],'audio') !== false) {
            $output = shell_exec("{$script} {$tmp} -show_entries format=duration -v quiet -of json");
            $media = json_decode($output);
            $duration = $media->format->duration;
        }

Maybe I did just setup my XAMPP/ffmpeg wrong?

Technical Details

  • Device: [
  • OS: Windows 10 (Version 10.0.17134 Build 17134)
  • Web Server: Apache/2.4.39 (Win64) OpenSSL/1.1.1c PHP/7.3.8 (XAMPP)
  • PHP Version: PHP Version 7.3.8
  • Database: MariaDB, 10.4.6
  • Install Method: git clone from the master branch
needs more info

Most helpful comment

Hey @bjgajjar, thanks for the reminder.
Just tested it with a fresh git clone of the directus suite and proper Path variable that contains ffmpeg: works right out of the box ๐Ÿ‘ โค๏ธ

btw. we've been using Directus at the IAA in Frankfurt last week as a content management for a realtime newsfeed system and really liked it, keep up the good work ๐Ÿ’ช

All 5 comments

@guidoschmidt - You don't need to pass the hardcoded path for ffprobe.exe. Just set it into your environment variables. You can check here for more details.

Hey @bjgajjar thanks for the hint. Actually that was what I was trying. But now as I think about it, I only added it to PATH (User variables) but maybe I should have added it to Path (System variables). I'll give it a try ๐Ÿ™‚

@guidoschmidt - May I have an update for this?

Hey @bjgajjar, thanks for the reminder.
Just tested it with a fresh git clone of the directus suite and proper Path variable that contains ffmpeg: works right out of the box ๐Ÿ‘ โค๏ธ

btw. we've been using Directus at the IAA in Frankfurt last week as a content management for a realtime newsfeed system and really liked it, keep up the good work ๐Ÿ’ช

Hey @guidoschmidt โ€” glad things are working for you now. Also, as the project lead for Directus, I'm always interested in learning more about how devs are using OSS Directus. Since we don't track any info, we don't know all the cool projects Directs is used in! Feel free to hit me up on Slack, I'd love to do a small case-study post on how IAA is using Directus. ๐Ÿ˜„

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cdwmhcc picture cdwmhcc  ยท  3Comments

metalmarco picture metalmarco  ยท  3Comments

Varulv1997 picture Varulv1997  ยท  3Comments

cdwmhcc picture cdwmhcc  ยท  3Comments

rijkvanzanten picture rijkvanzanten  ยท  3Comments