Piwigo / piwigo-videojs

Videojs port for piwigo. Play your videos on your web gallery!
http://piwigo.org/ext/extension_view.php?eid=610
GNU General Public License v3.0
65 stars 46 forks source link

Debian 8, ffmpeg/avconv issue #64

Open nguiot opened 9 years ago

nguiot commented 9 years ago

Hello,

I've installed all of the following : apt-get install libav-tools mediainfo libfaad2 libx264-142 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx1 libxvidcore4 (Note the libx264-142 instead of libx264-123).

But in the "sync" tab of the plugin, I still have a Warning sign for FFmpeg. I tried to input in the textbox "avconv", "/usr/bin/avconv", I've also tried to "ffmpeg" with a symlink to avconv (ln -s /usr/bin/avconv /usr/bin/ffmpeg), but I still have the Warning sign.

I'm using the git clone plugin (git clone git://github.com/xbgmsharp/piwigo-videojs.git)

What step did I miss ?

xbgmsharp commented 9 years ago

The latest github version is working with Debian Jessie 8.1 Both avconv, /usr/bin/avconv should work. No need to create symlink. Could you ensure your webserver user, eg: www-data has access to the binary?

$ which avconv
/usr/bin/avconv

and

$ ls -lh /usr/bin/avconv
-rwxr-xr-x 1 root root 145K Jun  4 20:43 /usr/bin/avconv
nguiot commented 9 years ago

Everything seems OK :

# cat /etc/debian_version 
8.1
# which avconv 
/usr/bin/avconv
# ls -lah /usr/bin/avconv
-rwxr-xr-x 1 root root 145K Jun  4 21:43 /usr/bin/avconv

Also, I can't sync a video, which looks to be good :

# ls -lh video_test/00012.mp4 
-rw-r--r-- 1 www-data www-data 76M Nov 26  2013 video_test/00012.mp4
# mediainfo  video_test/00012.mp4 
General
Complete name                            : video_test/00012.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom
File size                                : 75.1 MiB
Duration                                 : 1mn 10s
Overall bit rate mode                    : Variable
Overall bit rate                         : 8 904 Kbps
Writing application                      : Lavf53.21.1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4.0
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 2 frames
Format settings, GOP                     : M=2, N=13
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1mn 10s
Bit rate mode                            : Variable
Bit rate                                 : 8 644 Kbps
Maximum bit rate                         : 16.0 Mbps
Width                                    : 1 440 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 50.000 fps
Original frame rate                      : 25.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Interlaced
Scan order                               : Top Field First
Bits/(Pixel*Frame)                       : 0.111
Stream size                              : 72.9 MiB (97%)

Audio
ID                                       : 2
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Mode extension                           : CM (complete main)
Format settings, Endianness              : Big
Codec ID                                 : ac-3
Duration                                 : 1mn 10s
Bit rate mode                            : Constant
Bit rate                                 : 256 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
Compression mode                         : Lossy
Stream size                              : 2.16 MiB (3%)

You can see a screenshot here : maybe both error are related : http://pasteboard.co/2MEsklM5.png

Regards

xbgmsharp commented 9 years ago

If you go on the photo_edit page, do you correctly see the metadata of the video from MediaInfo? https://github.com/xbgmsharp/piwigo-videojs/wiki#photo-edit The tools are detected in file include/function_dependencies.php by running the following command as user www-data:

avconv 1>&2 /dev/null

Is the webserver allow to run the PHP system() and shell_exec() call? Do you have any error on your webserver?

nguiot commented 9 years ago

First, I forgot to tell you : I'm using Nginx (in case it rings a bell...)

Second : I can't see any photo_edit page as shown in the wiki : probably because no video has been detected...

Third : system and exec seem to be OK; I tried the following code (with shell_exec, and system), and it ran fine :

<?php
if(function_exists('exec')) {
    echo "exec is enabled";
} else {
    echo "exec is disabled";
}
?>

Fourth : I'm not sure I understand correctly about the "avconv" command :

www-data@ks1:~$ avconv 1>&2 /dev/null
avconv version 11.4-6:11.4-1~deb8u1, Copyright (c) 2000-2014 the Libav developers
  built on Jun  4 2015 19:39:02 with gcc 4.9.2 (Debian 4.9.2-10)
Unable to find a suitable output format for '/dev/null'
# rgrep -i "ffmpeg" * |grep -i null
plugins/piwigo-videojs/include/function_dependencies.php:        system($sync_options['ffmpeg'] ." 1>&2 /dev/null", $retval); // redirect any output
plugins/piwigo-videojs/admin/admin_sync.php:        system($sync_options['ffmpeg'] ." 1>&2 /dev/null", $retval); // redirect any output

# rgrep -i "avconv" * |grep -i null
# 
xbgmsharp commented 9 years ago

The code is dynamic, ffmpeg is the name of variable, eg: $sync_options['ffmpeg'] It is also webserver independent, it should work on Apache or Ngnix.

You must first add the photo via the normal PWG way, eg: upload and sync. You should have video in the statistics section prior to use the plugin. Please refer to the usage in the wiki: https://github.com/xbgmsharp/piwigo-videojs/wiki/Synchronize#usage The VideoJS sync only generate the thumbnails and poster and sync the atom as metadata.

However it does not solve the warning issue, at least you could check the photo-edit page. Please ensure, you don't have any errors message in your webserver log file.

If you run this code separately what is the output:

system($sync_options['ffmpeg'] ." 1>&2 /dev/null", $retval);
print_r($retval);
nguiot commented 9 years ago

Hello, OK, all is my mistake : I wanted to synchronize in video-js, while I had not synchronized the folder first in piwigo.

Now, I have my video, can play it, and have the metadata in photo-edit : http://pasteboard.co/2O7F9szP.png

However, I still have the warning sign for "avconv". I see no errror message in the web server logs. I tried your code : return code is 126 [Google tells me "Command invoked cannot execute" (Permission problem or command is not an executable)], but I don't understand why...

[error] 1463#0: *4978 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined variable: sync_options in /var/www/html/bla2.php on line 2" while reading response header from upstream,
xbgmsharp commented 9 years ago

$sync_options is undefined. Please retry with the following PHP sample. If you run this code separately what is the output:

system("/usr/bin/avconv 1>&2 /dev/null", $retval);
print_r($retval);
nguiot commented 9 years ago

No error in logs, $retval = 1

xbgmsharp commented 9 years ago

Then it should work. ;) Pease add a debug output on file admin/admin_sync.php on line 125. https://github.com/xbgmsharp/piwigo-videojs/blob/master/admin/admin_sync.php#L125

print_r($sync_options);
nguiot commented 9 years ago

It does work ;) Here the screenshot with the debug option : http://pasteboard.co/2zyTR9z.png

xbgmsharp commented 9 years ago

I believe this is link to the use of FastCGI and Nginx. I am not able to reproduce the error on my system. I am using Apache on Debian Jessie 8. What is surprising is that you only have the warning for avconv and not mediainfo. However the code is the same. If you input avconv or the full path and then save, do you see the warning message: https://github.com/xbgmsharp/piwigo-videojs/blob/master/admin/admin_sync.php#L119

You need to allow you webserver to run the command, maybe using the full path.

lewie commented 8 years ago

Exactly same Problem here! Apache on Debian Jessie 8: Get warnings for avconv/ffmpeg and not mediainfo.

Bash $ ffmpeg -version

ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libpulse --disable-mips32r2 --disable-mipsdspr1 --disable-mipsdspr2 --enable-libvidstab --enable-libzvbi --enable-avresample --disable-htmlpages --disable-podpages --enable-libutvideo --enable-libfdk-aac --enable-libx265 --enable-libiec61883 --enable-vaapi --enable-libdc1394 --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu
libavutil      54. 20.100 / 54. 20.100
libavcodec     56. 26.100 / 56. 26.100
libavformat    56. 25.101 / 56. 25.101
libavdevice    56.  4.100 / 56.  4.100
libavfilter     5. 11.102 /  5. 11.102
libavresample   2.  1.  0 /  2.  1.  0
libswscale      3.  1.101 /  3.  1.101
libswresample   1.  1.100 /  1.  1.100
libpostproc    53.  3.100 / 53.  3.100

Run in php echo shell_exec("ffmpeg 2>&1");

Starting ffmpeg... ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.9.2 (Debian 4.9.2-10) configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libpulse --disable-mips32r2 --disable-mipsdspr1 --disable-mipsdspr2 --enable-libvidstab --enable-libzvbi --enable-avresample --disable-htmlpages --disable-podpages --enable-libutvideo --enable-libfdk-aac --enable-libx265 --enable-libiec61883 --enable-vaapi --enable-libdc1394 --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu libavutil 54. 20.100 / 54. 20.100 libavcodec 56. 26.100 / 56. 26.100 libavformat 56. 25.101 / 56. 25.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 11.102 / 5. 11.102 libavresample 2. 1. 0 / 2. 1. 0 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... Use -h to get full help or, even better, run 'man ffmpeg' Done. 

Output: print_r($sync_options);

Array ( [mediainfo] => mediainfo [ffmpeg] => ffmpeg [metadata] => 1 [poster] => [postersec] => 1 [output] => jpg [posteroverlay] => 1 [posteroverwrite] => 1 [thumb] => [thumbsec] => 25 [thumbsize] => 120x68 [simulate] => 1 [cat_id] => 136 [subcats_included] => 1 ) 
xbgmsharp commented 8 years ago

You have the warning image next to avconv/ffmpeg but not for mediainfo. Please check the return value of function check_ffmpeg($sync_options) What is the retval value from the system command. https://github.com/xbgmsharp/piwigo-videojs/blob/master/admin/admin_sync.php#L103
system($sync_options['ffmpeg'] ." 1>&2 /dev/null", $retval); // redirect any output

lewie commented 8 years ago

Do not know why, but after a second new apache restart, ffmpeg is green and found as mediainfo is. Now, I think this effect was a cache of fast-cgi-php, which wasn't refreshed, sorry. Thank you for your help!

rphlypo commented 8 years ago

Also had an error involving the mediainfo: going into admin.php / plugins / VideoJS, unchecking the option in the tab synchronisation under simulation resolved the issue.

Hope this helps.

alex3137 commented 8 years ago

Same problem here (warning icon in front of avconv).

system($sync_options['ffmpeg'] ." 1>&2 /dev/null", $retval); print_r($retval);

returns "126".

Any thoughts ?

xbgmsharp commented 8 years ago

Thanks for the output. Does everything works even so the error? If a command is found but is not executable, the return status is 126. Do you have Safe Mode enable? http://stackoverflow.com/questions/438618/illegal-command-error-code-127-in-php-exec-function

alex3137 commented 8 years ago

There is no line in my php.ini file to enable safe mode so I imagine it is not enabled.

I solved this issue by upgrading the libav-tools package from the backports repository (I am on Debian Jessie).

xbgmsharp commented 8 years ago

Not sure how it can be link to libav-tools package, but good know. I will add 126 in the allow exit code as it works some how.

# grep -rni safe /etc/php5/apache2/*
/etc/php5/apache2/php.ini:750:; **You CAN safely turn this off for IIS, in fact, you MUST.**
/etc/php5/apache2/php.ini:899:;filter.default = unsafe_raw
/etc/php5/apache2/php.ini:1001:; http://php.net/sql.safe-mode
/etc/php5/apache2/php.ini:1002:sql.safe_mode = Off
/etc/php5/apache2/php.ini:1111:; Default host for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini:1115:; Default user for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini:1119:; Default password for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini:1170:; Default host for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini:1174:; Default user for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini:1178:; Default password for mysqli_connect() (doesn't apply in safe mode).
alex3137 commented 8 years ago

Looks like safe mode is disabled:

/etc/php5/apache2/php.ini:750:; **You CAN safely turn this off for IIS, in fact, you MUST.**
/etc/php5/apache2/php.ini:899:;filter.default = unsafe_raw
/etc/php5/apache2/php.ini:1000:; http://php.net/sql.safe-mode
/etc/php5/apache2/php.ini:1001:sql.safe_mode = Off
/etc/php5/apache2/php.ini:1110:; Default host for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini:1114:; Default user for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini:1118:; Default password for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini:1169:; Default host for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini:1173:; Default user for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini:1177:; Default password for mysqli_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini.ucf-dist:750:; **You CAN safely turn this off for IIS, in fact, you MUST.**
/etc/php5/apache2/php.ini.ucf-dist:899:;filter.default = unsafe_raw
/etc/php5/apache2/php.ini.ucf-dist:1001:; http://php.net/sql.safe-mode
/etc/php5/apache2/php.ini.ucf-dist:1002:sql.safe_mode = Off
/etc/php5/apache2/php.ini.ucf-dist:1111:; Default host for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini.ucf-dist:1115:; Default user for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini.ucf-dist:1119:; Default password for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini.ucf-dist:1170:; Default host for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini.ucf-dist:1174:; Default user for mysql_connect() (doesn't apply in safe mode).
/etc/php5/apache2/php.ini.ucf-dist:1178:; Default password for mysqli_connect() (doesn't apply in safe mode).

And now system($sync_options['ffmpeg'] ." 1>&2 /dev/null", $retval); print_r($retval);

returns "1"