More ffmpeg hell

Today I went to use the “mp” filter in ffmpeg (which I documented in another posting), and was told “no such filter”. (WTF!!??? @#$%@%^#%^&)

So I did a search and found that “mp” and “eq2” may have been removed and replaced with just “eq”. I haven’t found out definitively, but find no record of an “mp” filter in the FFMPEG documentation currently. There are also several other filters like “colorbalance” available, but I haven’t used them yet.

I tried porting my commands over to just the “eq” filter, but they may have rearranged the order of the elements because they didn’t work as they did previously. They didn’t bother to include any examples…

They also indicate that with the “eq” filter, you can specify with words what you want, such as contrast=0, but they give no examples of syntax, so I’m guessing. They also state “If the specified expression is not valid, it is kept at its current value”.

The old order was gamma:contrast:brightness:saturation:rg:gg:bg:weight

Defaults and ranges:
Contrast -2.0 to 2.0, default 0 (but I think it is default 1)
Brightness -2.0 to 2.0, default 0
Saturation 0 to 3, default 1
Gamma 0 to 10, default 1
Gamma r 0 to 10, default 1
Gamma g 0 to 10, default 1
Gamma b 0 to 10, default 1

Here are some tests. I will update as I figure it out:

I think the new order is
contrast : brightness : saturation : gamma : gamma r : gamma g : gamma b : weight

But I’m not sure. If both brightness and contrast have a default of 0, then the following test makes no sense:

ffmpeg -i test.m2ts -vf eq=1:0:1:1:1:1:1:1 foo.mp4 makes no changes

ffmpeg -i test.m2ts -vf eq=1:0:0:1:1:1:1:1 foo.mp4 yields B&W (indicates the 3rd value is saturation)

I think that contrast has a default of 1, not 0.

Here is what I used to correct a green cast that I got from videoing under fluorescent lighting, and also boosts saturation:

ffmpeg -i all.m2tsĀ  -vf eq=1:0:1.3:1:1:0.9:1:1 -c:v libx264 -c:a libfaac temp0.mp4

(That is the end of my tests. Sorry if you got a ton of notifications that I updated this post.)

Wireless bridging to places you can’t run cables

At work there is an out-building where I was told to install a security camera. The problem is that in order to run any cabling out to the building, we’d either need to trench through the paved lot (which contains several undocumented pipes and other cables) or do an aerial run (and we have some seriously large machinery come through on trucks that could hit such a cable).

We have an established network about 100 yards from the building, with unused fiber connections back to the switch-room and to the NVR.

The answer was to do a wireless connection from the out-building to the nearest location of fiber termination. I had never built anything like this before, so did a bit of research and figured out a nice secure way to do it. It has been working fine now for almost a year with no drops.

Here is a basic layout of the concept:
layout

The IP camera gets power from the first POE (power over ethernet) switch and does data transfers via the switch. The switch relays the information via CAT6 to the first wireless router. The router has a dish antenna attached and relays the information to the 2nd dish antenna and router, which then relays it to a switch in the next building. That switch converts it to multi-mode fiber and sends it on to the switch room. [There is actually an intermediate switch that receives it and sends it on. This part wasn’t technically needed for this particular camera, but there are other cameras that link in at this switch.] In the switch room, the final switch receives the fiber transmission and relays it over CAT6 to the NVR which records the video.

The camera network is on a private IP range (192.168.xxx.xxx). It is only using the LAN portion of each router, so I set the WAN to a private unused IP unrelated to the camera network (10.0.xxx.xxx). I set up the 2nd router as the central router, and the out-building router as a bridge to the central. The NVR has 2 NICs, so I set one to the private range and the other to an assigned IP from my company’s IT group. This keeps the camera traffic off of their switches unless someone specifically wants to see the cameras.

I disabled DHCP on each router since I don’t want them vending IPs at all, and I set static private IP addresses. I used my cellphone and the free Wifi Analyzer app to find a channel that wasn’t being used in the area, and used that for my routers. I enabled WDS bridging mode on the router in the out-building, gave it the name of the SSID to which it belongs, and gave it the MAC of the central router as the BSSID.

For security, I disabled broadcast of the SSID, set the password to WPA2 pre-shared, and used a rather long password. I tested the routers using their standard small antennas in the same room to make sure the settings worked prior to deploying the units. I also set MAC filtering to only allow the MAC of each router to talk to the other.

The dish antennas were the most “cool” part of this whole setup. I used the TP-LINK ANT2424B units. Honestly, they are overkill for the distance we needed. I didn’t realize that they were quite so large when I bought them, and they are actually good for up to 5 miles. But it was a learning experience and I know that I can make them work now. The antennas use a standard large coax N connector, and the routers use a tiny SMA connector, so I bought 40ft antenna cables and 2 of the short N to SMA connectors. The main thing I didn’t like about the antennas were how they connect to the mounting mast with a single U-bracket that also controls the angle of the antenna. Having the mount separate from the angle control would have made my installation a LOT easier. I weatherproofed the connection from the antenna to the cable with rubber tape and electrician tape.

I asked our plumbers for parts for the mounting mast and assembled those. One building is mostly sheet-metal, but has a wooden frame that I was able to use when mounting the mast. The other building had a handy wooden light-pole outside and I mounted to that. I used 5/16″ lag bolts. A carpenter once told me to not use 1/4 lags because they break a lot easier, in his experience. I used an impact wrench to drive them and it worked really well. On one building I drilled tap holes first and on the light-pole I just drove them in, on advice of another carpenter. I was up on a man-lift, so anything that made the job easier in that small space was welcome.

ant1
ant2
mast1
mount1
mount2
enclosure

Each antenna also has an inline surge suppressor unit with a grounding attachment near the antenna pigtail (purchased separately). I ran a 10AWG grounding cable with each antenna cable and attached those to the electrical ground cable on each building.

The routers were TP-LINK TL-WR841ND (I switched brands later to Linksys WRT1200ac, see update note below), the small POE switches are Netgear GS110TP which also have 2 SFP fiber outlets. I find them to be an economical solution for getting both POE and fiber connections. The SFP modules can be either single-mode or multi-mode, and are easy to get from Amazon or other online sellers. Having a multi-port POE switch in a location allows me to add on more cameras in that location, so I have these in a variety of spots.

The antennas don’t need to be laser sighted unless you are going a long distance. I got them close just by eyeballing it. The documentation says that the signal is polarized, so have both antennas either horizontal or vertical.

I may end up replacing the routers with a type that has gigabit ports. I’m seeing some sluggish video. Part of that is being limited to 20fps on a couple of older 3MP dome cams. Wireless is theoretically 300Mbps. I could try the new 802.11ac kind, but I’m limited by what the customer will spend.

UPDATE: After a few weeks of use, the TL-WR841ND units kept dropping the wireless link, sometimes up to an hour and a half! That’s no good for what I needed, so I got two Linksys WRT1200ac routers, put one in Wireless Bridge mode (forwards wired connections wirelessly to the primary router). They’ve been working fine for almost a year now, no drops at all. I had to use them in wireless N mode because the antennas I chose only work on the 2.4GHz range. I could mount a couple of square 5GHz antennas to get ac mode, but it’s working as-is. Had to ask where to find Bridge Mode, and it is under Internet Settings.