Improving the FPS of streaming video in Motion

Motion is a great software for streaming USB webcam, video capture or network camera input to Motion JPEG Video (MJPG). However when using this software on my Raspberry PI to monitor water level on an industrial plant I have found the video to stutter and slow down a lot when there was lots of action happening in the picture or something was moving.

The way Motion works is by capturing snapshots from the camera at every frame per second, and saving them to the working directory defined in the config. By default this directory is in /tmp/motion, however this quickly filled up my Raspberry Pi disk and slowed down the video feed due to the increased disk access times. Motion also fails to delete files from this directory whenever the feed slows down – it can’t keep up!

To resolve this we must move the working directory to a RAM disk, I used a 256MB RAM disk using tmpfs.

1. Open the file /etc/fstab, and add the following line. This can be done using nano, for example “sudo nano /etc/fstab”, paste the following line and press CTRL + X, then Y to save and close.

tmpfs   /motion    tmpfs    defaults,noatime,nosuid,mode=0755,size=256m    0 0

In the end your /etc/fstab file should look something like this:

2. Create the directory to mount this using the following command:

mkdir /motion

3. Mount this directory from fstab:

mount /motion
chown motion:motion /motion/

4. Open the configuration file for motion (nano /etc/motion/motion.conf), find the line target_dir (CTRL + W, target_dir), and change it to the following:

target_dir /motion

Your file should look something like this:

If needed, save and exit with Nano using CTRL + X, then press Y.

5. You should now be able to restart Motion with the command “service motion restart”, and enjoy faster FPS!

How to disable remote access on TP Link wireless routers

Surprisingly many TP Link routers allow remote access from all IP’s, with the username and password “admin”. Turning this off is simple!

1. To find out if you are effected by this, click on the link in If you can see a TP-LINK login box, you are effected by this.

2. Login with the username “admin”, and the password “admin”. Once you have done this, select System Tools, then Password.

Enter “admin” into the old username and password fields, then enter a SECURE username and password into the 3 boxes titled “New User Name”, “New Password” and “Confirm New Password”. Once you have done this, click Save.

3. Click Security, then Remote Management. From here, change the “Remote Management IP Address Box” to

4. Click Save, then Reboot if prompted. Once rebooted, click the link in If you can’t reach the page, then your router is now secure.

Leaving router access open to the world should NOT be done, as it can be used for malicious purposes – most routers are miniature Linux PC’s, and support running custom programs!