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

Using cron to delete files older than X minutes/ days

If you want to empty files in /tmp folder older than X minutes:

find /tmp -mmin +30 -type f -name "*.*" -exec rm -f {} ;

+30: 30 minutes; “*.*”: if you want to delete all files (please specify name as you want)

If you want to empty files in /tmp folder older than X days:

find /tmp -mtime +1 -type f -name "*.*" -exec rm -f {} ;

+1: 1 days (24 hours); “*.*”: if you want to delete all files

How to install FFmpeg and ffmpeg-php on CentOS Easily

FFmpeg is an amazing collection of open-source tools that can record and stream video and audio. However, it can also transcode video and audio (convert the files to different formats), and that is what has me so excited. There’s also a great PHP package called ffmpeg-phpthat allows for easy use of FFmpeg from inside PHP scripts. Today, I’m going to see if I can’t help you get both of these set up on your system.

Admittedly, it’s been a while since I’ve tried to install FFmpeg, about two years. I recently thought up some ideas on how I’d like to use FFmpeg, so I thought it was time to give it a try yet again. Today, I’m proud to say that installing FFmpeg is so much easier to install compared to the past, that I dare say it’s simple.

Here is my experience with installing FFmpeg on my server and how to fix the pitfalls that I encountered.

Preface

Note that I did all the following steps on a CentOS server. The specific version is CentOS x64 6.7.

These instructions can work for other distros with little or no modifications, but some distros will be completely different. For example, theDAG RPM Repository that I’m using (more info below) has support for the following distros: Red Hat Enterprise Linux, Fedora Core, Yellow Dog Linux, Aurora Linux, CentOS, Scientific Linux (they really need to get a verified SSL cert), TaoLinux, WhiteBox Linux, Lineox, andBLAG. Other distros will need to use a different repository.

If you successfully get FFmpeg running on another distro, please comment your changes here and I’ll update the post (and make sure you get credit of course).

Also note that I experienced some bumps in the road while installing everything. While many of you may not experience these issues, I found it important to document these problems and how I fixed them in case you encounter them.

Preparing

The first thing that you need to do is set up the DAG repository. This repository is an actively-maintained repository that provides a staggering number of packages with current or near current builds. Adding this repository is a great way to run the latest offerings of many packages.

Adding the DAG repository is simple. I’m using yum, so I did the following to add the repository:

  1. Create and open a new file called /etc/yum.repos.d/dag.repo. I ran “vi /etc/yum.repos.d/dag.repo“.
  2. Add the following text to the file:
    [dag]
    name=DAG RPM Repository
    baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
    gpgcheck=1
    enabled=1
  3. Finally, save and close the file.

In order to successfully use the DAG repository with tools such as yum, you need to add DAG’s GPG key. Failure to do so will result in an error like the following:

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
Public key for faac.x86_64.1.26-1.el5.rf.rpm is not installed

In order to add the GPG key for DAG, run the following:

rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

The DAG: Frequently Asked Questions page has additional instructions on how to get the repository loaded and working on your distro.

Now that DAG is setup, it’s a good idea to update all your packages.

yum update

Depending on the packages you currently have installed, this could potentially upgrade, install, or replace numerous packages that may or may not be very important to you. Make sure you carefully look through that list and do any necessary preparations before telling yum that it can go ahead.

For example, yum told me that it was going to replace my current MySQL interface library for Perl with a new one. I added to my check list a note to verify that my Perl code functioned correctly after the install.

I ran into another hitch when I told yum to go ahead with the update. It informed me that my current version of Subversion conflicted with the new version it wanted to install. When this happens, you need to remove the old package before proceeding. This time, I made backups of all of my repositories and my /etc/sysconfig/svnserve file before proceeding just in case. I then removed Subversion “yum remove subversion“, ran the update process “yum update“, and installed Subversion again “yum install subversion“.

Installing – FFmpeg

Now you are ready to install FFmpeg with yum. I wanted to install all the available FFmpeg packages, so I first asked yum what was available.

yum search ffmpeg

Searching through the results, I found that three packages need to be installed: ffmpeg, ffmpeg-devel, and ffmpeg-libpostproc.

yum install ffmpeg ffmpeg-devel ffmpeg-libpostproc

Note: If you install ffmpeg-libpostproc, the entire FFmpeg software library changes from the LGPL license to the GPL license.

After a couple of minutes, the packages and the packages that they depend on were installed.

I simply ran “ffmpeg” from the command line, and I took the lack of threatening error or warning messages as a good sign that things were working.

Preparing for ffmpeg-php

I often work with programs through command line calls in code, but I wanted something more robust this time, so I looked around and foundffmpeg-php. Based on the API, it looks to be a great tool to interface PHP and FFmpeg.

There are four things that are required to successfully install and run ffmpeg-php; they are:

  • ffmpeg-0.4.9_pre1 or higher
  • php-4.3.0 or higher
  • gd-2.0 or higher
  • php-devel

PHP and FFmpeg should be good to go since at the time of this writing, DAG has PHP version 5.1.6 and FFmpeg version 0.4.9. GD and php-devel can be easily installed by running the following yum command:

yum install php-gd php-devel

In case you are wondering what php-devel is for, it installs the phpize program which is used to install ffmpeg-php.

Installing ffmpeg-php

Now we are ready to install ffmpeg-php. This can be done in six easy steps:

  1. Download the latest ffmpeg-php release
  2. Extract the archive:
    tar -xjf ffmpeg-php-X.x.x.tbz2
  3. cd ffmpeg-php-X.x.x/
  4. phpize
  5. ./configure && make
  6. sudo make install

Finishing Thoughts

This may seem like a lot of work when I earlier described this process as “simple,” but trust me that this is a thousand times easier than when I first tried installing FFmpeg. I think I spent three hours working on installing FFmpeg just to find out that it didn’t work the first time I tried.

Time and time again, package management has proven to be an extremely powerful tool. While I know the value of manually configuring and compiling code, the ease of simply using a package manager can reduce the time needed to install and manage software from hours or days to minutes.

I’m glad to see that FFmpeg has benefited from the use of these package managers and great repositories like the DAG RPM Repository.

How to install MP4Box on CentOS

MP4Box is a MP4 multiplexer. So let see How TO Install MP4Box on CentOS.  MP4Box can import MPEG-4 video, DivX, XviD, 3ivx, h264 etc, audio streams and subtitles into the .mp4 container. The end result is a compliant MP4 stream. It can also extract streams from a .mp4. MP4Box is a command line tool, but can be used with graphical user interfaces such as YAMB or my MP4box GUI.

1) Install some dependencies packages with yum command

 yum -y install freetype-devel SDL-devel freeglut-devel

2) Download and install gpac

cd /usr/local/src/
wget http://mirror.ffmpeginstaller.com/source/gpac/gpac-0.5.0.tar.gz
wget http://mirror.ffmpeginstaller.com/source/gpac/gpac_extra_libs-0.5.0.zip

3) Extract gpac tar files

tar -zxvf gpac-0.5.0.tar.gz
unzip gpac_extra_libs-0.5.0.zip

4) Install gpac

cd extra_libs
cp -r * /usr/local/src/gpac/extra_lib
cd ..
cd gpac
chmod 755 configure
./configure
make lib
make apps
make install lib
make install
cp bin/gcc/libgpac.so /usr/lib 
install -m644 bin/gcc/libgpac.so /usr/local/lib/libgpac.so
chmod +x /usr/local/lib/libgpac.so
ldconfig

And it’s done.

[root@server ~]# which MP4Box
/usr/local/bin/MP4Box
[root@server ~]# /usr/local/bin/MP4Box -version
MP4Box - GPAC version 0.5.0-rev4065
GPAC Copyright: (c) Jean Le Feuvre 2000-2005
 (c) ENST 2005-200X
GPAC Configuration:
Features: GPAC_HAS_SSL GPAC_HAS_JPEG GPAC_HAS_PNG

Install Transmission Client to RHEL / CentOS 6

Torrent Guide – Install Transmission Client to RHEL / CentOS 6

transmission

Transmission Bittorrent Client

Transmission is an open source and extremely lightweight Bittorrent client. It is available for any OS and comes with it’s own GUI interface.

Although Transmission is not as popular as rTorrent/ruTorrent for seedboxes, it is still a strong solid choice as it does not require a web server to be deployed on the OS and has a light memory footprint allowing for it to run in very-low ram VPS environments.

Installing Transmission-BT to CentOS 6

For this guide I will be using CentOS 6, but any RHEL distro should work with similar commands.

Transmission can be installed quite easily through the repositories, however it is not part of the default Red Hat repositories. First we will need to install the EPEL repository to our server:

You can find the lastest EPEL repositories here:

https://fedoraproject.org/wiki/EPEL

For simplicity sake you can always just following my guide with version as of time of this writing, as it will be updated when you do an upgrade anyways.

1
2
wget http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm

Now with this repository added we can install Transmission via yum

1
2
yum -y update
yum -y install transmission transmission-daemon

Then start the process:

1
service transmission-daemon start

Test Transmission

Transmission uses port 9091 by default, try it now using your server’s IP or FQDN.

You will either see Transmission load, or you will see an error like this:

Transmission_-_2014-04-21_14.36.17

The reason for this error is because Transmission is setup by default to only accept connections from localhost. If you get this error proceed to the next step…

Configure Transmission For Remote Access

Before we modify the configuration we’ll want to stop the service. This is important!! Transmission will write it’s setting files on shutdown, so if we edit the settings now and “restart” Transmission then our changes just get overwritten.

1
service transmission-daemon stop

Now we can make changes to the settings.json file. Transmission will automatically write it’s config to the user’s home directory. By default the daemon process will be using “Transmission” user which is set to /var/lib/transmission rather then using the /home folders.

If you have trouble finding your settings.json you can always use the findcommand:

1
find / -name settings.json

Edit the settings.json file once you’ve located it:

1
nano /var/lib/transmission/.config/transmission/settings.json

Find the following lines:

    "rpc-whitelist": "127.0.0.1",
    "rpc-whitelist-enabled": true,

Change this according to your preferences. When a “White List” is set it means only those IP addresses can access the software. If you want to use the White List then set the appropriate IP addresses here. Otherwise we can just set the whitelist to false like so:

    "rpc-whitelist": "127.0.0.1",
    "rpc-whitelist-enabled": false,

Start our service back up:

1
service transmission-daemon start

And test:

Transmission_Web_Interface_-_2014-04-21_14.44.55

Success!