Skip to content

Using MediaInfo, ffmpeg without installing it inside the hosting system

Aliberk Sandıkçı edited this page Jul 12, 2024 · 15 revisions

Using MediaInfo, ffmpeg without installing it inside the hosting system

VideoJS in the automatic mode require FFMPEG and MediaInfo to be install. The reason is simple, there is no PHP library to manipulate H264 video file.

The command used to generate are on the wiki

Now if you want to use automatic mode, here are a few question to guide you in the process.

Do you have root access? If so install the program as describe in the wiki

If not, Which distribution?

Debian/CentOs, eg: lsb_release -a

Which architecture? 32/64, eg: uname -a

Then you can read below to give you though the manual install. It is for advanced Linux users.

I assume you have a x86_64 system. You can check by running the uname command

# uname -a
Linux debian-dev 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux

How to "install" mediainfo:

I created zip by extracting the rpm from the CentOS6 version of MediaInfo and uploaded in the GitHub Wiki. https://github.com/xbgmsharp/piwigo-videojs/wiki/mediainfo-0.7.67.zip

# zip -r mediainfo-0.7.67.zip usr/*
  adding: usr/bin/ (stored 0%)
  adding: usr/bin/mediainfo (deflated 65%)
  adding: usr/lib64/ (stored 0%)
  adding: usr/lib64/libzen.so.0 (deflated 61%)
  adding: usr/lib64/libmediainfo.so.0.0.0 (deflated 59%)
  adding: usr/lib64/libzen.so.0.0.0 (deflated 61%)
  adding: usr/lib64/libmediainfo.so.0 (deflated 59%)
  adding: usr/share/ (stored 0%)
  adding: usr/share/doc/ (stored 0%)
  adding: usr/share/doc/libmediainfo0-0.7.67/ (stored 0%)
  adding: usr/share/doc/libmediainfo0-0.7.67/ReadMe.txt (deflated 51%)
  adding: usr/share/doc/libmediainfo0-0.7.67/License.html (deflated 56%)
  adding: usr/share/doc/libmediainfo0-0.7.67/History.txt (deflated 66%)
  adding: usr/share/doc/mediainfo-0.7.67/ (stored 0%)
  adding: usr/share/doc/mediainfo-0.7.67/History_CLI.txt (deflated 66%)
  adding: usr/share/doc/mediainfo-0.7.67/ReadMe_CLI_Linux.txt (deflated 40%)
  adding: usr/share/doc/mediainfo-0.7.67/License.html (deflated 55%)
  adding: usr/share/doc/libzen0-0.4.29/ (stored 0%)
  adding: usr/share/doc/libzen0-0.4.29/ReadMe.txt (deflated 21%)
  adding: usr/share/doc/libzen0-0.4.29/History.txt (deflated 62%)
  adding: usr/share/doc/libzen0-0.4.29/License.txt (deflated 46%)

To extract it run unzip command or upload all file to your server.

# unzip mediainfo-0.7.67.zip

You need after to ensure have all dependencies using the ldd command.

# ldd usr/bin/mediainfo
        linux-vdso.so.1 =>  (0x00007fffe29ff000)
        libmediainfo.so.0 => /usr/lib/libmediainfo.so.0 (0x00007f4777b0c000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f47778f5000)
        libzen.so.0 => /usr/lib/libzen.so.0 (0x00007f47776b1000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4777495000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f477718e000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4776f0b000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f4776cf5000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f477696b000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f47781d8000)
# ldd usr/lib64/libzen.so.0
        linux-vdso.so.1 =>  (0x00007fff2cfcf000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fed5af77000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fed5ac70000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fed5a9ed000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fed5a663000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fed5a44d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fed5b3de000)
# ldd usr/lib64/libmediainfo.so.0
        linux-vdso.so.1 =>  (0x00007fff735ff000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0cd032f000)
        libzen.so.0 => /usr/lib/libzen.so.0 (0x00007f0cd00ec000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0ccfecf000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0ccfbc8000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0ccf946000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0ccf5bb000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0ccf3a5000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f0cd0c0c000)

If you're using bash, you could invoke mediainfo this way using:

LD_LIBRARY_PATH="$HOME/usr/lib64:$LD_LIBRARY_PATH"  $HOME/usr/bin/mediainfo

If it works on shell, then you can modify the '(piwigo-installation-directory)/plugins/piwigo-videojs/admin/admin_photo.php' file. https://github.com/xbgmsharp/piwigo-videojs/blob/master/admin/admin_photo.php#L64

How to get ffmpeg running:

Note: In order to generate posters/thumbnails, it is actually ffmpeg which is required. If you do not have mediainfo running, that is fine, it is not really needed for generating the thumbnails of the videos.

If your hosting provider will let you install it, you can do it like this:

# ldd /usr/bin/ffmpeg | wc -l
77

If you this this message:

Warning: system() has been disabled for security reasons in .../piwigo/plugins/piwigo-videojs/admin/admin_sync.php on line 87

Warning: system() has been disabled for security reasons in .../piwigo/plugins/piwigo-videojs/admin/admin_sync.php on line 103

Warning: system() has been disabled for security reasons in .../piwigo/plugins/piwigo-videojs/include/function_dependencies.php on line 50

Then you have no other choice to do a manual sync. This mean you need to create the poster yourself and upload then in the pwg_representative of the album. Then do a PWG sync and you will be able to play your video.

If your hosting provider will not let you install ffmpeg

In that case, you can use a "static build" as a workaround. Download a static build from here: https://johnvansickle.com/ffmpeg/

  1. Copy the tar file to your file system on the hosting server.
  2. Extract it. You may have to extract it twice to get the folder structure.
  3. Note the path where the executable is. For example in my system it looks like this:

/home/my_name/app/ffmpeg/ffmpeg-5.0-amd64-static/ffmpeg

(note that you do need the executable at the end)

You will need to enter this in two places:

  1. in the admin_photo.php file mentioned above
  2. In the configuration page of the plugin That is needed in case you want to run it manually.

How to test run ffmpeg:

You can test ffmpeg manually on a terminal session. This is an example, your own paths need to be used instead of my paths:

/home/username/app/ffmpeg/ffmpeg-5.0-amd64-static/ffmpeg -ss 4 -i "/home/username/public_html/piwigo/upload/2022/03/23/video1.m4v" -vcodec mjpeg -vframes 1 -an -f rawvideo -y "/home/username/public_html/piwigo/upload/2022/03/23/pwg_representative/video1.jpg"

Troubleshooting tips:

If you are getting this error message...

Failed to configure output pad on auto_scale_0

...add this to the end of your ffmpeg command line

-threads 1

For example:

/home/username/app/ffmpeg/ffmpeg-5.0-amd64-static/ffmpeg -threads 1 -ss 4 -i "/home/username/public_html/piwigo/upload/2022/03/23/video1.m4v" -vcodec mjpeg -vframes 1 -an -f rawvideo -y "/home/username/public_html/piwigo/upload/2022/03/23/pwg_representative/video1.jpg"

Good luck!