CopyDisable

Saturday, 19 May 2012

Installing ViMP Video CMS

ViMP provide a very good installation guide. I am documenting some points that may be helpful for running ViMP successfully.
I used Ubuntu 12.04 and  ViMP Community 2.5.4 version in this example.
I am assuming Apache, PHP and MySQL are already installed in the system otherwise it can be installed easily using apt-get. For the hardware and software requirements of ViMP, please see the Installation guide of ViMP.
Install gcc compiler
$ sudo apt-get install gcc
If make is not installed, install make
$ sudo apt-get install make

I will install the required PHP extensions:
$ sudo apt-get install php5-gd
$ sudo apt-get install php5-curl
$ sudo apt-get install php5-xsl
Also we need to install SourceGuardian module for PHP.
Check the PHP extensions directory
$ php -i | grep extension_dir extension_dir => /usr/lib/php5/20090626+lfs => /usr/lib/php5/20090626+lfs
My PHP extensions directory is /usr/lib/php5/20090626+lfs , go to this directory
$ cd /usr/lib/php5/20090626+lfs
Download the PHPShield loader into PHP extensions directory.
pranabs@ubuntu:/usr/lib/php5/20090626+lfs$ sudo wget http://downloads.phpmotion.com/phpshield-loaders/linux/i386/ixed.5.3
We have to add this new extension to PHP configuration file
$ cd /etc/php5/conf.d/
Create a new file ixed.5.3.ini
$ sudo pico ixed.5.3.ini
Add the line extension=ixed.5.3 to the new file and save it.

Enable apache mod_rewrite:
$ sudo a2enmod rewrite

Restart Apache.
$ sudo service apache2 restart

Install Ruby
$ sudo apt-get install ruby

Now we have to install the tools required for video encoding. ViMP document describes for debian installation. For Ubuntu we can get the required tools and codec from Medibuntu repository. You can find document for Medibuntu in the link https://help.ubuntu.com/community/Medibuntu .

Add Medibuntu repository:
$ sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update
Install the transcoding tools
$ sudo apt-get install mplayer mencoder ffmpeg flvtool2

Install the codec package:
$ sudo apt-get install w32codecs
Note: I am installing it for 32bit system, for 64bit it is w64codecs

Pre-requisite installation part is complete now, for configuration and installation of ViMP you can refer to ViMP installation manual.


Troubleshooting:

Even after installing the required tools I got the following error in the transcoding process
>> transcode media 5687762ac90946a84dfb015a19d677bc [1]
>> transcode    + move 5112de7fe0d8b45d87fa5...2d9e899bb28fb1c7348ad79a042.flv
>> rename    /var/www/mediaserver/data/web/u...4dfb015a19d677bc_1336642858.flv
>> chmod 775 /var/www/mediaserver/data/web/i...4dfb015a19d677bc_1336642858.flv
>> chown www-data.www-data /var/www/mediaserver/dat...a19d677bc_1336642858.flv
>> exec      "mplayer" -vo null -ao null -fr...87762ac90946a84dfb015a19d677bc"
>> exec      cat /tmp/info_output_5687762ac9...a19d677bc | grep ID_VIDEO_WIDTH
>> exec      cat /tmp/info_output_5687762ac9...19d677bc | grep ID_VIDEO_HEIGHT
>> exec      cat /tmp/info_output_5687762ac9...fb015a19d677bc | grep ID_LENGTH
>> file-     /tmp/info_output_5687762ac90946a84dfb015a19d677bc
>> file+     /var/www/mediaserver/data/web/i...4dfb015a19d677bc_1336642858.flv
>> chmod 775 /var/www/mediaserver/data/web/i...4dfb015a19d677bc_1336642858.flv
>> chown www-data.www-data /var/www/mediaserver/dat...a19d677bc_1336642858.flv
>> exec      nice -n 19 "ffmpeg" -i /var/www...4dfb015a19d677bc_1336642858.m4v
>> transcode    + Problem executing command. (error 1)
For transcoding errors we can view the framework.convert.log file located inside the log folder in ViMP application’s data  directory.

After lots of trial and failure, I have decided to remove ffmpeg and compile it from latest source

$ sudo git clone git://source.ffmpeg.org/ffmpeg
$ cd ffmpeg

$ sudo ./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab

The configure script may give some dependent library error (if it is already not present), these libraries can be installed easily using apt-get install command. Run apt-cache search command to find the exact library name and then install it.  
$ sudo make
$ sudo make install

Manually compiling ffmpeg may install it in /usr/local/bin/ffmpeg, so create a symbolic link /usr/bin/ffmpeg pointing to /usr/local/bin/ffmpeg

I tried transcoding again, but got the same error. After some searching I found the solution in ViMP support forum http://www.vimp.com/143/topic/929.html?page=1
I have to copy the ffmpeg-presets which can be downloaded from  http://www.vimp.com/en/download-configurations.html
Download and extract the ffmpeg.presets.tar.gz file. Put all the extracted files into /usr/local/share/ffmpeg directory (I have compiled ffmpeg, so I have this folder otherwise it is /usr/share/ffmpeg)
It didn’t resolve my problem, so another solution was provided in  http://www.vimp.com/143/topic/929.html?page=2
Open the /usr/local/share/ffmpeg/libx264-slow.ffpreset file and delete the following lines:
directpred=3
flags2=+bpyramid+mixed_refs+wpred+dct8x8+fastpskip
wpredp=2


Note: It is better to copy the presets in the ffmpeg's source (including the modified libx264-slow.ffpreset file) and recompile ffmpeg again.


After that I recompiled ffmpeg and this error was gone but I started getting another error.

>> chmod 775 /var/www/mediaserver/data/web/i...380eebfd1c44f67_1336646839.webm
>> chown www-data.www-data /var/www/mediaserver/dat...d1c44f67_1336646839.webm
>> exec      "flvtool2" -UP "/var/www/medias...033b6005d51c6f4380eebfd1c44f67"
>> exec      cat /tmp/duration_output_13033b...380eebfd1c44f67 | grep duration
>> transcode    + Problem executing command. (error 1)



I checked the duration_output_13033b… file mentioned in the error log. The content of the file was as follows:

root@ubuntu:~/flvtool2-1.0.6# cat /tmp/duration_output_13033b6005d51c6f4380eebfd1c44f67 ERROR: EOFError
ERROR: /usr/local/lib/site_ruby/1.8/flv/amf_string_buffer.rb:37:in `read'
ERROR: /usr/local/lib/site_ruby/1.8/flv/video_tag.rb:80:in `read_header'
ERROR: /usr/local/lib/site_ruby/1.8/flv/video_tag.rb:47:in `after_initialize'
ERROR: /usr/local/lib/site_ruby/1.8/flv/tag.rb:56:in `initialize'
ERROR: /usr/local/lib/site_ruby/1.8/flv/stream.rb:449:in `new'
ERROR: /usr/local/lib/site_ruby/1.8/flv/stream.rb:449:in `read_tags'
ERROR: /usr/local/lib/site_ruby/1.8/flv/stream.rb:58:in `initialize'
ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:272:in `new'
ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:272:in `open_stream'
ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:238:in `process_files'
ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:225:in `each'
ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:225:in `process_files'
ERROR: /usr/local/lib/site_ruby/1.8/flvtool2/base.rb:44:in `execute!'
ERROR: /usr/local/lib/site_ruby/1.8/flvtool2.rb:168:in `execute!'
ERROR: /usr/local/lib/site_ruby/1.8/flvtool2.rb:228
ERROR: /usr/bin/flvtool2:2:in `require'
ERROR: /usr/bin/flvtool2:2



After lots of searching I found the solution in the forum:

http://www.wowza.com/forums/showthread.php?467-Modifying-flvtool2-to-work-with-flv-files-recorded-using-Wowza-Pro-(fix)



I changed the audio_tag.rb file:


from:

         def after_initialize(new_object)
         @tag_type = AUDIO
         read_header
         end
to:

         def after_initialize(new_object)
         @tag_type = AUDIO
         if data_size > 0
             read_header
         end
         end




and changed the video_tag.rb file

from:
     

   bit_sequence = data_stream.read(9).unpack('B72').to_s

to:


    if @codec_id == H263VIDEOPACKET || @codec_id == SCREENVIDEOPACKET
           bit_sequence = data_stream.read(9).unpack('B72').to_s
     end




These two files located in prefix/site_ruby/1.8/flv folder (prefix will change depending on your installation), in my case it is in /usr/local/lib/site_ruby/1.8/flv folder.

It worked for me without reinstalling flvtool2.



If it doesn’t work, you may have to download flvtool2 from http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz , change the audio_tag.rb and video_tag.rb files, rebuild and install it again.

e.g.

$ wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz

$ tar xzvf flvtool2-1.0.6.tgz

$ cd flvtool2-1.0.6/lib/flv

Edit audio_tag.rb and video_tag.rb files

$ cd ../..

$ sudo ruby setup.rb config

$ sudo ruby setup.rb setup

$ sudo ruby setup.rb install



That’s it and enjoy ViMP.

Tuesday, 8 May 2012

Installing PHPMotion Media Sharing CMS

PHPMotion is a video sharing application and it also has functionalities for sharing images and music.
In this document I will install PHPMotion in an Ubuntu Linux server. The version of Ubuntu I used in 12.04 and it is 32bit.
While installing Ubuntu I installed the LAMP so that I already have the required Apache, PHP and MySQL. It can also be installed easily using apt-get.
The PHP version I used is 5.3.
Check the modules installed with PHP using the command
$ php –m
This command will list the PHP modules already installed. From this command I found that the GD Library is missing. To install GD library use the command:
$ sudo apt-get install php5-gd
 
Note: If you are at root user shell, just run the commands without sudo. Also in this doc I used pico editor to edit files, you can use any editor you like.
 
Also we need PHP curl library
$ sudo apt-get install php5-curl
Restart Apache after the installation
$ sudo service apache2 restart
To check details of PHP we can use the following script
$ sudo pico /var/www/info.php
 
image
Save the script in default apache root directory .i.e /var/www and open in a web-browser.
 
image
 
Next we have to install LAME mp3 encoder.
$ sudo apt-get install lame
 
Next we have to install Libogg and Libvorbis. First we have to install Libogg otherwise if we first try to install Libvorbis we will get error.
Also we need C compiler installed, otherwise we will get configure: error: no acceptable C compiler found in $PATH error while we try to compile Libogg and Libvorbis.
I am going to install the GCC compiler as do not have any C compiler installed in my computer.
$ sudo apt-get install gcc
If make is not installed, install make
$ sudo apt-get install make
 
Download Libogg
$ wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
Extract the downloaded file
$ tar xzvf libogg-1.3.0.tar.gz
Now we are going to compile the libogg, go to the libogg-1.3.0 directory
$ cd libogg-1.3.0
$ sudo ./configure
$ sudo make
$ sudo make install
 
Download Libvorbis and compile it
$ wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
$ tar xzvf libvorbis-1.3.3.tar.gz
$ cd libvorbis-1.3.3
$ sudo ./configure
$ sudo make
$ sudo make install

 
Install Mencoder and also Mplayer
$ sudo apt-get install mencoder
 
Install FFMpeg
$ sudo apt-get install ffmpeg
 
Install Flvtool2
$ sudo apt-get install flvtool2
 
Open PHP configuration file /etc/php5/apache2/php.ini and set the following:
open_basedir =
upload_max_filesize = 100M 
post_max_size = 100M
(Note: PHPMotion suggests above two parameters value as 100M, but it depends on your need. If you want to upload files larger than 100M set it accordingly)
max_execution_time = 1500
session.gc_maxlifetime = 14000
safe_mode = Off
enable_dl = On
 
Restart apache to load the changes.
$ sudo service apache2 restart
 
Download PHPMotion 3.5 version and extract it.
$ unzip phpmotion.zip
 
Copy Phpmotion to the Apache web server. In this example, I will deploy PHPMotion to the default root folder of Apache.
$ sudo cp -rf * /var/www/
 
We have to change the permission of the cgi-bin folder of phpmotion application to 755
$ cd /var/www
$ sudo chmod -R 755 ./cgi-bin
 
Now we could start the setup of PHPMotion.
Open the URL for PHPMotion and click on Continue button
image
 
In the second step PHPMotion checks for required components. Oopssss…… error for PHPShield.
 
image
 
To resolve this issue go to the Instruction manual http://wiki.phpmotion.com/PHPShield53
Check the PHP extensions directory
pranabs@ubuntu:/var/www$ php -i | grep extension_dir
extension_dir => /usr/lib/php5/20090626+lfs => /usr/lib/php5/20090626+lfs

My PHP extensions directory is /usr/lib/php5/20090626+lfs , go to this directory
$ cd /usr/lib/php5/20090626+lfs
 
Check is there any phpshield loader
 
pranabs@ubuntu:/usr/lib/php5/20090626+lfs$ ls
curl.so  gd.so  mysqli.so  mysql.so  pdo_mysql.so  pdo.so

 
Download the PHPShield loader from the link provided in http://wiki.phpmotion.com/PHPShield53
 
pranabs@ubuntu:/usr/lib/php5/20090626+lfs$ sudo wget http://downloads.phpmotion.com/phpshield-loaders/linux/i386/ixed.5.3
 
Now we have to add this new extension to PHP configuration file
$ cd /etc/php5/conf.d/
Create a new file ixed.5.3.ini
$ sudo pico ixed.5.3.ini
 
Add the line extension=ixed.5.3 to the new file and save it.
image
 
Restart Apache.
$ sudo service apache2 restart
 
Now go to the PHPMotion setup and refresh the page.
 
image
 
Now everything looks OK and we can continue the setup. Click on Continue button.

OMG… again some error. Its very simple just have to change permissions for some folders in PHPMotion.

image

pranabs@ubuntu:/var/www$ cd /var/www
pranabs@ubuntu:/var/www$ sudo chmod -R 777 addons
pranabs@ubuntu:/var/www$ sudo chmod -R 777 uploads
pranabs@ubuntu:/var/www$ sudo chmod -R 777 classes
pranabs@ubuntu:/var/www$ sudo chmod -R 777 logs
pranabs@ubuntu:/var/www$ sudo chmod -R 777 setup
pranabs@ubuntu:/var/www$ sudo chmod -R 777 pictures
pranabs@ubuntu:/var/www$ sudo chmod -R 777 temp


Click on the Check Again button after changing the permissions.
image

Click on Continue to proceed.
In this step we have to configure database connection to MySQL server. Connect to MySQL server and create the database and user.
mysql> create database phpmotion;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on phpmotion.* to 'phpmotion'@'localhost' identified by 'passw0rd';
Query OK, 0 rows affected (0.00 sec)


Enter the database details and click on Continue:
image

Enter the website information and other details and click Continue
image

Our setup is complete, remove the setup folder from PHPMotion root directory and click Login to Siteadmin to administer PHPMotion.
image

Installation is done, I can get the admin console:
image

But for proper functioning of this application we have to do some additional configurations.

Right now if we go to links like Video, Audios etc. we will get URL not found error
image

image

Also while uploading video the following error comes:
image

We have to change Apache config file to fix these issues

Open Apache config file /etc/apache2/sites-available/default and edit. My default file after editing looks as follows:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
     <Directory "/var/www/cgi-bin">
            AllowOverride None
            Options Indexes FollowSymLinks Includes ExecCGI
            Order allow,deny
            Allow from all
      </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
 
save and restart Apache. Also make sure that .htaccess file is present in the PHPMotion root folder. i.e. in my case in /var/www folder.
 
Ooopssss Server error after restarting Apache
image
 
Lets check the Apache error log.
/var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration, referer: http://mediaserver.mkcl.org/uploader.php
Error related to RewriteEngine i.e. mod_rewrite of Apache. May be it is not loaded by Apache. Lets check all the loaded modules of Apache.
 
pranabs@ubuntu:/var/www$ apachectl -t -D DUMP_MODULES
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
reqtimeout_module (shared)
setenvif_module (shared)
status_module (shared)

Rewrite module is not loaded, we have to enable rewrite module
pranabs@ubuntu:/var/www$ sudo a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
  service apache2 restart

pranabs@ubuntu:/var/www$ sudo service apache2 restart
 
Now check whether rewrite module has been loaded or not
pranabs@ubuntu:/var/www$ apachectl -t -D DUMP_MODULES
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
reqtimeout_module (shared)
 rewrite_module (shared)setenvif_module (shared)
status_module (shared)
 
Wow…. I can see the rewrite module.
 
Now all the links of PHPMotion site are working fine :) .
 
Also I found one issue, in the new user registration page, the captcha image is not getting displayed and new users unable to register to the site.
image
 
If I check the Apache error log I get the message:
PHP Warning:  imagettfbbox(): Could not find/open font in /var/www/includes/captcha.php on line 53, referer: http://mediaserver.mkcl.org/join.php
 
I got the solution for this problem from PHPMotion Forum.
Open the file captcha.php located inside includes directory of PHPMotion root directory, i.e. in my case /var/www/includes/captcha.php
pranabs@ubuntu:~$ sudo pico /var/www/includes/captcha.php
Change the var $font = 'DoradoHeadline.ttf'; to var $font = './DoradoHeadline.ttf';
 
image
 
Save this file and and check again. This will resolve the issue.
image
 
That's all we have to do. Relax and enjoy your PHPMotion installation.