How to: Set custom video encoding parameters for any camera that uses "CMS" for configuration .

Joined
Mar 20, 2019
Messages
26
Reaction score
8
Location
here
I've purchased a few cheapo cameras from China and the biggest annoyance so far has been the crappy bitrate settings the manufacturer has imposed. I'm assuming they're doing this so it looks like the camera is very efficient and recordings take up little space, but the picture quality is so terrible because of it and I find the cameras unusable.

I've been fishing for a while trying various things like custom firmware to remove this limitation, but I just stumbled across a brilliant Python library that allows full control of the camera outside CMS! You can even set things like custom text overlays, it's fantastic.

I'm just going to cover changing the bitrate settings here as that's what I set out to do.

First, open CMS and set up the camera settings as you want, ignoring the bitrate.

upload_2019-4-14_17-47-43.png


A good tip here, I've found the cameras fall over with high bitrate settings if your i frame interval is too long. We'll be able to put the bitrate up to a decent level with this mod, so select something small like 2.

Next download and install python 2.7: Python Release Python 2.7.16

Next, download this python library from here: NeiroNx/python-dvr

Put the python library on the desktop for handiness. Now open idle (it's installed with python). Click on File, then new. In the window that opens, paste the following code:

Code:
import sys
from dvrip import DVRIPCam
from time import sleep
import json

#FILL IN YOUR DETAILS HERE:
CameraUserName = "admin"
CameraPassword = ""
CameraIP = '192.168.178.68'
BitrateRequired = 7000
#END OF USER DETAILS


if len(sys.argv) > 1:
    CameraIP = str(sys.argv[1])

cam = DVRIPCam(CameraIP,CameraUserName,CameraPassword)

if cam.login():
    print "Success! Connected to " + CameraIP
else:
    print "Failure. Could not connect to camera!"

sleep(2)
print "\r\n"
print "Current encoding settings:"
enc_info = cam.get_info("Simplify.Encode")
print enc_info
print "\r\n"
sleep(2)
enc_info[0]['MainFormat']['Video']['BitRate'] = BitrateRequired
cam.set_info("Simplify.Encode", enc_info)
print "Sent new bitrate settings\r\n"
sleep(5)
print "New encoding settings:"
print(cam.get_info("Simplify.Encode"))
print(cam.get_info("Simplify.Encode"))
print "\r\n"
print "Closing connection in 5 seconds..."
sleep(5)
cam.close()
Change the IP, username, password and bitrate as needed. The cameras I have here just use the username admin with no password.

Now, select file, save, and save the file in the same folder as the library.

Then click, run, run module.

The python script will now run and set the bitrate you set up!

Had to share this, I've been trying to find a way to do this for months!

EDIT: I just discovered something important.

DO NOT CONNECT THE DVR TO THE CAMERA USING THE ADMIN USER/PASS.

If you connect the DVR to the admin account, it will overwrite these settings (why I don't know, took a while to figure out why this was changing back). Create a new user account using CMS on the camera called something like "ReadOnly" and set it as a user account, not an admin account. Connect the DVR using this account to ensure it can't alter the encoding settings.
 
Last edited:
Top