Install H264 Streaming Module for Apache & PHP on CentOS Server

Installing the streaming module can be a problem sometimes. This is a simple ins;tall guide which worked fine in a standard CentOS7/cpanel server:

For Cpanel:

yum install ea-apache24-devel

otherwise:

yum install httpd-devel

wget http://h264.code-shop.com/download/apache_mod_h264_streaming-2.2.7.tar.gz
tar -zxvf apache_mod_h264_streaming-2.2.7.tar.gz
cd mod_h264_streaming-2.2.7
./configure
make
make install

Edit /usr/local/apache/conf/httpd.conf
Add the following lines:
LoadModule h264_streaming_module /usr/lib64/httpd/modules/mod_h264_streaming.so
AddHandler h264-streaming.extensions .mp4

Then restart your apache:
service httpd restart

Make sure the module is loaded, you can check using command:
/usr/local/apache/bin/apachectl -t -D DUMP_MODULES | grep h264_streaming_module

then, cd to a public_html which is resolving correctly and run
cd /home/user/public_html
wget -O test.mp4 "http://h264-demo.code-shop.com/demo/apache/trailer2.mp4"

http://your-servers-ip/test.mp4?start=55.5

You will see the opening preview credits in the first link and in the second, it should have the first 55.5 seconds removed from the original video file.

Compile ffmpeg libs on Windows with Visual Studio compiler

Today I spent some time to compile ffmpeg libs on Windows. Most documentation out there is not updated to 2015, yet compiling ffmpeg on Windows is pretty easy. If you’re looking for a copy and paste solution, keep reading.

2015-06-30-ffmpeg.png

Pre-requisites

  • Visual Studio 2013 or 2015
  • MSYS2
  • YASM

Visual Studio

Latest ffmpeg versions compile both with Visual Studio 2013 and 2015. Previous versions don’t compile with VS2015 because they expect that VS compiler has no snprintf support while it was introduced in VS2015.

MSYS2

  1. Download and run the installer at ​http://msys2.github.io. Follow the instructions and install it in C:\workspace\windows\msys64
  2. Install required tools: pacman -S make gcc diffutils
  3. Rename C:\workspace\windows\msys64\usr\bin\link.exe to C:\workspace\windows\msys64\usr\bin\link_orig.exe, in order to use MSVC link.exe (naming conflict)

YASM

  1. Download Win64.exe and move it to C:\workspace\windows
  2. Rename yasm-<version>-win64.exe to yasm.exe
  3. Add C:\workspace\windows to PATH environment variable (setx PATH "%PATH%;C:\workspace\windows)

Ready to compile

Launch msys2 shell from Visual Studio Code shell

  1. Run VS2013/VS2015 prompt
  2. Run C:\workspace\windows\msys64\msys2_shell.cmd -msys -use-full-path: will open msys2 shell inheriting %PATH% from VS2013/VS2015 prompt
  3. Ensure which cl exists and which link points to MSVC
  4. cd /c/path/to/ffmpeg
  5. ./configure and make

Basic configure switches:

./configure \
    --toolchain=msvc \
    --arch=x86 \
    --enable-yasm \
    --enable-asm\
    --enable-shared \
    --disable-static

 

ruTorrent – How to auto install on CentOS and Debian

Installing ruTorrent on CentOS and Debian

ruTorrent Logo

WHAT IS A SEEDBOX?

Simply, a seedbox (like ruTorrent) is a server used for downloading and uploading files. A seedbox is usually used to run and download torrents which can later be downloaded through FTP.

Seedboxes have a very fast internet connection (100 mbps, 1gbps…)
I’m going to use a script to auto install everything to avoid some hardcore configurations. This is the quickest method of turning a server into a seedbox. It was tested on a fresh CentOS6 64 bit installation and a fresh Debian6 64 bit installation. The server has 256 MB RAM and 512 MB Burst RAM, although 256MB should be fine.

INSTALLING RUTORRENT ON CENTOS 6

First let’s update all our current packages:

yum update

Make sure wget is installed to download the installer:

yum install wget

Then we download the installer:

wget –no-check-certificate https://raw.github.com/etiennerached/rutorrent-auto-installer-centos/master/rutorrent-installer.sh

And run it:

sh rutorrent-installer.sh
The installer will start, you can keep the default settings by pressing enter, or just choose the ones you want.
I’m going to use Apache as the web server and install ruTorrent to manage the torrents from a web interface.
Seedbox Installation
Next, we create a torrent user, I will call mine “tor” for this tutorial. And we install the FTP server with a secure encrypted connection (FTPES), I will choose port number 666.
If you would like to manage your server from a web-interface, you can install webmin, which by default will run on port 10000.
Seedbox Installation
After choosing all the settings, we press Enter to install and configure. This might take around 5 minutes, depending on the server speed. If Webmin is to be installed, more configuration has to be done after few minutes, pressing enter and leaving the default value is OK.
To access the webinterface, go to your-domain-name/rutorrent, or Server-IP-Address/rutorrent, enter the username you chose (tor in my case) and the password.
ruTorrent Interface
To access the FTP, make sure you choose the port number that was selected during the installation (666 in this tutorial), and select FTP over explicit TLS or SSL. Make sure you accept the certificate. The downloaded files will be located in the downloads directory.
Ftp

Happy Torrenting!

INSTALLING RUTORRENT ON DEBIAN 6

First let’s update all our current packages:

apt-get update

Then we download the installer:

wget –no-check-certificate https://raw.github.com/etiennerached/rutorrent-auto-installer-centos/master/rutorrent-installer.sh

And run it:

sh rutorrent-installer.sh

or

sudo rutorrent-installer.sh
The installer will start, you can keep the default settings by pressing enter, or just choose the ones you want.
I’m going to use Apache as the web server and install ruTorrent to manage the torrents from a web interface.
Seedbox Installation
Next, we create a torrent user, I will call mine “tor” for this tutorial. And we install the FTP server with a secure encrypted connection (FTPES), I will choose port number 666.
If you would like to manage your server from a web-interface, you can install webmin, which by default will run on port 10000.
Seedbox Installation
After choosing all the settings, we press Enter to install and configure. This might take around 5 minutes, depending on the server speed. If Webmin is to be installed, more configuration has to be done after few minutes, pressing enter and leaving the default value is OK.
To access the webinterface, go to your-domain-name/rutorrent, or Server-IP-Address/rutorrent, enter the username you chose (tor in my case) and the password.
ruTorrent Interface

If the webinterface is not loaded correctly, try to re-install irssi.

sudo apt-get install irssi
To access the FTP, make sure you choose the port number that was selected during the installation (666 in this tutorial), and select FTP over explicit TLS or SSL. Make sure you accept the certificate. The downloaded files will be located in the downloads directory.
FTP Login

NOTE:

If you get the below error when you access rutorrent:

AutodlIrssiTab._getNewLines: Exception info: name = TypeError; message = $.browser is undefined; fileName = https://xxx.xxx.xxx.xxx/rutorrent/plugins/autodl-irssi/AutodlFilesDownloader.js; lineNumber = 28;

or

Error downloading files. Make sure autodl-irssi is started and configured properly (eg. password, port number): AutodlFilesDownloader.downloadAllFiles: Exception info: name = TypeError; message = $.browser is undefined; fileName = https://xxx.xxx.xxx.xxx/rutorrent/plugins/autodl-irssi/AutodlFilesDownloader.js; lineNumber = 28;

Go back to SSH and type the following command:

vi /var/rutorrent/rutorrent/plugins/autodl-irssi/AutodlFilesDownloader.js

Press “i” to go into editing mode, and replace:

if ($.browser.msie)

with

if ($.browser={ msie: ( navigator.appName == ‘Microsoft Internet Explorer’) ? true : false })

Press ESC to exit editing mode. Press :w to save. Press :q to quit.

If you are on CentOS 7:
Apache and mod_scgi does not work well on CentOS 7 yet. If you are on CentOS 7 You should choose nginx for now while installing.

And make sure to allow the http/https ports in the firewall:

sudo firewall-cmd –permanent –zone=public –add-service=http
sudo firewall-cmd –permanent –zone=public –add-service=https
sudo firewall-cmd –reload

Happy Torrenting!

How to Install ClamAV on CentOS 7

Install ClamAV

First, install the Epel (Extra Packages for Enterprise Linux) repository and the mailx command with yum. .

yum -y install epel-release

In this step, we will install Clam AntiVirus or ClamAV to get the best scanning results of LMD. ClamAV is available in the Epel repository (that we’ve installed in the first step).

Install ClamAV and ClamAV devel with yum:

yum -y install clamav clamav-devel

After ClamAV has been installed, update the ClamAV virus databases with the freshclam command:

freshclam

Update ClamAV malware database with the freshclam command after Install ClamAV

Useful FFmpeg Commands

Fmpeg is an extremely powerful and versatile command line tool for converting audio and video files. It is free and available for Windows, Mac and Linux machines. Whether you want to join two video files, extract the audio component from a video file, convert your video into an animated GIF, FFmpeg can do it all and even more.

Extract the audio from a video file with this simple FFmpeg command.
Extract the audio from a video file with this simple FFmpeg command.

USEFUL FFMPEG COMMANDS

FFmpeg supports all popular audio and video formats. Or you can running the command ./ffmpeg -formats to get a list of every format that is supported by your FFmpeg installation. If you are just getting started, here are some commands that will give you good idea of the capabilities of this tool.

1. CUT VIDEO FILE INTO A SMALLER CLIP

You can use the time offset parameter (-ss) to specify the start time stamp in HH:MM:SS.ms format while the -t parameter is for specifying the actual duration of the clip in seconds.

ffmpeg -i input.mp4 -ss 00:00:50.0 -codec copy -t 20 output.mp4

2. SPLIT A VIDEO INTO MULTIPLE PARTS

If you want to split a large video into multiple smaller clips without re-encoding, ffmpeg can help. This command will split the source video into 2 parts – one ending at 50s from the start and the other beginning at 50s and ending at the end of the input video.

ffmpeg -i video.mp4 -t 00:00:50 -c copy small-1.mp4 -ss 00:00:50 -codec copy small-2.mp4

3. CONVERT VIDEO FROM ONE FORMAT TO ANOTHER

You can use the -vcodec parameter to specify the encoding format to be used for the output video. Encoding a video takes time but you can speed up the process by forcing a preset though it would degrade the quality of the output video.

ffmpeg -i youtube.flv -c:v libx264 filename.mp4
ffmpeg -i video.wmv -c:v libx264 -preset ultrafast video.mp4

4. JOIN (CONCATENATE) VIDEO FILES

If you have multiple audio or video files encoded with the same codecs, you can join them into a single file using FFmpeg. Create a input file with a list of all source files that you wish to concatenate and then run this command.

ffmpeg -f concat -i file-list.txt -c copy output.mp4

5. MUTE A VIDEO (REMOVE THE AUDIO COMPONENT)

Use the -an parameter to disable the audio portion of a video stream.

ffmpeg -i video.mp4 -an mute-video.mp4

6. EXTRACT THE AUDIO FROM VIDEO

The -vn switch extracts the audio portion from a video and we are using the -ab switch to save the audio as a 256kbps MP3 audio file.

ffmpeg -i video.mp4 -vn -ab 256 audio.mp3

7. CONVERT A VIDEO INTO ANIMATED GIF

FFmpeg is an excellent tool for converting videos into animated GIFs and the quality isn’t bad either. Use the scale filter to specify the width of the GIF, the -t parameter specific the duration while -r specifies the frame rate (fps).

ffmpeg -i video.mp4 -vf scale=500:-1 -t 10 -r 10 image.gif

8. EXTRACT IMAGE FRAMES FROM A VIDEO

This command will extract the video frame at the 15s mark and saves it as a 800px wide JPEG image. You can also use the -s switch (like -s 400×300) to specify the exact dimensions of the image file though it will probably create a stretched image if the image size doesn’t follow the aspect ratio of the original video file.

ffmpeg -ss 00:00:15 -i video.mp4 -vf scale=800:-1 -vframes 1 image.jpg

9. CONVERT VIDEO INTO IMAGES

You can use FFmpeg to automatically extract image frames from a video every ‘n’ seconds and the images are saved in a sequence. This command saves image frame after every 4 seconds.

ffmpeg -i movie.mp4 -r 0.25 frames_%04d.png

10. MERGE AN AUDIO AND VIDEO FILE

You can also specify the -shortest switch to finish the encoding when the shortest clip ends.

ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -strict experimental output.mp4
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -strict experimental -shortest output.mp4

11. RESIZE A VIDEO

Use the size (-s) switch with ffmpeg to resize a video while maintaining the aspect ratio.

ffmpeg -i input.mp4 -s 480x320 -c:a copy output.mp4

12. CREATE VIDEO SLIDESHOW FROM IMAGES

This command creates a video slideshow using a series of images that are named as img001.png, img002.png, etc. Each image will have a duration of 5 seconds (-r 1/5).

ffmpeg -r 1/5 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p slideshow.mp4

13. ADD A POSTER IMAGE TO AUDIO

You can add a cover image to an audio file and the length of the output video will be the same as that of the input audio stream. This may come handy for uploading MP3s to YouTube.

ffmpeg -loop 1 -i image.jpg -i audio.mp3 -c:v libx264 -c:a aac -strict experimental -b:a 192k -shortest output.mp4

14. CONVERT A SINGLE IMAGE INTO A VIDEO

Use the -t parameter to specify the duration of the video.

ffmpeg -loop 1 -i image.png -c:v libx264 -t 30 -pix_fmt yuv420p video.mp4

15. ADD SUBTITLES TO A MOVIE

This will take the subtitles from the .srt file. FFmpeg can decode most common subtitle formats.

ffmpeg -i movie.mp4 -i subtitles.srt -map 0 -map 1 -c copy -c:v libx264 -crf 23 -preset veryfast output.mkv

16. CROP AN AUDIO FILE

This will create a 30 second audio file starting at 90 seconds from the original audio file without transcoding.

ffmpeg -ss 00:01:30 -t 30 -acodec copy -i inputfile.mp3 outputfile.mp3

17. CHANGE THE AUDIO VOLUME

You can use the volume filter to alter the volume of a media file using FFmpeg. This command will half the volume of the audio file.

ffmpeg -i input.wav -af 'volume=0.5' output.wav

18. ROTATE A VIDEO

This command will rotate a video clip 90° clockwise. You can set transpose to 2 to rotate the video 90° anti-clockwise.

ffmpeg -i input.mp4 -filter:v 'transpose=1' rotated-video.mp4

This will rotate the video 180° counter-clockwise.

ffmpeg -i input.mp4 -filter:v 'transpose=2,transpose=2' rotated-video.mp4

19. SPEED UP OR SLOW DOWN THE VIDEO

You can change the speed of your video using the setpts (set presentation time stamp) filter of FFmpeg. This command will make the video 8x (1/8) faster or use setpts=4*PTS to make the video 4x slower.

ffmpeg -i input.mp4 -filter:v "setpts=0.125*PTS" output.mp4

20. SPEED UP OR SLOW DOWN THE AUDIO

For changing the speed of audio, use the atempo audio filter. This command will double the speed of audio. You can use any value between 0.5 and 2.0 for audio.

ffmpeg -i input.mkv -filter:a "atempo=2.0" -vn output.mkv

Stack Exchange has a good overview to get you started with FFmpeg. You should also check out the official documentation at ffmpeg.org or the wiki at trac.ffmpeg.org to know about all the possible things you can do with FFmpeg.

TRANSFER FILES BETWEEN A PC AND ANDROID PHONE USING WIFI

The future is wireless and the trend is now being carried over by android phones too . These days a very few people actually prefer to use USB cables for transferring files between their PC’s and their phones / tablets . The reason being transferring files wirelessly is very convenient than transferring files through a USB cable and adding to the advantages, you don’t have to wait beside your PC until the transfers complete. While your files are being transferred to your phone you can carry on with your other works .

There are many apps on the android store that can help you to transfer files wirelessly between your PC and Android phones . Among these apps,  some come with bare and basic features like simply transferring files over WiFi and some add many more exciting features apart from the basic file transferring feature. For me, when it comes to features, i believe in the more the merrier. So in this guide I will make make use of an feature packed app to transfer files between a PC and an android phone .

How to Transfer files Wirelesssly between your Android phone and PC

AirDroid is one such popular and feature packed free android app which i use primarily to transfer files wirelessly across my phone and PC . The app can be used to both receive and send files wirelessly between your PC and android phone. Airdroid is basically an android app which helps to manage your android phone from your PC’s web browser .  The web interface of the app is very neat and the usability is the best among all the apps in its class. All in all its simple, beautiful and highly effective .

Usually while transferring files using AirDroid , i always get transfer speeds in excess of 3.5 Mbps, which is pretty much good. Apart from the file transferring feature, the app has many more useful features like :

  • You can view photos from your phone
  • You can send send SMS messages from PC
  • You can play music / videos from your phone
  • You can use your phone’s camera on your PC
  • You can take screenshots of your Phone
  • You can backup app as apk on your PC

All of this and more can be performed from AirDroid’s PC interface itself . Now lets move ahead and find out how we can use airdroid to transfer files wirelessly between your PC and Android phone over a WiFi network .

Instructions to transfer files wirelessly from your PC to your Phone

  • Step 1: Install AirDroid from the Google play store and open the app on your phone .
  • Step 2: Connect to your PC’s wifi network from your android phone . ( If you are using a USB WiFi dongle like me then you can use Connectify to create a Wifi hotspot )
  • Step 3: Open the AirDroid app and Instantly the app will detect your WiFi network and start the AirDroid  server . The app will provide you with an ip address , which you have to type into your PC’s web browser to connect to the AirDroid  server .

airdroid-app-screenshoot

  • Step 4: Manually type in the ip address provided by the AirDroid app in your web browser and press enter  . Simultaneously You will see the below screen and your android phone will prompt you to accept the connection .

accept-airdroid-connection-on-phone

  • Step 5: On your android phone , tap on accept and you will be able to access the AirDroid interface on your PC’s web browser .

accept-connection-request-on-android-phone

  • Step 6: To the right of AirDroid web interface , there is a toolbox , click the file icon and next you can select from the folder / files icon to transfer a file or folder to your android phone .

send-files-through-airdroid

  • Step 7: To transfer a file to you android phone select the file tab from the AirDroid toolbox and click on the folder /file icon to select from any file from your PC .  As soon as you select the file , AirDroid will start transferring the file to your android phone . similarly you can also transfer entire folders to your android phone .

files-transferring-to-android-phone-from-pc

The files will be stored in the following locations on your phone : SD card/airdroid/upload

Transferring files from your Phone to your PC

If you want to transfer files from your Android phone to your PC , then you have to use the Airdroid web interface on your PC . All you need to do is click on the files icon from AirDroid’s web interface and select a file from the file browser that opens up , right click on any file and select download to download the file to your PC .

transferring-fiels-from-phone-to-pc-over-wifi

The file will be downloaded as regular downloads in your web browser and can be accessed from the download menu . Here is a screenshot of the transfer speed i was getting while downloading files from my android phone . I was able to get a constant  download speed of 3.5 Mbps which peaked around 4Mbps .

transfer-speed-over-wifi